Store pusher remote address and push protocol in PushLog

Summary: Ref T4195. Stores remote address and protocol in the logs, where possible.

Test Plan: Pushed some stuff, looked at the log, saw data.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4195

Differential Revision: https://secure.phabricator.com/D7711
This commit is contained in:
epriestley
2013-12-05 11:59:22 -08:00
parent caa6fdf56d
commit e28b848ab2
5 changed files with 80 additions and 13 deletions

View File

@@ -30,9 +30,10 @@ $engine->setRepository($repository);
// Figure out which user is writing the commit.
if ($repository->isGit() || $repository->isHg()) {
$username = getenv('PHABRICATOR_USER');
$username = getenv(DiffusionCommitHookEngine::ENV_USER);
if (!strlen($username)) {
throw new Exception(pht('usage: PHABRICATOR_USER should be defined!'));
throw new Exception(
pht('usage: %s should be defined!', DiffusionCommitHookEngine::ENV_USER));
}
// TODO: If this is a Mercurial repository, the hook we're responding to
@@ -41,8 +42,8 @@ if ($repository->isGit() || $repository->isHg()) {
} else if ($repository->isSVN()) {
// NOTE: In Subversion, the entire environment gets wiped so we can't read
// PHABRICATOR_USER. Instead, we've set "--tunnel-user" to specify the
// correct user; read this user out of the commit log.
// DiffusionCommitHookEngine::ENV_USER. Instead, we've set "--tunnel-user" to
// 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>'));
@@ -86,6 +87,16 @@ if ($repository->isHg()) {
$engine->setStdin($stdin);
$remote_address = getenv(DiffusionCommitHookEngine::ENV_REMOTE_ADDRESS);
if (strlen($remote_address)) {
$engine->setRemoteAddress($remote_address);
}
$remote_protocol = getenv(DiffusionCommitHookEngine::ENV_REMOTE_PROTOCOL);
if (strlen($remote_protocol)) {
$engine->setRemoteProtocol($remote_protocol);
}
try {
$err = $engine->execute();
} catch (DiffusionCommitHookRejectException $ex) {