Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no more bad commit messages >:D #15

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

commit_message=$(<"$1")

if ! [[ $commit_message =~ ^(vingo:|vinscant:|vinvoor:|zess:) ]]; then
echo "Error: commit message should start with vingo:|vinscant:|vinvoor:|zess: depending on which subproject you are working on."
exit 1
fi

if ! [[ $commit_message =~ ^.*:\ [a-z].* ]]; then
echo "Error: first letter after project specifier should be lower case
Example:
vingo: add cheese
^
| this one"
exit 1
fi

exit 0
29 changes: 29 additions & 0 deletions .github/workflows/commit_message_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: commit message check
run-name: commit message check
on: [push]

jobs:
check_commit_messages:
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: check commit messages
run: |
git log --format="%s" origin/main..HEAD | while IFS= read -r message; do
if ! [[ $message =~ ^(vingo:|vinscant:|vinvoor:|zess:) ]]; then
echo $message
echo "Error: commit message should start with vingo:|vinscant:|vinvoor:|zess: depending on which subproject you are working on."
exit 1
fi

if ! [[ $message =~ ^.*:\ [a-z].* ]]; then
echo $message
echo "Error: first letter after project specifier should be lower case"
exit 1
fi
done