We want every person that does a push in our git repository to run "grunt" before this is done. We enforce this by having a pre-push hook in .git/hooks/pre-push
and writing npm install
and grunt
in that file.
We also have a TFS repository. I am looking for similar logic to be used here. Meaning, we want a sort of "Gated check-in" when someone tries to check something in. This will only starts up PowerShell and runs npm install
and grunt
locally.
We don't want TFS to do anything else (run build, run tests etc. (all this is done in the grunt task)).
Is this possible? Anyone know how?
Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.
The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that's . git/hooks .
pre-commit hooks are a mechanism of the version control system git. They let you execute code right before the commit. Confusingly, there is also a Python package called pre-commit which allows you to create and use pre-commit hooks with a way simpler interface.
You can test a pre-receive hook script locally before you create or update it on your GitHub Enterprise Server instance.
TFS has nothing to do with what you do locally. You can add as many pre-commit hooks to your repo and push them to TFS. TFS will happily store these hook scripts. ANd when you are using a client that supports them, that client will execute them pre-commit.
But if you expect Visual Studio to run these hooks before commit, you're probably out of luck. There is no "check-in policy" support for Visual Studio when connected to Git. Nor in any other Git client based on LibGit2 at present as far as I can tell.
You could setup a branch policy linked to a CI build, effectively running the grunt tasks on a build server, but I understand this is not what you want. .
There's some background available on the LibGit2 issue section, which is what Visual Studio uses to implement its git functionality. And this corresponding user voice item for Visual Studio. As well as a discussion on the GitHub for Windows client which uses the same underlying library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With