Marc Cataford
540ce0bbbb
* test: add integration test on ts skip * chore: add test prefix to commit linter * build: shell access * build: lint commit to include first commit
37 lines
1,016 B
Bash
37 lines
1,016 B
Bash
#!/usr/bin/bash
|
|
|
|
#
|
|
# This loosely implements the commit message linting check described by
|
|
# Conventional Commit (https://www.conventionalcommits.org). Commits merged in
|
|
# branches on this repository are expected to meet that general format:
|
|
#
|
|
# <prefix>: <message>
|
|
#
|
|
# where <prefix> is one of the prefixes included in the filters below.
|
|
#
|
|
|
|
CURRENT_HEAD=$(git rev-parse HEAD)
|
|
COMMITS=$(git log origin/main..$CURRENT_HEAD --oneline --format=%s)
|
|
|
|
if [[ -z "$COMMITS" ]]; then
|
|
echo "No commits."
|
|
exit 0
|
|
fi
|
|
|
|
INVALID_COMMITS_FOUND=0
|
|
|
|
while IFS='\n' read -r line; do
|
|
if [[ $line =~ ^"Merge "[0-9a-z]+" into "[0-9a-z]+$ ]]; then
|
|
continue
|
|
elif [[ ($line =~ ^(test|feat|chore|fix|refactor|wip|docs|build|ci|perf):) ]]; then
|
|
echo "VALID - $line"
|
|
else
|
|
echo "INVALID - $line"
|
|
INVALID_COMMITS_FOUND=$((INVALID_COMMITS_FOUND+1))
|
|
fi;
|
|
done <<< "$COMMITS"
|
|
|
|
if [[ $INVALID_COMMITS_FOUND -gt 0 ]]; then
|
|
echo "$INVALID_COMMITS_FOUND bad commit messages found."
|
|
exit 1
|
|
fi
|