Differential D18920 Diff 45391 src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if ($repository->isGit()) { | ||||
throw new Exception(pht('Unsupported VCS!')); | throw new Exception(pht('Unsupported VCS!')); | ||||
} | } | ||||
} | } | ||||
private function pushToGitRepository( | private function pushToGitRepository( | ||||
PhabricatorRepository $repository, | PhabricatorRepository $repository, | ||||
PhabricatorRepositoryURI $mirror_uri) { | PhabricatorRepositoryURI $mirror_uri) { | ||||
// See T5965. Test if we have any refs to mirror. If we have nothing, git | |||||
// will exit with an error ("No refs in common and none specified; ...") | |||||
// when we run "git push --mirror". | |||||
// If we don't have any refs, we just bail out. (This is arguably sort of | |||||
// the wrong behavior: to mirror an empty repository faithfully we should | |||||
// delete everything in the remote.) | |||||
list($stdout) = $repository->execxLocalCommand( | |||||
'for-each-ref --count 1 --'); | |||||
if (!strlen($stdout)) { | |||||
return; | |||||
} | |||||
$argv = array( | $argv = array( | ||||
'push --verbose --mirror -- %P', | 'push --verbose --mirror -- %P', | ||||
$mirror_uri->getURIEnvelope(), | $mirror_uri->getURIEnvelope(), | ||||
); | ); | ||||
$future = $mirror_uri->newCommandEngine() | $future = $mirror_uri->newCommandEngine() | ||||
->setArgv($argv) | ->setArgv($argv) | ||||
->newFuture(); | ->newFuture(); | ||||
Show All 33 Lines |