From 57c6114fe13b974380ac7b7c369c027982953989 Mon Sep 17 00:00:00 2001 From: Mattias Axelsson Date: Thu, 4 Apr 2024 16:23:37 +0200 Subject: [PATCH 1/2] Detect cherry-pick conflicts Detect cherry-pick conflicts and report them with a clear note in the PR title. --- .github/workflows/cherry-picker.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cherry-picker.yml b/.github/workflows/cherry-picker.yml index 6311275..8d1b855 100644 --- a/.github/workflows/cherry-picker.yml +++ b/.github/workflows/cherry-picker.yml @@ -22,13 +22,17 @@ 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 + 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')" From 50bfcd5cde5870661a09c21e70c393528e97519f Mon Sep 17 00:00:00 2001 From: Mattias Axelsson Date: Thu, 4 Apr 2024 16:27:43 +0200 Subject: [PATCH 2/2] Update cherry-picker.yml --- .github/workflows/cherry-picker.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cherry-picker.yml b/.github/workflows/cherry-picker.yml index 8d1b855..d9285f5 100644 --- a/.github/workflows/cherry-picker.yml +++ b/.github/workflows/cherry-picker.yml @@ -24,8 +24,9 @@ jobs: commit_hash="$(git rev-parse refs/remotes/other/HEAD)" title_prefix= if ! git cherry-pick $commit_hash; then - title_prefix="CHERRY-PICK CONFLICT " - git cherry-pick $commit_hash --strategy-option theirs + 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))