I have a project in node. In this project I want to standardize commits and versioning. I installed husky, commitzen, commitlint and standard-version. They work great, my commit is running git-cz and I'm able to standardize my commits. So far so good! But every time I need to run the command "yarn standard-release" and "git push --follow-tags origin branch_whatever", and this is not productive for me.
What I want is, every time I do a "git push" command after a commit (fix, feat or chore), I want to run the standard-release add the options "--follow-tags origin branch_whatever" and then yes run the "git push" command, but if I put this command inside the pre-push hook, it loops on the husky, I've already tried using --no-verify, HUSKY=0 and it doesn't work.
Inside the pre-push hook script I can run the standard-release and "git push --follow-tags origin branch_whatever" without looping, any suggestions to solve this?
Note: Running this on CI/CD is not feasible for me at the moment.
Thanks!
package.json
{
"name": "app",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"prepare": "husky install",
"release": "standard-version",
"commit": "git-cz"
},
"keywords": [],
"license": "ISC",
"dependencies": {
"express": "^4.18.1"
},
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"commitizen": "^4.2.5",
"cz-conventional-changelog": "3.3.0",
"husky": "^8.0.1",
"standard-version": "^9.5.0"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"subject-case": [
2,
"never",
[
"start-case",
"pascal-case"
]
]
}
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
======= .husky/commit-msg
#!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh"
yarn commitlint --edit "$@"
======= .husky/pre-push
#!/usr/bin/env sh
#. "$(dirname -- "$0")/_/husky.sh"
yarn release git push --follow-tags origin "$(git rev-parse --abbrev-ref HEAD)"
======= terminal:
$ git add . $ yarn commit
Select example, feat commit
returned: feat: add new router
$ git push
enter hook pre-push
execute script, but looping pre-push script