Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I require (or urge) git commiters to provide relevant author info?

Tags:

git

Ninety-nine percent of time our team commits on local development boxes and pushes commits, in which case the authorship info on commits is correct. However, under times of high-stress someone will tweak something directly on the dev server and commit from there. When that happens the author info in the commit defaults to the shared deployment account.

Is there a way to prompt users for their author info on commit? They're not going to remember to do --author.

Some things I've looked at, but couldn't quite get across the finish line are:

  1. using a client side hook to reject commits with 'deploy' in the author string
  2. looked for a setting to always-prompt for author info
  3. try to automatically set author based on the ssh-key used to login to the box

Is there a way to get one of those to work or a good way to do it?

like image 459
Ry4an Brase Avatar asked Aug 09 '12 14:08

Ry4an Brase


People also ask

How do I commit a co author in git?

In the text box below your commit message, add Co-authored-by: name <[email protected]> with specific information for each co-author. If you're adding multiple co-authors, give each co-author their own line and Co-authored-by: commit trailer. Click Commit changes or Propose changes.


1 Answers

Okay, I found a way to do this, but it works only because we exclusively access this box over ssh using key based authentication.

In the shared deploy user's /home/deploy/.ssh/authorized_keys file I added an environment variable per key so that mine, for example, looks like this:

environment="[email protected]",environment="GIT_AUTHOR_NAME=Ry4an on Dev" ssh-rsa AAAA...cXBcmHr [email protected]

which also required adding:

PermitUserEnvironment yes

to the /etc/ssh/sshd_config file.

That works, but I'd rather learn about a user.name=ASK setting if such a thing existed.

like image 51
Ry4an Brase Avatar answered Oct 11 '22 10:10

Ry4an Brase