Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896150
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/workflow/ArcanistListWorkflow.php b/src/workflow/ArcanistListWorkflow.php
index 5a74b959..e443e700 100644
--- a/src/workflow/ArcanistListWorkflow.php
+++ b/src/workflow/ArcanistListWorkflow.php
@@ -1,93 +1,107 @@
<?php
/**
* Lists open revisions in Differential.
*
* @group workflow
*/
final class ArcanistListWorkflow extends ArcanistBaseWorkflow {
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 "You have no open Differential revisions.\n";
return 0;
}
$repository_api = $this->getRepositoryAPI();
$info = array();
-
- $status_len = 0;
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]['here'] = 1;
+ $info[$key]['exists'] = 1;
} else {
- $info[$key]['here'] = 0;
+ $info[$key]['exists'] = 0;
}
$info[$key]['sort'] = sprintf(
'%d%04d%08d',
- $info[$key]['here'],
+ $info[$key]['exists'],
$revision['status'],
$revision['id']);
$info[$key]['statusName'] = $revision['statusName'];
- $status_len = max(
- $status_len,
- strlen($info[$key]['statusName']));
+ $info[$key]['color'] = idx(
+ $color_map, $revision['statusName'], 'default');
}
+ $table = id(new PhutilConsoleTable())
+ ->setShowHeader(false)
+ ->addColumn('exists', array('title' => ''))
+ ->addColumn('status', array('title' => 'Status'))
+ ->addColumn('title', array('title' => 'Title'));
+
$info = isort($info, 'sort');
foreach ($info as $key => $spec) {
$revision = $revisions[$key];
- printf(
- "%s %-".($status_len + 4)."s D%d: %s\n",
- $spec['here']
- ? phutil_console_format('**%s**', '*')
- : ' ',
- $spec['statusName'],
- $revision['id'],
- $revision['title']);
+
+ $table->addRow(array(
+ 'exists' => $spec['exists'] ? phutil_console_format('**%s**', '*') : '',
+ 'status' => phutil_console_format(
+ "<fg:{$spec['color']}>%s</fg>", $spec['statusName']),
+ 'title' => phutil_console_format(
+ '**D%d:** %s', $revision['id'], $revision['title']),
+ ));
}
+ $table->draw();
return 0;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 22:38 (6 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129475
Default Alt Text
(3 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment