mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Pass repository PHID to custom hooks in PHABRICATOR_REPOSITORY instead of callsign
Summary: Ref T4245. We pass this exclusively for use by additional third-party hooks. This is technically a backward compatibility break, but I suspect it doesn't affect anyone: - Probably almost no one is using this (there are few reasons to, even for the tiny number of installs with custom commit hooks). - If they are, there's a good chance the PHID will work anyway, since nearly all scripts and Conduit methods will accept it in place of a callsign now, and if it's in logging or debugging code the PHID is a reasonable substitute - Even if it doesn't just keep working, the break should be very obvious in most reasonable cases. I'll call this out explicitly in the changelog, though -- almost everything else will just continue working, but this is a strict compatibility break. Test Plan: - Ugh. - Picked a hosted Git repo out of Diffusion. - Went to the path on disk. - Went into `hooks/`. - Went into `pre-receive-phabricator.d/`. - Wrote this hook and gave it `chmod +x`: ```name=stuff.sh #!/bin/sh echo $PHABRICATOR_REPOSITORY >> /tmp/stuff.log ``` - Pushed to the repository. - Saw a PHID show up in the log: ``` $ cat /tmp/stuff.log PHID-REPO-bqkcdp47euwnwlasrsrh ``` Reviewers: chad, avivey Reviewed By: avivey Subscribers: avivey Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D15294
This commit is contained in:
parent
973b8ace86
commit
925a0d3d59
2 changed files with 3 additions and 2 deletions
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
final class DiffusionCommitHookEngine extends Phobject {
|
||||
|
||||
const ENV_REPOSITORY = 'PHABRICATOR_REPOSITORY';
|
||||
const ENV_USER = 'PHABRICATOR_USER';
|
||||
const ENV_REMOTE_ADDRESS = 'PHABRICATOR_REMOTE_ADDRESS';
|
||||
const ENV_REMOTE_PROTOCOL = 'PHABRICATOR_REMOTE_PROTOCOL';
|
||||
|
@ -610,7 +611,7 @@ final class DiffusionCommitHookEngine extends Phobject {
|
|||
$console = PhutilConsole::getConsole();
|
||||
|
||||
$env = array(
|
||||
'PHABRICATOR_REPOSITORY' => $this->getRepository()->getCallsign(),
|
||||
self::ENV_REPOSITORY => $this->getRepository()->getPHID(),
|
||||
self::ENV_USER => $this->getViewer()->getUsername(),
|
||||
self::ENV_REMOTE_PROTOCOL => $this->getRemoteProtocol(),
|
||||
self::ENV_REMOTE_ADDRESS => $this->getRemoteAddress(),
|
||||
|
|
|
@ -42,7 +42,7 @@ These hooks act like normal `pre-commit` or `pre-receive` hooks:
|
|||
These additional variables will be available in the environment, in addition
|
||||
to the variables the VCS normally provides:
|
||||
|
||||
- `PHABRICATOR_REPOSITORY` The callsign of the repository the hook is
|
||||
- `PHABRICATOR_REPOSITORY` The PHID of the repository the hook is
|
||||
executing for.
|
||||
- `PHABRICATOR_USER` The Phabricator username that the session is
|
||||
authenticated under.
|
||||
|
|
Loading…
Reference in a new issue