1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-09 16:32:39 +01:00

In "arc diff", warn when some reviewers are away even if not everyone is away

Summary:
Ref T13249. See PHI810. We currently warn you when //all// reviewers are away, but not when only some reviewers are away.

This makes some amount of sense under the "anyone can accept anything" rules we sort of recommend, but a lot of installs realistically have tons of owner/package rules now.

Instead, if any reviewers are away, show the user exactly who is away and until when, then make sure they don't want to make any adjustments.

(We can do a better job of this after the toolsets change when we can use the new APIs, but this is an easy fix for now.)

Test Plan: Created a revision with multiple reviewers, either some or all of whom were away. Got appropriate output and prompt behavior.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13249

Differential Revision: https://secure.phabricator.com/D20172
This commit is contained in:
epriestley 2019-02-14 10:14:40 -08:00
parent 7e61e43f65
commit 07a208d8fc

View file

@ -1820,17 +1820,56 @@ EOTEXT
$this->checkRevisionOwnership(head($result));
break;
case 'reviewers':
$untils = array();
$away = array();
foreach ($result as $user) {
if (idx($user, 'currentStatus') == 'away') {
$untils[] = $user['currentStatusUntil'];
if (idx($user, 'currentStatus') != 'away') {
continue;
}
$username = $user['userName'];
$real_name = $user['realName'];
if (strlen($real_name)) {
$name = pht('%s (%s)', $username, $real_name);
} else {
$name = pht('%s', $username);
}
$away[] = array(
'name' => $name,
'until' => $user['currentStatusUntil'],
);
}
if (count($untils) == count($reviewers)) {
$until = date('l, M j Y', min($untils));
$confirm = pht(
'All reviewers are away until %s. Continue anyway?',
$until);
if ($away) {
if (count($away) == count($reviewers)) {
$earliest_return = min(ipull($away, 'until'));
$message = pht(
'All reviewers are away until %s:',
date('l, M j Y', $earliest_return));
} else {
$message = pht('Some reviewers are currently away:');
}
echo tsprintf(
"%s\n\n",
$message);
$list = id(new PhutilConsoleList());
foreach ($away as $spec) {
$list->addItem(
pht(
'%s (until %s)',
$spec['name'],
date('l, M j Y', $spec['until'])));
}
echo tsprintf(
'%B',
$list->drawConsoleString());
$confirm = pht('Continue even though reviewers are unavailable?');
if (!phutil_console_confirm($confirm)) {
throw new ArcanistUsageException(
pht('Specify available reviewers and retry.'));