mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-08 16:02:39 +01:00
9c056c5cc8
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
109 lines
2.7 KiB
PHP
109 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Lists open revisions in Differential.
|
|
*/
|
|
final class ArcanistListWorkflow extends ArcanistWorkflow {
|
|
|
|
public function getWorkflowName() {
|
|
return 'list';
|
|
}
|
|
|
|
public function getCommandSynopses() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
**list**
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function getCommandHelp() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
Supports: git, svn, hg
|
|
List your open Differential revisions.
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function requiresConduit() {
|
|
return true;
|
|
}
|
|
|
|
public function requiresRepositoryAPI() {
|
|
return true;
|
|
}
|
|
|
|
public function requiresAuthentication() {
|
|
return true;
|
|
}
|
|
|
|
public function run() {
|
|
static $color_map = array(
|
|
'Closed' => 'cyan',
|
|
'Needs Review' => 'magenta',
|
|
'Needs Revision' => 'red',
|
|
'Changes Planned' => 'red',
|
|
'Accepted' => 'green',
|
|
'No Revision' => 'blue',
|
|
'Abandoned' => 'default',
|
|
);
|
|
|
|
$revisions = $this->getConduit()->callMethodSynchronous(
|
|
'differential.query',
|
|
array(
|
|
'authors' => array($this->getUserPHID()),
|
|
'status' => 'status-open',
|
|
));
|
|
|
|
if (!$revisions) {
|
|
echo pht('You have no open Differential revisions.')."\n";
|
|
return 0;
|
|
}
|
|
|
|
$repository_api = $this->getRepositoryAPI();
|
|
|
|
$info = array();
|
|
foreach ($revisions as $key => $revision) {
|
|
$revision_path = Filesystem::resolvePath($revision['sourcePath']);
|
|
$current_path = Filesystem::resolvePath($repository_api->getPath());
|
|
if ($revision_path == $current_path) {
|
|
$info[$key]['exists'] = 1;
|
|
} else {
|
|
$info[$key]['exists'] = 0;
|
|
}
|
|
$info[$key]['sort'] = sprintf(
|
|
'%d%04d%08d',
|
|
$info[$key]['exists'],
|
|
$revision['status'],
|
|
$revision['id']);
|
|
$info[$key]['statusName'] = $revision['statusName'];
|
|
$info[$key]['color'] = idx(
|
|
$color_map, $revision['statusName'], 'default');
|
|
}
|
|
|
|
$table = id(new PhutilConsoleTable())
|
|
->setShowHeader(false)
|
|
->addColumn('exists', array('title' => ''))
|
|
->addColumn('status', array('title' => pht('Status')))
|
|
->addColumn('title', array('title' => pht('Title')));
|
|
|
|
$info = isort($info, 'sort');
|
|
foreach ($info as $key => $spec) {
|
|
$revision = $revisions[$key];
|
|
|
|
$table->addRow(array(
|
|
'exists' => $spec['exists'] ? tsprintf('**%s**', '*') : '',
|
|
'status' => tsprintf(
|
|
"<fg:{$spec['color']}>%s</fg>",
|
|
$spec['statusName']),
|
|
'title' => tsprintf(
|
|
'**D%d:** %s',
|
|
$revision['id'],
|
|
$revision['title']),
|
|
));
|
|
}
|
|
|
|
$table->draw();
|
|
return 0;
|
|
}
|
|
|
|
}
|