質問

I have a gitolite server and I would like to setup a server-side hook so that when anyone clones a repository located on it, an email is sent out to the administrator. Right now seems that is only able to do it for push but not for cloning.. Was I wrong?

役に立ちましたか?

解決

There is no server-side fetch hook from git. gitolite has PRE_GIT and POST_GIT triggers which you can use to detect when someone is fetching (running git-upload-pack) but the difference between a clone and a normal fetch is a human semantics one.

The only way to detect what may be a clone is way inside the protocol layer if the client doesn't provide any local commits in the negotiation, but it could still just be someone running fetch manually.

Lastly, as git is distributed, cloning from your server or cloning from elsewhere (maybe a coworker's computer/usb stick or a different repo in the same computer) and then fetching the rest from the server is essentially the same, as there is no strong binding between repositories.

他のヒント

Since there isn't really a hook on git clone (server side), that leaves you with a possible workaround:

Gitolite leaves a log of every operation, as I illustrate in "Is there a git activity log?".
However, it only record git-upload-pack instances, which means you know about git pull or git clone, without knowing which operation just occurred (pull or clone)

If you setup a cron job which monitor that gitolite log, you could send an email when detecting new occurrences of that git-upload-pack instance.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top