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
This commit is contained in:
epriestley
2016-02-17 16:45:22 -08:00
parent f5e2f9587c
commit 973b8ace86
3 changed files with 42 additions and 6 deletions

View File

@@ -32,14 +32,14 @@ $root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
if ($argc < 2) {
throw new Exception(pht('usage: commit-hook <callsign>'));
throw new Exception(pht('usage: commit-hook <repository>'));
}
$engine = new DiffusionCommitHookEngine();
$repository = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withCallsigns(array($argv[1]))
->withIdentifiers(array($argv[1]))
->needProjectPHIDs(true)
->executeOne();
@@ -62,8 +62,9 @@ if ($repository->isGit() || $repository->isHg()) {
if (!strlen($username)) {
throw new Exception(
pht(
'Usage: %s should be defined!',
DiffusionCommitHookEngine::ENV_USER));
'No Direct Pushes: You are pushing directly to a repository hosted '.
'by Phabricator. This will not work. See "No Direct Pushes" in the '.
'documentation for more information.'));
}
if ($repository->isHg()) {
@@ -77,7 +78,7 @@ if ($repository->isGit() || $repository->isHg()) {
// specify the correct user; read this user out of the commit log.
if ($argc < 4) {
throw new Exception(pht('usage: commit-hook <callsign> <repo> <txn>'));
throw new Exception(pht('usage: commit-hook <repository> <repo> <txn>'));
}
$svn_repo = $argv[2];