1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-25 14:08:18 +01:00
phorge-arcanist/src/workflow/ArcanistListWorkflow.php

94 lines
2.1 KiB
PHP
Raw Normal View History

2011-01-09 15:22:25 -08:00
<?php
/**
* Lists open revisions in Differential.
*
* @group workflow
*/
final class ArcanistListWorkflow extends ArcanistBaseWorkflow {
2011-01-09 15:22:25 -08:00
public function getWorkflowName() {
return 'list';
}
public function getCommandSynopses() {
2011-01-09 15:22:25 -08:00
return phutil_console_format(<<<EOTEXT
**list**
EOTEXT
);
}
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
Supports: git, svn, hg
2011-01-09 15:22:25 -08:00
List your open Differential revisions.
EOTEXT
);
}
public function requiresConduit() {
return true;
}
public function requiresRepositoryAPI() {
return true;
}
public function requiresAuthentication() {
return true;
}
public function run() {
$revisions = $this->getConduit()->callMethodSynchronous(
'differential.query',
2011-01-09 15:22:25 -08:00
array(
'authors' => array($this->getUserPHID()),
'status' => 'status-open',
2011-01-09 15:22:25 -08:00
));
if (!$revisions) {
echo "You have no open Differential revisions.\n";
return 0;
}
$repository_api = $this->getRepositoryAPI();
$info = array();
2011-01-09 15:22:25 -08:00
$status_len = 0;
foreach ($revisions as $key => $revision) {
$revision_path = Filesystem::resolvePath($revision['sourcePath']);
2011-01-09 15:22:25 -08:00
$current_path = Filesystem::resolvePath($repository_api->getPath());
if ($revision_path == $current_path) {
$info[$key]['here'] = 1;
} else {
$info[$key]['here'] = 0;
}
$info[$key]['sort'] = sprintf(
'%d%04d%08d',
$info[$key]['here'],
$revision['status'],
$revision['id']);
$info[$key]['statusName'] = $revision['statusName'];
$status_len = max(
$status_len,
strlen($info[$key]['statusName']));
}
2011-01-09 15:22:25 -08:00
$info = isort($info, 'sort');
foreach ($info as $key => $spec) {
$revision = $revisions[$key];
2011-01-09 15:22:25 -08:00
printf(
"%s %-".($status_len + 4)."s D%d: %s\n",
$spec['here']
? phutil_console_format('**%s**', '*')
: ' ',
$spec['statusName'],
$revision['id'],
$revision['title']);
2011-01-09 15:22:25 -08:00
}
return 0;
}
}