@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

If repository mirroring fails, keep trying the other mirrors

Summary: Ref T4338. Currently, if you have several mirrors and the first one fails, we won't try the other mirrors (since we'll throw and that will take us out of the mirroring process). Instead, try each mirror even if one fails, and then throw an AggregateException with all the failures.

Test Plan:
- Ran `bin/repository mirror` normally.
- Faked an exception, ran again, got the AggregateException I expected.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4338

Differential Revision: https://secure.phabricator.com/D8067

+34 -14
+34 -14
src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
··· 18 18 ->withRepositoryPHIDs(array($repository->getPHID())) 19 19 ->execute(); 20 20 21 + $exceptions = array(); 22 + foreach ($mirrors as $mirror) { 23 + try { 24 + $this->pushRepositoryToMirror($repository, $mirror); 25 + } catch (Exception $ex) { 26 + $exceptions[] = $ex; 27 + } 28 + } 29 + 30 + if ($exceptions) { 31 + throw new PhutilAggregateException( 32 + pht( 33 + 'Exceptions occurred while mirroring the "%s" repository.', 34 + $repository->getCallsign()), 35 + $exceptions); 36 + } 37 + } 38 + 39 + private function pushRepositoryToMirror( 40 + PhabricatorRepository $repository, 41 + PhabricatorRepositoryMirror $mirror) { 42 + 21 43 // TODO: This is a little bit janky, but we don't have first-class 22 44 // infrastructure for running remote commands against an arbitrary remote 23 45 // right now. Just make an emphemeral copy of the repository and muck with ··· 28 50 $proxy->makeEphemeral(); 29 51 30 52 $proxy->setDetail('hosting-enabled', false); 31 - foreach ($mirrors as $mirror) { 32 - $proxy->setDetail('remote-uri', $mirror->getRemoteURI()); 33 - $proxy->setCredentialPHID($mirror->getCredentialPHID()); 53 + $proxy->setDetail('remote-uri', $mirror->getRemoteURI()); 54 + $proxy->setCredentialPHID($mirror->getCredentialPHID()); 34 55 35 - $this->log(pht('Pushing to remote "%s"...', $mirror->getRemoteURI())); 56 + $this->log(pht('Pushing to remote "%s"...', $mirror->getRemoteURI())); 36 57 37 - if (!$proxy->isGit()) { 38 - throw new Exception('Unsupported VCS!'); 39 - } 58 + if (!$proxy->isGit()) { 59 + throw new Exception(pht('Unsupported VCS!')); 60 + } 40 61 41 - $future = $proxy->getRemoteCommandFuture( 42 - 'push --verbose --mirror -- %P', 43 - $proxy->getRemoteURIEnvelope()); 62 + $future = $proxy->getRemoteCommandFuture( 63 + 'push --verbose --mirror -- %P', 64 + $proxy->getRemoteURIEnvelope()); 44 65 45 - $future 46 - ->setCWD($proxy->getLocalPath()) 47 - ->resolvex(); 48 - } 66 + $future 67 + ->setCWD($proxy->getLocalPath()) 68 + ->resolvex(); 49 69 } 50 70 51 71 }