mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
618b5cbbc4
Summary: Ref T4189. T4189 describes most of the intent here: - When updating hosted repositories, sync a pre-commit hook into them instead of doing a `git fetch`. - The hook calls into Phabricator. The acting Phabricator user is sent via PHABRICATOR_USER in the environment. The active repository is sent via CLI. - The hook doesn't do anything useful yet; it just veifies basic parameters, does a little parsing, and exits 0 to allow the commit. Test Plan: - Performed Git pushes and pulls over SSH and HTTP. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4189 Differential Revision: https://secure.phabricator.com/D7682
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class DiffusionSSHGitReceivePackWorkflow
|
|
extends DiffusionSSHGitWorkflow {
|
|
|
|
public function didConstruct() {
|
|
$this->setName('git-receive-pack');
|
|
$this->setArguments(
|
|
array(
|
|
array(
|
|
'name' => 'dir',
|
|
'wildcard' => true,
|
|
),
|
|
));
|
|
}
|
|
|
|
protected function executeRepositoryOperations() {
|
|
$args = $this->getArgs();
|
|
$path = head($args->getArg('dir'));
|
|
$repository = $this->loadRepository($path);
|
|
|
|
// This is a write, and must have write access.
|
|
$this->requireWriteAccess();
|
|
|
|
$command = csprintf('git-receive-pack %s', $repository->getLocalPath());
|
|
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command);
|
|
|
|
$future = id(new ExecFuture('%C', $command))
|
|
->setEnv($this->getEnvironment());
|
|
|
|
$err = $this->newPassthruCommand()
|
|
->setIOChannel($this->getIOChannel())
|
|
->setCommandChannelFromExecFuture($future)
|
|
->execute();
|
|
|
|
if (!$err) {
|
|
$repository->writeStatusMessage(
|
|
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE,
|
|
PhabricatorRepositoryStatusMessage::CODE_OKAY);
|
|
$this->waitForGitClient();
|
|
}
|
|
|
|
return $err;
|
|
}
|
|
|
|
}
|