1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-29 18:22:41 +01:00
phorge-arcanist/src/workflow/ArcanistPhrequentWorkflow.php
epriestley 9c056c5cc8 Improve arc's handling of dirty submodules in Git
Summary:
Fixes T9455. Depends on D14136. When you have a dirty submodule:

  $ nano submodule/file.c # save changes

...we currently ask you to make a commit when you run `arc diff`, which is meaningless and misleading.

Instead, prompt the user separately.

This behavior isn't perfect but I think it's about the best we can do within reason.

Test Plan:
  - Ran `arc diff` in a working copy with uncommitted submodule changes only, got new prompt.
  - Ran `arc diff` in a working copy with submodule base commit changes only, got old (correct) prompt.
  - Ran `arc diff` in a working copy with both, got only old prompt (which is incomplete, but reasonable/meaningful).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9455

Differential Revision: https://secure.phabricator.com/D14137
2015-09-21 12:40:06 -07:00

70 lines
1.7 KiB
PHP

<?php
/**
* Base workflow for Phrequent workflows.
*/
abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
protected function printCurrentTracking() {
$conduit = $this->getConduit();
$results = $conduit->callMethodSynchronous(
'phrequent.tracking',
array());
$results = $results['data'];
if (count($results) === 0) {
echo phutil_console_format(
"%s\n",
pht('Not currently tracking time against any object.'));
return 0;
}
$phids_to_lookup = array();
foreach ($results as $result) {
$phids_to_lookup[] = $result['phid'];
}
$phid_query = $conduit->callMethodSynchronous(
'phid.query',
array(
'phids' => $phids_to_lookup,
));
$phid_map = array();
foreach ($phids_to_lookup as $lookup) {
if (array_key_exists($lookup, $phid_query)) {
$phid_map[$lookup] = $phid_query[$lookup]['fullName'];
} else {
$phid_map[$lookup] = pht('Unknown Object');
}
}
$table = id(new PhutilConsoleTable())
->addColumn('type', array('title' => pht('Status')))
->addColumn('time', array('title' => pht('Tracked'), 'align' => 'right'))
->addColumn('name', array('title' => pht('Name')))
->setBorders(false);
$i = 0;
foreach ($results as $result) {
if ($i === 0) {
$column_type = pht('In Progress');
} else {
$column_type = pht('Suspended');
}
$table->addRow(array(
'type' => '('.$column_type.')',
'time' => tsprintf($result['time']),
'name' => $phid_map[$result['phid']],
));
$i++;
}
$table->draw();
return 0;
}
}