Skip to content

Commit

Permalink
✨ feat: add pre-commit hook config (#199)
Browse files Browse the repository at this point in the history
Co-authored-by: welpo <welpo@users.noreply.github.com>
  • Loading branch information
TribuneX and welpo authored Feb 9, 2025
1 parent b450796 commit 673bbae
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- id: git-sumi
name: Lint commit message with git-sumi
description: Lints each new commit with git-sumi based on the configured project rules in your sumi.toml
entry: git-sumi --file
language: rust
pass_filenames: false
stages: [commit-msg]
16 changes: 16 additions & 0 deletions .release-hooks/pre-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Pre-release hook for the release script: https://github.com/welpo/release
VERSION_TAG="$1"
VERSION="${VERSION_TAG#v}" # Remove the 'v' prefix.
WEBSITE_DOCS_PATH='website/docs/integration.md'

# Update latest version in pre-commit hook docs.
# -i: edit file in place
# -pe: print and execute perl command
perl -i -pe 's/(rev: v)\K[\d.]+(?=\s+#)/'$VERSION'/g' "$WEBSITE_DOCS_PATH"

echo "Updated version in $WEBSITE_DOCS_PATH to:"
grep "rev: v" "$WEBSITE_DOCS_PATH" || {
echo "Error: Version update failed"
exit 1
}
4 changes: 4 additions & 0 deletions website/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ git sumi -c '🎨 refactor: format JS with Prettier'

If your message passes all rules, it will be committed. Otherwise, you'll see what went wrong.

:::tip
Do you use the [pre-commit](https://pre-commit.com/#intro) package manager? Check out the [integration guide](/docs/integration/#using-pre-commit) to add git-**sumi** to your pre-commit configuration.
:::

## Contributing

Please do! We appreciate bug reports, improvements to documentation (however minor), feature requests, code contributions… To get started, take a look at the [contributing guidelines](https://github.com/welpo/git-sumi/blob/main/CONTRIBUTING.md).
12 changes: 12 additions & 0 deletions website/docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ sidebar_position: 6

# Integration

## Using pre-commit

To integrate git-**sumi** with [pre-commit](https://pre-commit.com/#intro), add the following hook to your pre-commit config:

```yaml title=".pre-commit-config.yaml" showLineNumbers
repos:
- repo: https://github.com/welpo/git-sumi
rev: v0.0.9 # check latest version: https://github.com/welpo/git-sumi/tags
hooks:
- id: git-sumi
```
## Local linting with Git hooks
:::tip
Expand Down

0 comments on commit 673bbae

Please sign in to comment.