mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Make re-running rebuild-identities
a bit faster and add a little progress information
Summary: Ref T13151. Ref T12164. Two small tweaks: - If we aren't actually going to change anything, just skip the writes. This makes re-running/resuming a lot faster (~20x, locally). - Print when we touch a commit so there's some kind of visible status. This is just a small quality-of-life tweak that I wrote anyway while investigating T13152, and will make finishing off db024, db025 and db010 manually a little easier. Test Plan: - Set `authorIdentityPHID` + `committerIdentityPHID` to `NULL`. - Ran `rebuild-identities`, saw status information. - Ran `rebuild-identiites` again, saw it go faster with status information. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13151, T12164 Differential Revision: https://secure.phabricator.com/D19484
This commit is contained in:
parent
6011085b0f
commit
1459fb3037
1 changed files with 39 additions and 15 deletions
|
@ -44,27 +44,51 @@ final class PhabricatorRepositoryManagementRebuildIdentitiesWorkflow
|
||||||
|
|
||||||
$iterator = new PhabricatorQueryIterator($query);
|
$iterator = new PhabricatorQueryIterator($query);
|
||||||
foreach ($iterator as $commit) {
|
foreach ($iterator as $commit) {
|
||||||
|
$needs_update = false;
|
||||||
|
|
||||||
$data = $commit->getCommitData();
|
$data = $commit->getCommitData();
|
||||||
$author_name = $data->getAuthorName();
|
$author_name = $data->getAuthorName();
|
||||||
|
|
||||||
$author_identity = $this->getIdentityForCommit(
|
$author_identity = $this->getIdentityForCommit(
|
||||||
$commit, $author_name);
|
$commit,
|
||||||
|
$author_name);
|
||||||
|
|
||||||
$commit->setAuthorIdentityPHID($author_identity->getPHID());
|
$author_phid = $commit->getAuthorIdentityPHID();
|
||||||
$data->setCommitDetail(
|
$identity_phid = $author_identity->getPHID();
|
||||||
'authorIdentityPHID', $author_identity->getPHID());
|
if ($author_phid !== $identity_phid) {
|
||||||
|
$commit->setAuthorIdentityPHID($identity_phid);
|
||||||
$committer_name = $data->getCommitDetail('committer', null);
|
$data->setCommitDetail('authorIdentityPHID', $identity_phid);
|
||||||
if ($committer_name) {
|
$needs_update = true;
|
||||||
$committer_identity = $this->getIdentityForCommit(
|
|
||||||
$commit, $committer_name);
|
|
||||||
|
|
||||||
$commit->setCommitterIdentityPHID($committer_identity->getPHID());
|
|
||||||
$data->setCommitDetail(
|
|
||||||
'committerIdentityPHID', $committer_identity->getPHID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$commit->save();
|
$committer_name = $data->getCommitDetail('committer', null);
|
||||||
$data->save();
|
$committer_phid = $commit->getCommitterIdentityPHID();
|
||||||
|
if (strlen($committer_name)) {
|
||||||
|
$committer_identity = $this->getIdentityForCommit(
|
||||||
|
$commit,
|
||||||
|
$committer_name);
|
||||||
|
$identity_phid = $committer_identity->getPHID();
|
||||||
|
} else {
|
||||||
|
$identity_phid = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($committer_phid !== $identity_phid) {
|
||||||
|
$commit->setCommitterIdentityPHID($identity_phid);
|
||||||
|
$data->setCommitDetail('committerIdentityPHID', $identity_phid);
|
||||||
|
$needs_update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($needs_update) {
|
||||||
|
$commit->save();
|
||||||
|
$data->save();
|
||||||
|
echo tsprintf(
|
||||||
|
"Rebuilt identities for %s.\n",
|
||||||
|
$commit->getDisplayName());
|
||||||
|
} else {
|
||||||
|
echo tsprintf(
|
||||||
|
"No changes for %s.\n",
|
||||||
|
$commit->getDisplayName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue