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

✨ feat: add pre-commit hook config #199

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
welpo marked this conversation as resolved.
Show resolved Hide resolved
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
welpo marked this conversation as resolved.
Show resolved Hide resolved
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