Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rednaks/git-hook-commit-ref
git hook to add a reference to your commit message
https://github.com/rednaks/git-hook-commit-ref
Last synced: 3 days ago
JSON representation
git hook to add a reference to your commit message
- Host: GitHub
- URL: https://github.com/rednaks/git-hook-commit-ref
- Owner: rednaks
- Created: 2022-09-28T20:08:44.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-26T11:42:04.000Z (over 1 year ago)
- Last Synced: 2024-10-12T14:01:09.005Z (about 1 month ago)
- Language: Rust
- Homepage: https://crates.io/crates/git-hook-commit-ref
- Size: 34.2 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Description
Git hook to prepare commit message.Will check if you're allowed to commit or not, if you're allowed to commit, check if there is a reference that matches the branch
if not it will update the commit message.# How to use
build the project:
```
cargo install git-hook-commit-ref
```# Install the hook to your current git repo:
```sh
cd my_git_project
git hook-commit-ref --install
```
## Configure your git repoin your project, edit the `.git/config` file to add the organization and the project name, and a list of forbidden branches to commit from.
eg:
```
[commit-ref-hook]
org = "rednaks"
project = "git-hook-commit-ref"
forbiddenbranches = "master, release"
branchpattern = "(?P\w+).*-(?P\d+).*"
```## Branch name
the default branch name should match the `-` pattern, but if your branch name is different, make sure to add the regex matching your branch name.
don't forget to add `org` and `issue_number` to capture the matches.`org` is optional, but `issue_number` is required.
### Check everything is good
To check that everything works and configured, you can use `git hook-commit-ref --check` in your git repo.### Bypassing hook
In some situations like merging or rebasing there is no current branch, but a reference instead. you won't be able to commit your changes because it doesn't match the hook's configuration.
You can use `COMMIT_HOOK_IGNORE=true` env var when commit to bypass the hook.