mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-09 06:11:01 +01:00
66d204be81
Summary: This commit doesn't change license of any file. It just makes the license implicit (inherited from LICENSE file in the root directory). We are removing the headers for these reasons: - It wastes space in editors, less code is visible in editor upon opening a file. - It brings noise to diff of the first change of any file every year. - It confuses Git file copy detection when creating small files. - We don't have an explicit license header in other files (JS, CSS, images, documentation). - Using license header in every file is not obligatory: http://www.apache.org/dev/apply-license.html#new. This change is approved by Alma Chao (Lead Open Source and IP Counsel at Facebook). Test Plan: Verified that the license survived only in unit tests and LICENSE file. Reviewers: epriestley, btrahan, edward Reviewed By: epriestley CC: aran, Korvin, davidrecordon Maniphest Tasks: T2035 Differential Revision: https://secure.phabricator.com/D3881
127 lines
2.9 KiB
PHP
127 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Close a task
|
|
*
|
|
* @group workflow
|
|
*/
|
|
final class ArcanistCloseWorkflow extends ArcanistBaseWorkflow {
|
|
|
|
private $tasks;
|
|
private $statusOptions = array(
|
|
"resolved" => 1,
|
|
"wontfix" => 2,
|
|
"invalid" => 3,
|
|
"duplicate" => 4,
|
|
"spite" => 5,
|
|
"open" => 0
|
|
);
|
|
|
|
|
|
public function getWorkflowName() {
|
|
return 'close';
|
|
}
|
|
|
|
public function getCommandSynopses() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
**close** __task_id__ [__options__]
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function getCommandHelp() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
Close a task.
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function requiresConduit() {
|
|
return true;
|
|
}
|
|
|
|
public function requiresRepositoryAPI() {
|
|
return false;
|
|
}
|
|
|
|
public function requiresAuthentication() {
|
|
return true;
|
|
}
|
|
|
|
|
|
public function getArguments() {
|
|
$options = array_keys($this->statusOptions);
|
|
$last = array_pop($options);
|
|
return array(
|
|
'*' => 'task_id',
|
|
'message' => array(
|
|
'short' => 'm',
|
|
'param' => 'comment',
|
|
'help' => "Provide a comment with your status change.",
|
|
),
|
|
'status' => array(
|
|
'param' => 'status',
|
|
'short' => 's',
|
|
'help' => "New status. Valid options are ".
|
|
implode(', ', $options).", or {$last}. Default is resolved.\n"
|
|
),
|
|
);
|
|
}
|
|
|
|
public function run() {
|
|
$ids = $this->getArgument('task_id');
|
|
$message = $this->getArgument('message');
|
|
$status = strtolower($this->getArgument('status'));
|
|
|
|
if (!isset($status) || $status == '') {
|
|
$status = head_key($this->statusOptions);
|
|
}
|
|
|
|
if (isset($this->statusOptions[$status])) {
|
|
$status = $this->statusOptions[$status];
|
|
} else {
|
|
$options = array_keys($this->statusOptions);
|
|
$last = array_pop($options);
|
|
echo "Invalid status {$status}, valid options are ".
|
|
implode(', ', $options).", or {$last}.\n";
|
|
return;
|
|
}
|
|
|
|
foreach ($ids as $id) {
|
|
if (!preg_match("/^T?\d+$/", $id)) {
|
|
echo "Invalid Task ID: {$id}.\n";
|
|
return 1;
|
|
}
|
|
$id = ltrim($id, 'T');
|
|
$result = $this->closeTask($id, $status, $message);
|
|
$status_options = array_flip($this->statusOptions);
|
|
$current_status = $status_options[$status];
|
|
if ($result) {
|
|
echo "T{$id}'s status is now set to {$current_status}.\n";
|
|
} else {
|
|
echo "T{$id} is already set to {$current_status}.\n";
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
private function closeTask($task_id, $status = 1, $comment = "") {
|
|
$conduit = $this->getConduit();
|
|
$info = $conduit->callMethodSynchronous(
|
|
'maniphest.info',
|
|
array(
|
|
'task_id' => $task_id
|
|
));
|
|
if ($info['status'] == $status) {
|
|
return false;
|
|
}
|
|
return $conduit->callMethodSynchronous(
|
|
'maniphest.update',
|
|
array(
|
|
'id' => $task_id,
|
|
'status' => $status,
|
|
'comments' => $comment
|
|
));
|
|
}
|
|
|
|
}
|