0

I want to use husky to run a shell script to return exit 1 if a user includes the --tags option in a git push command.

I have husky set up like this in my package.json

"husky": {
  "hooks": {
    "pre-push": "sh stopTagPush.sh"
  }
}

When I run the command git push origin --tags this runs my script but I don't know how to get access to the value of the git command git push origin --tags to see if --tags is present. Is there a git variable that I can use to access the command value inside the script?

user3891559
  • 169
  • 3
  • 12
  • 2
    You don't have access to the exact command, but the pre-push hook receives information about what would be pushed on its standard input, see [docs](https://git-scm.com/docs/githooks#_pre_push). – Benjamin W. Nov 30 '21 at 21:54
  • Users can include `--no-verify` and the hooks won't run, so it's not being enforced – Diego Torres Milano Dec 01 '21 at 03:59

0 Answers0