File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed
Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 3333 - name : Check commit message compliance of the pull request
3434 if : github.event_name == 'pull_request'
3535 run : |
36- ./run-tests.sh --check-commitlint ${{ github.event.pull_request.head .sha }}~${{ github.event.pull_request.commits }} ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.number }}
36+ ./run-tests.sh --check-commitlint ${{ github.event.pull_request.base .sha }} ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.number }}
3737
3838 lint-shellcheck :
3939 runs-on : ubuntu-24.04
Original file line number Diff line number Diff line change @@ -56,15 +56,28 @@ check_commitlint () {
5656 npx commitlint --from=" $from " --to=" $to "
5757 found=0
5858 while IFS= read -r line; do
59- if echo " $line " | grep -qP " \(\#$pr \)$" ; then
60- true
61- elif echo " $line " | grep -qP " ^chore\(.*\): release" ; then
62- true
63- else
64- echo " ✖ Headline does not end by '(#$pr )' PR number: $line "
59+ commit_hash=$( echo " $line " | cut -d ' ' -f 1)
60+ commit_title=$( echo " $line " | cut -d ' ' -f 2-)
61+ commit_number_of_parents=$( git rev-list --parents " $commit_hash " -n1 | awk ' {print NF-1}' )
62+ # (i) skip checking release commits generated by Release Please
63+ if [ " $commit_number_of_parents " -le 1 ] && echo " $commit_title " | grep -qP " ^chore\(.*\): release" ; then
64+ continue
65+ fi
66+ # (ii) check presence of PR number
67+ if ! echo " $commit_title " | grep -qP " \(\#$pr \)$" ; then
68+ echo " ✖ Headline does not end by '(#$pr )' PR number: $commit_title "
6569 found=1
6670 fi
67- done < <( git log " $from ..$to " --format=" %s" )
71+ # (iii) check absence of merge commits in feature branches
72+ if [ " $commit_number_of_parents " -gt 1 ]; then
73+ if echo " $commit_title " | grep -qP " ^chore\(.*\): merge " ; then
74+ break # skip checking maint-to-master merge commits
75+ else
76+ echo " ✖ Merge commits are not allowed in feature branches: $commit_title "
77+ found=1
78+ fi
79+ fi
80+ done < <( git log " $from ..$to " --format=" %H %s" )
6881 if [ $found -gt 0 ]; then
6982 exit 1
7083 fi
You can’t perform that action at this time.
0 commit comments