Add Git pre-receive hooks
This suggestion is migrated to Developer Community. Please use below link to view the current status.
Add built-in Git pre-receive hooks to block undesirable commits from the repository. Examples include commit messages, file content scanning, and file names.
yes please add this
D I commented
Please add this! The lack of pre-receive hooks are making us seriously consider moving to Bitbucket server because we need to lock commits to a certain directory.
It would be great if we have some UI based Git Pre-recevie hooks option like Branch policies( which is great option in Azure Devops)
Maciek Samsel commented
Well it is not about just teaching people. People allowed slopiness pay least attention to process administration in development and they tend to create "their own ways" instead of following process established for commercial business. Also hooks are needed to enforce providing some information (comments, ticket number e.t.c.) that are critical to integrate with other tools (JIRA, Criucible e.t.c.)
John Goodwin commented
Since VSTS promotes the shared repo model ( no forks ), having pre-commit hooks would let me stop large files from coming into the repo, or a single commit too large. For some reason this is too hard to teach people, so I'd rather just make the server return an error.
Jason Finch commented
Would be beneficial to run https://github.com/smiley/git-hooks/blob/master/pre-receive/case-insensitive-branches.sh
pre-receive hooks are *essential* for our code and VSTS is useless without them.
You need pre-receive hooks to compete with GitHub.
Alex Mags commented
Would be great to block strings that look like secrets/passwords/API keys
We'd also love to have server-side git Hooks in VSTS
Dave Ferguson commented
Another would be enforcing naming conventions for branching (lower case always to prevent casing issues, prefixing with a set of folder names such as feature or release or hotfix, etc).
Sid M commented
I agree with yann Armand. We'd love to have pre-receive hooks to include logic to fix problems early on...
yann Armand commented
We'd love to have pre-receive hook to detect secrets being pushed.
We can use CredScan to detect them, but this is a build step, when it runs and detect the secrets, it is already too late, the secret is already present into the git history on VSTS server.
I'd love to use pre-receive for clang-format to reject inconsistent formatting on the server side (paired with pre-commit on the client).
We used to have update server hooks to check commit message should have work item id and I'd should exist in TFS otherwise reject the push.
Jakub Bereżański commented
One thing I used a pre-receive hook for in the past (before we moved to TFS) was to ensure that users had their user.name and user.email set correctly, e.g. FirstName LastName and matching work e-mail. I'd be glad to be able to reproduce that functionality in TFS.