1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Add migration to encourage rebuilding repository identities

Summary: Ref T12164. Defines a new manual activity that suggests rebuilding repository identities before Phabricator begins to rely on them.

Test Plan:
- Ran migration, observed expected setup issue: {F5788217}
- Ran `bin/config done identities` and observed setup issue get marked as done.
- Ran `/bin/storage upgrade --apply phabricator:20170912.ferret.01.activity.php` to make sure I didn't break the reindex migration; observed reindex setup issue appear as expected.
- Ran `./bin/config done reindex` and observed reindex issue cleared as expected.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T12164

Differential Revision: https://secure.phabricator.com/D19497
This commit is contained in:
Austin McKinley 2018-08-09 12:24:36 -07:00
parent 2951694c27
commit a6951a0a5a
3 changed files with 146 additions and 53 deletions

View file

@ -0,0 +1,20 @@
<?php
// Advise installs to rebuild the repository identities.
// If the install has no commits (or no commits that lack an
// authorIdentityPHID), don't require a rebuild.
$commits = id(new PhabricatorRepositoryCommit())
->loadAllWhere('authorIdentityPHID IS NULL LIMIT 1');
if (!$commits) {
return;
}
try {
id(new PhabricatorConfigManualActivity())
->setActivityType(PhabricatorConfigManualActivity::TYPE_IDENTITIES)
->save();
} catch (AphrontDuplicateKeyQueryException $ex) {
// If we've already noted that this activity is required, just move on.
}

View file

@ -13,10 +13,21 @@ final class PhabricatorManualActivitySetupCheck
foreach ($activities as $activity) {
$type = $activity->getActivityType();
// For now, there is only one type of manual activity. It's not clear
// if we're really going to have too much more of this stuff so this
// is a bit under-designed for now.
switch ($type) {
case PhabricatorConfigManualActivity::TYPE_REINDEX:
$this->raiseSearchReindexIssue();
break;
case PhabricatorConfigManualActivity::TYPE_IDENTITIES:
$this->raiseRebuildIdentitiesIssue();
break;
default:
}
}
}
private function raiseSearchReindexIssue() {
$activity_name = pht('Rebuild Search Index');
$activity_summary = pht(
'The search index algorithm has been updated and the index needs '.
@ -60,16 +71,76 @@ final class PhabricatorManualActivitySetupCheck
$message[] = phutil_tag(
'pre',
array(),
(string)csprintf('phabricator/ $ ./bin/config done %R', $type));
'phabricator/ $ ./bin/config done reindex');
$activity_message = phutil_implode_html("\n\n", $message);
$this->newIssue('manual.'.$type)
$this->newIssue('manual.reindex')
->setName($activity_name)
->setSummary($activity_summary)
->setMessage($activity_message);
}
private function raiseRebuildIdentitiesIssue() {
$activity_name = pht('Rebuild Repository Identities');
$activity_summary = pht(
'The mapping from VCS users to Phabricator users has changed '.
'and must be rebuilt.');
$message = array();
$message[] = pht(
'The way Phabricator attributes VCS activity to Phabricator users '.
'has changed. There is a new indirection layer between the strings '.
'that appear as VCS authors and committers (such as "John Developer '.
'<johnd@bigcorp.com>") and the Phabricator user that gets associated '.
'with VCS commits. This is to support situations where users '.
'are incorrectly associated with commits by Phabricator making bad '.
'guesses about the identity of the corresponding Phabricator user. '.
'This also helps with situations where existing repositories are '.
'imported without having created accounts for all the committers to '.
'that repository. Until you rebuild these repository identities, you '.
'are likely to encounter problems with future Phabricator features '.
'which will rely on the existence of these identities.');
$message[] = pht(
'You can rebuild repository identities while Phabricator is running.');
$message[] = pht(
'To rebuild identities, run this command:');
$message[] = phutil_tag(
'pre',
array(),
(string)csprintf(
'phabricator/ $ ./bin/repository rebuild-identities --all'));
$message[] = pht(
'You can find more information about this new identity mapping '.
'here: %s',
phutil_tag(
'a',
array(
'href' => 'https://phurl.io/u/repoIdentities',
'target' => '_blank',
),
'https://phurl.io/u/repoIdentities'));
$message[] = pht(
'After rebuilding repository identities, run this command to clear '.
'this setup warning:');
$message[] = phutil_tag(
'pre',
array(),
'phabricator/ $ ./bin/config done identities');
$activity_message = phutil_implode_html("\n\n", $message);
$this->newIssue('manual.identities')
->setName($activity_name)
->setSummary($activity_summary)
->setMessage($activity_message);
}
}
}

View file

@ -7,6 +7,8 @@ final class PhabricatorConfigManualActivity
protected $parameters = array();
const TYPE_REINDEX = 'reindex';
const TYPE_IDENTITIES = 'identities';
protected function getConfiguration() {
return array(