6

I wish to integrate a remote git repository with an RTC server, by using their RESTful interface to attach a link to gitweb for a commit associated with a particular task.

Ideally this will be done with a post-receive hook on the git server, but the processing user that git runs as is not allowed a user account to authenticate to RTC.

The best solution I can think of is to somehow pass an authentication token (Acquired from RTC in the form of cookies.txt) along with the git push (But not have it part of the commit).

The alternative would be a post-push hook on each client repository but that has its own problems (Including that there is no such hook).

Andrew Stubbs
  • 4,322
  • 3
  • 29
  • 48
  • 1
    Why don't you just add the link to the commit message at the client's side i.e. how gerrit does with Change-Id? – the.malkolm Jul 22 '13 at 12:17
  • Your post-receive hook should use some form of [IPC](http://en.wikipedia.org/wiki/Inter-process_communication) to tell a long-running process which had acquired the necessary authentication token to connect that RTC server and tell it whatever you need it to tell. That is, use a proxy process. – kostix Jul 22 '13 at 14:11

1 Answers1

7

With git version 2.10 and higher, you can use git --push-option <string> to pass the given string value to the server, which passes them to the pre-receive as well as the post-receive hook. git push documentation.

The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,…​ If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.git hook documentation

SteveCoffman
  • 983
  • 1
  • 8
  • 22
  • 1
    Note that on the server side, you still have to set `receive.advertisePushOptions` to `true` as described in [this thread](https://stackoverflow.com/questions/45400553/the-receiving-end-does-not-support-push-options) for this to work. It took me a while to figure out, because this is really not documented well. – Simeon Schaub May 11 '20 at 11:40