Git Templates with hooks
Git Starter Template with opinionated hooks to help you create beautiful commits with high quality standards..and emojis ✨
If there is an issue with a hook, please open an issue and consult the section Opt Out for a workaround.
The workflow
First, commit
. A nice template message appears to help you write a meaningful commit description that passes the requirements.
The message saved, validators run in parallel. If there is an issue, the commit is aborted
Ready to push? once git push
is started, the tests runs for the module you updated, branch name is checked. The branch is pushed. Bravo
The wiki explore in details this workflow
The wiki also lists all the implemented hooks
Setup
Clone the repository to a convenient place:
mkdir ~/.config/git
cd ~/.config/git
git clone https://github.com/fredericrous/git-templates.git
chmod +x templates/hooks/*
Setup your gitconfig
git config --global init.templatedir ~/.config/git/git-templates/templates
git config --global commit.template ~/.config/git/git-templates/message
Copy the hooks to existing repositories
cd <folder-of-your-repo>
git init
Update
Update the local clone to the latest version
cd ~/.config/git/git-templates/templates
git pull
Update the target repository
rm $(git rev-parse --git-dir)/hooks/*
git init
Requirements
- Git 2.22+
- ZSH
- NodeJS 11.7+
- ripgrep
Wiki
- Coding Flow - an explanation of where the hooks fit in your git "flow"
- Commit Prefix - list of prefix your commit summaries should contain
- Hooks Implemented - all the hooks that are triggered when you execute a git command
- Ideas of hooks to implement - a list of ideas, not a roadmap
- Opt Out - bypass a check, a hook or uninstall it
- Similar Projects
Contribute
Basically if a script is simple implement it in shell script. If the logic is complicated, use javascript or any proper language to implement it. Javascript is nice because nowadays a lot of devs have nodejs installed on their machine.
There's a makefile, open it, see the different tasks, basically:
make test
runs the testsmake
is an alias tomake test
make install
copies the hooks from this repo to both .git/ and ~/.config/git/
To run only one test, use make test RUN=<part of the name of the test>