Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionServeController.php
Show First 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | private function serveGitRequest( | ||||
$input = PhabricatorStartup::getRawInput(); | $input = PhabricatorStartup::getRawInput(); | ||||
$command = csprintf('%s', $bin); | $command = csprintf('%s', $bin); | ||||
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | ||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||
$cluster_engine = id(new DiffusionRepositoryClusterEngine()) | |||||
->setViewer($viewer) | |||||
->setRepository($repository); | |||||
$did_write_lock = false; | $did_write_lock = false; | ||||
if ($this->isReadOnlyRequest($repository)) { | if ($this->isReadOnlyRequest($repository)) { | ||||
$repository->synchronizeWorkingCopyBeforeRead(); | $cluster_engine->synchronizeWorkingCopyBeforeRead(); | ||||
} else { | } else { | ||||
$did_write_lock = true; | $did_write_lock = true; | ||||
$repository->synchronizeWorkingCopyBeforeWrite($viewer); | $cluster_engine->synchronizeWorkingCopyBeforeWrite(); | ||||
} | } | ||||
$caught = null; | $caught = null; | ||||
try { | try { | ||||
list($err, $stdout, $stderr) = id(new ExecFuture('%C', $command)) | list($err, $stdout, $stderr) = id(new ExecFuture('%C', $command)) | ||||
->setEnv($env, true) | ->setEnv($env, true) | ||||
->write($input) | ->write($input) | ||||
->resolve(); | ->resolve(); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$caught = $ex; | $caught = $ex; | ||||
} | } | ||||
if ($did_write_lock) { | if ($did_write_lock) { | ||||
$repository->synchronizeWorkingCopyAfterWrite(); | $cluster_engine->synchronizeWorkingCopyAfterWrite(); | ||||
} | } | ||||
unset($unguarded); | unset($unguarded); | ||||
if ($caught) { | if ($caught) { | ||||
throw $caught; | throw $caught; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 646 Lines • Show Last 20 Lines |