Changeset View
Changeset View
Standalone View
Standalone View
scripts/repository/commit_hook.php
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | $console->writeErr( | ||||
"attempting to edit \"%s\").\n". | "attempting to edit \"%s\").\n". | ||||
"Edit the repository configuration before making dangerous changes.", | "Edit the repository configuration before making dangerous changes.", | ||||
$revprop_key)); | $revprop_key)); | ||||
} | } | ||||
exit($err); | exit($err); | ||||
} else if ($repository->isGit() || $repository->isHg()) { | } else if ($repository->isGit() || $repository->isHg()) { | ||||
$username = getenv(DiffusionCommitHookEngine::ENV_USER); | $username = getenv(DiffusionCommitHookEngine::ENV_USER); | ||||
if (!strlen($username)) { | if (!phutil_nonempty_string($username)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'No Direct Pushes: You are pushing directly to a hosted repository. '. | 'No Direct Pushes: You are pushing directly to a hosted repository. '. | ||||
'This will not work. See "No Direct Pushes" in the documentation '. | 'This will not work. See "No Direct Pushes" in the documentation '. | ||||
'for more information.')); | 'for more information.')); | ||||
} | } | ||||
if ($repository->isHg()) { | if ($repository->isHg()) { | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if ($stdin === false) { | ||||
throw new Exception(pht('Failed to read stdin!')); | throw new Exception(pht('Failed to read stdin!')); | ||||
} | } | ||||
} | } | ||||
$engine->setStdin($stdin); | $engine->setStdin($stdin); | ||||
$engine->setOriginalArgv(array_slice($argv, 2)); | $engine->setOriginalArgv(array_slice($argv, 2)); | ||||
$remote_address = getenv(DiffusionCommitHookEngine::ENV_REMOTE_ADDRESS); | $remote_address = getenv(DiffusionCommitHookEngine::ENV_REMOTE_ADDRESS); | ||||
if (strlen($remote_address)) { | if (phutil_nonempty_string($remote_address)) { | ||||
$engine->setRemoteAddress($remote_address); | $engine->setRemoteAddress($remote_address); | ||||
} | } | ||||
$remote_protocol = getenv(DiffusionCommitHookEngine::ENV_REMOTE_PROTOCOL); | $remote_protocol = getenv(DiffusionCommitHookEngine::ENV_REMOTE_PROTOCOL); | ||||
if (strlen($remote_protocol)) { | if (phutil_nonempty_string($remote_protocol)) { | ||||
$engine->setRemoteProtocol($remote_protocol); | $engine->setRemoteProtocol($remote_protocol); | ||||
} | } | ||||
$request_identifier = getenv(DiffusionCommitHookEngine::ENV_REQUEST); | $request_identifier = getenv(DiffusionCommitHookEngine::ENV_REQUEST); | ||||
if (strlen($request_identifier)) { | if (phutil_nonempty_string($request_identifier)) { | ||||
$engine->setRequestIdentifier($request_identifier); | $engine->setRequestIdentifier($request_identifier); | ||||
} | } | ||||
try { | try { | ||||
$err = $engine->execute(); | $err = $engine->execute(); | ||||
} catch (DiffusionCommitHookRejectException $ex) { | } catch (DiffusionCommitHookRejectException $ex) { | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
Show All 35 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0