Skip to content

Commit

Permalink
馃摑 docs(faq): set hook to exit early outside main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Feb 7, 2024
1 parent 2f5ff91 commit 92d9071
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions website/docs/faq.md
Expand Up @@ -50,14 +50,6 @@ Yes. If you're using the `commit-msg` hook (`git sumi --init hook`), modify it s

set -e # Exit on any error.

# 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

# highlight-start
# Get the current branch name.
current_branch=$(git rev-parse --abbrev-ref HEAD)
Expand All @@ -68,6 +60,14 @@ if [ "$current_branch" != "main" ]; then
fi
# highlight-end

# 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.
```
Expand Down

0 comments on commit 92d9071

Please sign in to comment.