Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get pusher's Information in post-receive hooks?

Tags:

git

hook

Author, Committer and Pusher can be different person in Git, but git didn't store the pusher's information in logs.

So, How do i get it?

like image 899
Saito Avatar asked Jul 01 '12 08:07

Saito


2 Answers

You don't.
The upstream repo doesn't make any assumption about who is providing commit: it can be through email, a diff patch copied on a USB key, and other various transfer protocol.

Some of those protocols (ssh, https) might have in their logs the information you seek, but:

  • this has nothing to do with Git
  • this suppose their log level is appropriately set.
  • even for Gitolite, the name of the public ssh key registered in the gitolite-admin repo can be anything you want, and not related to a real name.

As Linus mentions (in "Why do some open source projects do not accept pull requests, but emailing patch files only?"):

since github identities are random, I expect the pull request to be a signed tag, so that I can verify the identity of the person in question.

So if you want, as someone pushing some commits, to vouch for the integrity of the all repo, you can make and sign a tag on the HEAD of what is being pushed, in order for the upstream repo to consider you as, not exactly the "pusher", but the one validating what has been pushed

like image 119
VonC Avatar answered Sep 19 '22 12:09

VonC


If the push is happening over SSH, you may be able to use the USER environment variable. (This will also work for local pushes, of course.) This depends, of course, on whether the user that is used for SSH login is distinct for different users of your system - this isn't the case with gitolite, for example. (However, gitolite will define the GL_USER environment variable to identify the pusher.) For HTTP, you can try the REMOTE_USER environment variable.

Update: In general, this information isn't terribly interesting compared to the author and committer of the commits - it's always a surprise to me, for example, that GitHub displays the user who did particular pushes at all...

like image 31
Mark Longair Avatar answered Sep 19 '22 12:09

Mark Longair