Skip to content

Commit

Permalink
ci(commitlint): check pr number presence in merge commits (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Aug 6, 2024
1 parent 47978e7 commit 469061e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,21 @@ check_commitlint () {
commit_hash=$(echo "$line" | cut -d ' ' -f 1)
commit_title=$(echo "$line" | cut -d ' ' -f 2-)
commit_number_of_parents=$(git rev-list --parents "$commit_hash" -n1 | awk '{print NF-1}')
if [ "$commit_number_of_parents" -le 1 ] && echo "$commit_title" | grep -qP "^chore\(.*\): release"; then
# release commit generated by release-please, skip checks
continue
fi
if ! echo "$commit_title" | grep -qP "\(\#$pr\)$"; then
echo "✖ Headline does not end by '(#$pr)' PR number: $commit_title"
found=1
fi
if [ "$commit_number_of_parents" -gt 1 ]; then
if echo "$commit_title" | grep -qP "^chore\(.*\): merge "; then
break
else
echo "✖ Merge commits are not allowed in feature branches: $commit_title"
found=1
fi
elif echo "$commit_title" | grep -qP "^chore\(.*\): release"; then
true
elif echo "$commit_title" | grep -qP "\(\#$pr\)$"; then
true
else
echo "✖ Headline does not end by '(#$pr)' PR number: $commit_title"
found=1
fi
done < <(git log "$from..$to" --format="%H %s")
if [ $found -gt 0 ]; then
Expand Down

0 comments on commit 469061e

Please sign in to comment.