From a57bde547df8636cd9bf5703b7885703d23996ef Mon Sep 17 00:00:00 2001 From: Mattias Axelsson Date: Thu, 4 Apr 2024 16:33:19 +0200 Subject: [PATCH] Detect cherry-pick conflicts (#76) * Detect cherry-pick conflicts Detect cherry-pick conflicts and report them with a clear note in the PR title. * Update cherry-picker.yml --- .github/workflows/cherry-picker.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cherry-picker.yml b/.github/workflows/cherry-picker.yml index 6311275..d9285f5 100644 --- a/.github/workflows/cherry-picker.yml +++ b/.github/workflows/cherry-picker.yml @@ -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')"