fix(core): guard against empty release in graduation check - #2531
Merged
Merged
Conversation
shipit threw "Cannot read properties of undefined (reading 'labels')" when --only-graduate-with-release-label was set and the release had no commits (head[0] is undefined). Guard the access with head.length > 0 so an empty release simply does not graduate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of the graduation-check guard from player-ui/player#885, applied to the TypeScript source (this repo is the source of
@auto-it/core).Problem
auto shipit --only-graduate-with-release-labelthrewTypeError: Cannot read properties of undefined (reading 'labels')when the release contained no commits —head[0]isundefinedand.labelsblows up.Fix
Guard the access with
head.length > 0before readinghead[0].labels, so an empty release simply does not graduate.Test
Added a regression test in
packages/core/src/__tests__/auto.test.ts("should not graduate with an empty release when onlyGraduateWithReleaseLabel is set") that mocks an emptygetCommitsInRelease, assertsshipitresolves without throwing, and thatlatest()is not called. Verified it fails without the guard and passes with it.🐤 Download canary assets:
auto-linux--canary.2531.2745a1a9810aac04cbd5119d35906eee96783e72.gz
auto-macos--canary.2531.2745a1a9810aac04cbd5119d35906eee96783e72.gz
auto-win.exe--canary.2531.2745a1a9810aac04cbd5119d35906eee96783e72.gz