mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Add a --repair flag to "bin/repository discover"
Summary: If a repository is missing commits because they mysteriously vanished, there's no reasonable way to get them back right now. Provide a way to ignore the state in the database and rediscover the entire repository unconditionally. We don't queue any reparses or anything, but when I move reparse into this script we can hook things up or something. This generally shouldn't be too important anyway. Test Plan: Ran `repository discover --repair` on Phabricator. Reviewers: jungejason, nh, vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D2850
This commit is contained in:
parent
13d96e6377
commit
ca31e3e84b
2 changed files with 26 additions and 1 deletions
|
@ -46,6 +46,12 @@ final class PhabricatorRepositoryPullLocalDaemon
|
|||
extends PhabricatorDaemon {
|
||||
|
||||
private $commitCache = array();
|
||||
private $repair;
|
||||
|
||||
public function setRepair($repair) {
|
||||
$this->repair = $repair;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/* -( Pulling Repositories )----------------------------------------------- */
|
||||
|
@ -238,6 +244,13 @@ final class PhabricatorRepositoryPullLocalDaemon
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($this->repair) {
|
||||
// In repair mode, rediscover the entire repository, ignoring the
|
||||
// database state. We can hit the local cache above, but if we miss it
|
||||
// stop the script from going to the database cache.
|
||||
return false;
|
||||
}
|
||||
|
||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
|
||||
'repositoryID = %s AND commitIdentifier = %s',
|
||||
$repository->getID(),
|
||||
|
@ -316,6 +329,12 @@ final class PhabricatorRepositoryPullLocalDaemon
|
|||
$commit->getID(),
|
||||
$epoch);
|
||||
|
||||
if ($this->repair) {
|
||||
// Normally, the query should throw a duplicate key exception. If we
|
||||
// reach this in repair mode, we've actually performed a repair.
|
||||
$this->log("Repaired commit '%s'.", $commit_identifier);
|
||||
}
|
||||
|
||||
$this->setCache($repository, $commit_identifier);
|
||||
} catch (AphrontQueryDuplicateKeyException $ex) {
|
||||
// Ignore. This can happen because we discover the same new commit
|
||||
|
|
|
@ -22,7 +22,7 @@ final class PhabricatorRepositoryManagementDiscoverWorkflow
|
|||
public function didConstruct() {
|
||||
$this
|
||||
->setName('discover')
|
||||
->setExamples('**discover** __repository__ ...')
|
||||
->setExamples('**discover** [__options__] __repository__ ...')
|
||||
->setSynopsis('Discover __repository__, named by callsign or PHID.')
|
||||
->setArguments(
|
||||
array(
|
||||
|
@ -30,6 +30,11 @@ final class PhabricatorRepositoryManagementDiscoverWorkflow
|
|||
'name' => 'verbose',
|
||||
'help' => 'Show additional debugging information.',
|
||||
),
|
||||
array(
|
||||
'name' => 'repair',
|
||||
'help' => 'Repair a repository with gaps in commit '.
|
||||
'history.',
|
||||
),
|
||||
array(
|
||||
'name' => 'repos',
|
||||
'wildcard' => true,
|
||||
|
@ -52,6 +57,7 @@ final class PhabricatorRepositoryManagementDiscoverWorkflow
|
|||
|
||||
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
|
||||
$daemon->setVerbose($args->getArg('verbose'));
|
||||
$daemon->setRepair($args->getArg('repair'));
|
||||
$daemon->discoverRepository($repo);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue