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

Remove dependence on callsigns from `bin/commit-hook`

Summary:
Ref T4245. Two effects:

- First, let hooks work for future repositories without callsigns.
- Second, provide a better error when users push directly to hosted repositories.

Test Plan: Ran `bin/commit-hook PHID-REPO-xxx`.

Reviewers: chad, avivey

Reviewed By: avivey

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D15293

+42 -6
+6 -5
scripts/repository/commit_hook.php
··· 32 32 require_once $root.'/scripts/__init_script__.php'; 33 33 34 34 if ($argc < 2) { 35 - throw new Exception(pht('usage: commit-hook <callsign>')); 35 + throw new Exception(pht('usage: commit-hook <repository>')); 36 36 } 37 37 38 38 $engine = new DiffusionCommitHookEngine(); 39 39 40 40 $repository = id(new PhabricatorRepositoryQuery()) 41 41 ->setViewer(PhabricatorUser::getOmnipotentUser()) 42 - ->withCallsigns(array($argv[1])) 42 + ->withIdentifiers(array($argv[1])) 43 43 ->needProjectPHIDs(true) 44 44 ->executeOne(); 45 45 ··· 62 62 if (!strlen($username)) { 63 63 throw new Exception( 64 64 pht( 65 - 'Usage: %s should be defined!', 66 - DiffusionCommitHookEngine::ENV_USER)); 65 + 'No Direct Pushes: You are pushing directly to a repository hosted '. 66 + 'by Phabricator. This will not work. See "No Direct Pushes" in the '. 67 + 'documentation for more information.')); 67 68 } 68 69 69 70 if ($repository->isHg()) { ··· 77 78 // specify the correct user; read this user out of the commit log. 78 79 79 80 if ($argc < 4) { 80 - throw new Exception(pht('usage: commit-hook <callsign> <repo> <txn>')); 81 + throw new Exception(pht('usage: commit-hook <repository> <repo> <txn>')); 81 82 } 82 83 83 84 $svn_repo = $argv[2];
+1 -1
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
··· 192 192 } 193 193 194 194 private function getHookContextIdentifier(PhabricatorRepository $repository) { 195 - $identifier = $repository->getCallsign(); 195 + $identifier = $repository->getPHID(); 196 196 197 197 $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); 198 198 if (strlen($instance)) {
+35
src/docs/user/userguide/diffusion_hosting.diviner
··· 371 371 is caused by SVN wiping the environment (including PATH) when invoking 372 372 commit hooks. 373 373 374 + No Direct Pushes 375 + ================ 376 + 377 + You may get an error about "No Direct Pushes" when trying to push. This means 378 + you are pushing directly to the repository instead of pushing through 379 + Phabricator. This is not supported: writes to hosted repositories must go 380 + through Phabricator so it can perform authentication, enforce permissions, 381 + write logs, proxy requests, apply rewriting, etc. 382 + 383 + One way to do a direct push by mistake is to use a `file:///` URI to interact 384 + with the repository from the same machine. This is not supported. Instead, use 385 + one of the repository URIs provided in the web interface, even if you're 386 + working on the same machine. 387 + 388 + Another way to do a direct push is to misconfigure SSH (or not configure it at 389 + all) so that none of the logic described above runs and you just connect 390 + normally as a system user. In this case, the `ssh` test described above will 391 + fail (you'll get a command prompt when you connect, instead of the message you 392 + are supposed to get, as described above). 393 + 394 + If you encounter this error: make sure you're using a remote URI given to 395 + you by Diffusion in the web interface, then run through the troubleshooting 396 + steps above carefully. 397 + 398 + Sometimes users encounter this problem because they skip this whole document 399 + assuming they don't need to configure anything. This will not work, and you 400 + MUST configure things as described above for hosted repositories to work. 401 + 402 + The technical reason this error occurs is that the `PHABRICATOR_USER` variable 403 + is not defined in the environment when commit hooks run. This variable is set 404 + by Phabricator when a request passes through the authentication layer that this 405 + document provides instructions for configuring. Its absence indicates that the 406 + request did not pass through Phabricator. 407 + 408 + 374 409 = Next Steps = 375 410 376 411 Once hosted repositories are set up: