Skip to content

Commit

Permalink
last-edit
Browse files Browse the repository at this point in the history
  • Loading branch information
oxve committed Nov 14, 2023
1 parent a36a9a3 commit f46ba4b
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions .github/workflows/label-cherry-pick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,17 @@ jobs:
set -x
git fetch origin ${{ matrix.target_branch }}
rev_list=`git rev-list --parents -n 1 ${MERGE_COMMIT_SHA}`
hash_count=`wc -w <<< ${rev_list}`
set +e
# Select the first parent (-m 1) as the mainline tree.
git cherry-pick -x -m 1 ${MERGE_COMMIT_SHA}
RES=$?
set -e
# 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
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}
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
fi
- name: Create Pull Request
Expand Down

0 comments on commit f46ba4b

Please sign in to comment.