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 @@ -16,15 +16,28 @@ check_commitlint () {
1616 npx commitlint --from=" $from " --to=" $to "
1717 found=0
1818 while IFS= read -r line; do
19- if echo " $line " | grep -qP " \(\#$pr \)$" ; then
20- true
21- elif echo " $line " | grep -qP " ^chore\(.*\): release" ; then
22- true
23- else
24- echo " ✖ Headline does not end by '(#$pr )' PR number: $line "
19+ commit_hash=$( echo " $line " | cut -d ' ' -f 1)
20+ commit_title=$( echo " $line " | cut -d ' ' -f 2-)
21+ commit_number_of_parents=$( git rev-list --parents " $commit_hash " -n1 | awk ' {print NF-1}' )
22+ # (i) skip checking release commits generated by Release Please
23+ if [ " $commit_number_of_parents " -le 1 ] && echo " $commit_title " | grep -qP " ^chore\(.*\): release" ; then
24+ continue
25+ fi
26+ # (ii) check presence of PR number
27+ if ! echo " $commit_title " | grep -qP " \(\#$pr \)$" ; then
28+ echo " ✖ Headline does not end by '(#$pr )' PR number: $commit_title "
2529 found=1
2630 fi
27- done < <( git log " $from ..$to " --format=" %s" )
31+ # (iii) check absence of merge commits in feature branches
32+ if [ " $commit_number_of_parents " -gt 1 ]; then
33+ if echo " $commit_title " | grep -qP " ^chore\(.*\): merge " ; then
34+ break # skip checking maint-to-master merge commits
35+ else
36+ echo " ✖ Merge commits are not allowed in feature branches: $commit_title "
37+ found=1
38+ fi
39+ fi
40+ done < <( git log " $from ..$to " --format=" %H %s" )
2841 if [ $found -gt 0 ]; then
2942 exit 1
3043 fi
You can’t perform that action at this time.
0 commit comments