@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+3 -2
+2 -1
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 10 10 */ 11 11 final class DiffusionCommitHookEngine extends Phobject { 12 12 13 + const ENV_REPOSITORY = 'PHABRICATOR_REPOSITORY'; 13 14 const ENV_USER = 'PHABRICATOR_USER'; 14 15 const ENV_REMOTE_ADDRESS = 'PHABRICATOR_REMOTE_ADDRESS'; 15 16 const ENV_REMOTE_PROTOCOL = 'PHABRICATOR_REMOTE_PROTOCOL'; ··· 610 611 $console = PhutilConsole::getConsole(); 611 612 612 613 $env = array( 613 - 'PHABRICATOR_REPOSITORY' => $this->getRepository()->getCallsign(), 614 + self::ENV_REPOSITORY => $this->getRepository()->getPHID(), 614 615 self::ENV_USER => $this->getViewer()->getUsername(), 615 616 self::ENV_REMOTE_PROTOCOL => $this->getRemoteProtocol(), 616 617 self::ENV_REMOTE_ADDRESS => $this->getRemoteAddress(),
+1 -1
src/docs/user/userguide/diffusion_hooks.diviner
··· 42 42 These additional variables will be available in the environment, in addition 43 43 to the variables the VCS normally provides: 44 44 45 - - `PHABRICATOR_REPOSITORY` The callsign of the repository the hook is 45 + - `PHABRICATOR_REPOSITORY` The PHID of the repository the hook is 46 46 executing for. 47 47 - `PHABRICATOR_USER` The Phabricator username that the session is 48 48 authenticated under.