Skip to content

Commit

Permalink
tighten set +e
Browse files Browse the repository at this point in the history
  • Loading branch information
oxve committed Nov 14, 2023
1 parent 62332b9 commit 389a527
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/label-cherry-pick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,28 @@ jobs:
run: |
set -x
git fetch origin ${{ matrix.target_branch }}
set +e
rev_list=`git rev-list --parents -n 1 ${MERGE_COMMIT_SHA}`
hash_count=`wc -w <<< ${rev_list}`
# git rev-list returns a list of hashes: <HEAD_HASH> [<PARENT_HASH>...]
# It's not a merge commit if there are less than three (i.e. less than two parents).
if [ ${hash_count} -lt 3 ]; then
set +e
git cherry-pick -x ${MERGE_COMMIT_SHA}
RES=$?
set -e
if [ ${RES} -ne 0 ]; then
# If the cherry pick failed due to a merge conflict we can
# add the conflicting file and create the commit anyway.
git add .
git cherry-pick --continue
exit ${RES}
fi
else
# This commit is a merge commit and has multiple parents.
# Select the first parent (-m 1) as the mainline tree.
git cherry-pick -x -m 1 ${MERGE_COMMIT_SHA}
RES=$?
fi
- name: Create Pull Request
Expand Down

0 comments on commit 389a527

Please sign in to comment.