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

后端 未结 2 640
猫巷女王i
猫巷女王i 2021-01-18 07:09

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?

相关标签:
2条回答
  • 2021-01-18 07:37

    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

    0 讨论(0)
  • 2021-01-18 07:49

    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...

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题