git-client-hook used for installing some git client hook into node project.
- If
npm test
passed, git push will go on, else git push will be cancelled, and output errors npm test found. - Check if the pushing branch is update to newest remotes/origion/master.
- Check if commit-msg is valid, check options as follows:
- if commit on branch: master/develop/release/test, it will output a warning.
- if commit without any message, this commit will fail.
- if branch name format does not satisfy
[feature | release | bugfix | hotfix]/JIRA-xxxx-brief-description
, this commit will fail. (correct branch name format) - if commit message already contains a jira task number(regex:
[A-Z][A-Z_0-9]+-[0-9]+
), it will not add one again.
- Add JIRA TASK number(branch name) to commit-msg.
If all above passed, commit-msg will add branch name (JIRA TASK number) to commit message.
Add JIRA Task number into commit message can build a link between git commit and JIRA TASK.
Run npm install git-client-hook --save-dev
, pre-push & commit-msg hooks
will install into git/hooks
.
Before install git hooks to .git/hooks
, there are also some checks,
Check options as follows:
- Git hook will install only if NODE_ENV is development or undefined.
- If project is managed by git.(has .git/ dir)
- Check if some hooks have already installed, if hooks have changed/updated. If hook has already installed and not changed, this hook will not install again, else if it updated, it will updated.
Run npm uninstall git-client-hook --save-dev
:
- git-client-hook will be uninstalled.
- git hooks installed into .git/hooks/ will be uninstalled.
You can add any fantasy git client hooks to the repository, or custom it for your project.
Tests are executed using Bats
Please feel free to submit pull requests and file bugs on the issue tracker.
- add post-commit to run npm test in background
- add git-hook CLI: 1.custom pre-commit email verify; 2.batch change current branch commits email
- optimize "feature branch update to master branch before push".
- add branch name format reference link.
- add branch name of
release
.
- restrict branch name format: [feature | bugfix | hotfix]/JIRA-xxxx-brief-description.
- optimize emoji.
- fix: JIRA Number can not prepend to commit-msg when
git commit
with editor.
- force feature branch update to master branch before git push.
- check whether feature branch merged/rebased newest master branch in pre-push.
- add travis ci
- fix shell if [[ to [
- fix some unit test warning
- fix mulit jira task add to commit-msg when open editor to edit commit message
- optimize jira number check:
- check jira number instead of branch name
- add jira number instead of branch name to commit-msg.
- add increment eslint check
- fix typo: romte_sha -> remote_sha
- change install approach
- backup all exist and affected hooks
- fix is_commit_msg_empty func in commit-msg
- modify README.md
- add git hook update unit-test
- rename unit test dir name
- change prepare-commit-msg to commit-msg. prepare-commit-msg invoked before editor, commit-msg invoked after user enters a commit message.
- optimize string judgement, fix string var bug:
$() to "$ ()" - fix empty commit-msg judegment.
- uninstall git hooks from .git/hooks/ when uninstall git-client-hook
- fix NODE_ENV does not work when bash git-hook-install.sh.
- remove bats & bats-assert from git-hook-install.sh
- update git unit test for new git-hook-install.sh