File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,26 @@ TARGET_BRANCH="${1:-main}"
66echo " Target branch: $TARGET_BRANCH "
77git fetch origin $TARGET_BRANCH 2> /dev/null
88
9- out=$( git log origin/${TARGET_BRANCH} ..HEAD --merges --oneline)
9+
10+ # Detection of (PR) merge commits at tip of HEAD:
11+ target_sha=$( git rev-parse origin/${TARGET_BRANCH} )
12+ # Get SHA of parent commit
13+ merge_target=$( git log --merges --oneline --parents --no-abbrev-commit HEAD^..HEAD | cut -d" " -f2)
14+ # If parent is the target branch, start from the commit before the merge commit
15+ if [ " $target_sha " = " $merge_target " ] ; then
16+ tip=" HEAD^"
17+ else
18+ tip=" HEAD"
19+ fi
20+
21+ out=$( git log origin/${TARGET_BRANCH} ..${tip} --merges --oneline)
1022exit_status=$?
1123if [ -n " $out " ]
1224then
1325 echo " Please rebase your branch" >&2
1426 echo " If your branch or its base branch is a release branch then ignore this error" >&2
15- echo " \nMerge commit(s):" >&2
27+ echo >&2
28+ echo " Merge commit(s):" >&2
1629 echo " $out " >&2
1730 # Disclaimer: current version of the check doesn't work well with release branches
1831 exit_status=1
You can’t perform that action at this time.
0 commit comments