Skip to content

Commit

Permalink
馃懛 misc(CI): use git-sumi hook to lint commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Feb 7, 2024
1 parent f7c0de4 commit 71f09a8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .githooks/commit-msg
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.

0 comments on commit 71f09a8

Please sign in to comment.