Skip to content

Resolve the commit to its full SHA before backporting - #201

Open
RaphaelFakhri wants to merge 1 commit into
python:mainfrom
RaphaelFakhri:resolve-short-sha
Open

RaphaelFakhri wants to merge 1 commit into
python:mainfrom
RaphaelFakhri:resolve-short-sha

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes #200.

cherry_picker builds the backport branch name from the commit SHA exactly as you typed it. When the SHA has fewer than 7 characters or contains uppercase letters, get_base_branch() rejects the branch name it just created. The command then crashes after the cherry-pick and leaves cherry-picker.state at BACKPORT_LOOP_START, which blocks --abort and --continue.

Changes

  • After fetching upstream, backport() resolves the commit with git rev-parse --verify <sha>^{commit} and uses the full SHA from then on. As a result, the branch name and the (cherry picked from commit ...) line always use the canonical SHA.
  • If the commit does not exist, backport() prints the Git error, resets the state, and exits before it creates a backport branch. Before this change, it created a backport-<sha>-<branch> branch, failed the cherry-pick, and left the run paused.

Tests

  • test_backport_resolves_commit_sha covers a 6-character SHA and an uppercase SHA.
  • test_backport_unknown_commit_sha checks that an unknown commit stops before checkout and leaves no state behind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backporting with a short or uppercase commit SHA crashes after the cherry-pick

1 participant