Skip to content

Commit

Permalink
Detect cherry-pick conflicts (#76)
Browse files Browse the repository at this point in the history
* Detect cherry-pick conflicts

Detect cherry-pick conflicts and report them with a clear note in the PR title.

* Update cherry-picker.yml
  • Loading branch information
killenheladagen authored Apr 4, 2024
1 parent 019c085 commit a57bde5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/cherry-picker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ jobs:
git remote add other $OTHER_REPO_FULL.git -f --no-tags -t main -m main
commit_hash="$(git rev-parse refs/remotes/other/HEAD)"
git cherry-pick $commit_hash
title_prefix=
if ! git cherry-pick $commit_hash; then
git cherry-pick --abort
title_prefix="CHERRY-PICK CONFLICT "
git cherry-pick $commit_hash --strategy-option theirs
fi
remote_pr_id=$(gawk 'match($0, /\(#([0-9]+)\)$/, ary) {print ary[1]}' <<< $(git show -s --format=%s))
trimmed_commit_msg="$(sed -E '1 s/ \(#[0-9]+\)$//' <<< $(git show -s --format=%B))"
git commit --amend -m "$trimmed_commit_msg"
title_txt="$(git show -s --format=%s)"
title_txt="$title_prefix$(git show -s --format=%s)"
echo "title text is $title_txt"
remote_pr_body="$(gh pr view $remote_pr_id --repo $OTHER_REPO_FULL.git --json body --jq '.body')"
Expand Down

0 comments on commit a57bde5

Please sign in to comment.