0

Currently due to collaboration across different vendors and contractors sometimes they use a malformed git config at the client side when checking in code

Once the code is checked in, bitbucket does not reconcile the correct username against the commit often appearing as in bitbuckets commit section.

This is not desirable for audits and can potentially corrupt the commit trail Need a custom pre commit hook to call the rest API to verfiy that the user has a account and email address against that REST Endpoint.

Lovato
  • 2,250
  • 1
  • 16
  • 22
sudhakar
  • 33
  • 1
  • 6

1 Answers1

0

Using this tool https://github.com/lovato/hooks4git you can create that script in your preferred language. This tool helps you out with the hook management.

What everyone needs to do (in any client side git hook approach) in to install that tool and activate it.

Other options: https://githooks.com/

Lovato
  • 2,250
  • 1
  • 16
  • 22
  • Thanks for the answer, i am confused if pre-commit script needs to be placed in server side(bitbucket) under repositories/repo#/hooks/pre-commit script or in the local from where we will commit and push under .git/hooks. – sudhakar Sep 24 '18 at 12:30
  • You are correct. Your title mentioned "pre-commit", which IS a local hook. If you are looking for a PRE-RECEIVE hook, this can solve your problem more effectively. Just be warned that errors (I have no idea how complex your script will be) on that server hook will also prevent legitimate pushes. – Lovato Sep 24 '18 at 17:15
  • Thanks for that, in that case need help on pre-recieve as we manage bitbucket repos, and cannot control users local, how he is commiting. So need help in pre-recieve script wherein once he tries to push to particular repo, call the rest API to verfiy that the user has a account and email address against that REST Endpoint. – sudhakar Sep 25 '18 at 10:49
  • The library is free to use. There is more information about its usage here: https://stackoverflow.com/questions/427207/can-git-hook-scripts-be-managed-along-with-the-repository – Lovato Apr 23 '19 at 17:54