-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 misc(CI): use git-sumi hook to lint commit messages
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Commit-msg hook generated by git-sumi. | ||
# For more information and documentation, visit: https://sumi.rs | ||
|
||
set -e # Exit on any error. | ||
|
||
# Get the current branch name. | ||
current_branch=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
# Check if the current branch is 'main'. | ||
if [ "$current_branch" != "main" ]; then | ||
exit 0 # Exit successfully without running git-sumi. | ||
fi | ||
|
||
# Check if git-sumi is installed. | ||
if ! command -v git-sumi &> /dev/null | ||
then | ||
echo "git-sumi is not installed. Please install it. See https://sumi.rs for instructions." | ||
echo "Alternatively, edit or remove the commit-msg hook in .git/hooks/commit-msg." | ||
exit 1 | ||
fi | ||
|
||
# Run git-sumi on the commit message if on the 'main' branch. | ||
git-sumi -- "$(cat $1)" # Exit with error if linting fails. |