0

So we just got FishEye/Crucible for out development server. Our git is set up to force public-private key auth, but some of the developers like to use multiple machines and not use more then one key like they are suppose. Or they use the same machine they use for personal development and use their personal email and identity. So their .gitconfig does not have correct identities. They might have three or four different identities because they commit from different machines ([user1]@[domain1], [user1]@[domain2], and [user1]@[domain3]). FishEye/Crucible does not like this at all. It see each one of these as a different committer. I have to manually go in and set mappings for each user for each project.

Is there a git hook or something that prevent a user from commit unless their identity is under the right format? So force the email for the identity to be in the format @[domain1] and reject any push request from any other domain (like @[domain2] or [domain3]). I have already look around a bit, but I am not sure where to look for this.

1 Answers1

2

You can use a pre-receive or update hook and reject the push if it contains commits with authors that do not match your criteria.

Using update has the advantage that you can selectively reject only branches containing such commits (in case the push updates multiple branches).

The top-scored answer in Git/gitosis: How to check validity of user name and email? contains an example of how to check the commits using pre-receive; updating it to work as an update hook should be straightforward with a short look at the githooks manpage.

Community
  • 1
  • 1
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • Sorry I never marked this as the answer. I was able to use the pre-hook inside of gitolite (called VREF) to enforce this. Thanks. – angellusmortis Mar 03 '14 at 19:37