Changeset View
Changeset View
Standalone View
Standalone View
scripts/repository/commit_hook.php
| Show All 11 Lines | |||||
| // Commit hooks execute in an unusual context where the environment may be | // Commit hooks execute in an unusual context where the environment may be | ||||
| // unavailable, particularly in SVN. The first parameter to this script is | // unavailable, particularly in SVN. The first parameter to this script is | ||||
| // either a bare repository identifier ("X"), or a repository identifier | // either a bare repository identifier ("X"), or a repository identifier | ||||
| // followed by an instance identifier ("X:instance"). If we have an instance | // followed by an instance identifier ("X:instance"). If we have an instance | ||||
| // identifier, unpack it into the environment before we start up. This allows | // identifier, unpack it into the environment before we start up. This allows | ||||
| // subclasses of PhabricatorConfigSiteSource to read it and build an instance | // subclasses of PhabricatorConfigSiteSource to read it and build an instance | ||||
| // environment. | // environment. | ||||
| $hook_start = microtime(true); | |||||
| if ($argc > 1) { | if ($argc > 1) { | ||||
| $context = $argv[1]; | $context = $argv[1]; | ||||
| $context = explode(':', $context, 2); | $context = explode(':', $context, 2); | ||||
| $argv[1] = $context[0]; | $argv[1] = $context[0]; | ||||
| if (count($context) > 1) { | if (count($context) > 1) { | ||||
| $_ENV['PHABRICATOR_INSTANCE'] = $context[1]; | $_ENV['PHABRICATOR_INSTANCE'] = $context[1]; | ||||
| putenv('PHABRICATOR_INSTANCE='.$context[1]); | putenv('PHABRICATOR_INSTANCE='.$context[1]); | ||||
| } | } | ||||
| } | } | ||||
| $root = dirname(dirname(dirname(__FILE__))); | $root = dirname(dirname(dirname(__FILE__))); | ||||
| require_once $root.'/scripts/__init_script__.php'; | require_once $root.'/scripts/__init_script__.php'; | ||||
| if ($argc < 2) { | if ($argc < 2) { | ||||
| throw new Exception(pht('usage: commit-hook <repository>')); | throw new Exception(pht('usage: commit-hook <repository>')); | ||||
| } | } | ||||
| $engine = new DiffusionCommitHookEngine(); | $engine = id(new DiffusionCommitHookEngine()) | ||||
| ->setStartTime($hook_start); | |||||
| $repository = id(new PhabricatorRepositoryQuery()) | $repository = id(new PhabricatorRepositoryQuery()) | ||||
| ->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
| ->withIdentifiers(array($argv[1])) | ->withIdentifiers(array($argv[1])) | ||||
| ->needProjectPHIDs(true) | ->needProjectPHIDs(true) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$repository) { | if (!$repository) { | ||||
| ▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines | |||||