Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistFeatureWorkflow.php
Show All 25 Lines | return phutil_console_format(<<<EOTEXT | ||||
Supports: git, hg | Supports: git, hg | ||||
A wrapper on 'git branch' or 'hg bookmark'. | A wrapper on 'git branch' or 'hg bookmark'. | ||||
Without __name__, it lists the available branches and their revision | Without __name__, it lists the available branches and their revision | ||||
status. | status. | ||||
With __name__, it creates or checks out a branch. If the branch | With __name__, it creates or checks out a branch. If the branch | ||||
__name__ doesn't exist and is in format D123 then the branch of | __name__ doesn't exist and is in format D123 then the branch of | ||||
revision D123 is checked out. Use __start__ to specify where the new | revision D123 is checked out. If the format is T123 the corresponding | ||||
task will be assigned to you. Use __start__ to specify where the new | |||||
branch will start. Use 'arc.feature.start.default' to set the default | branch will start. Use 'arc.feature.start.default' to set the default | ||||
feature start location. | feature start location. | ||||
EOTEXT | EOTEXT | ||||
); | ); | ||||
} | } | ||||
public function requiresConduit() { | public function requiresConduit() { | ||||
return true; | return true; | ||||
} | } | ||||
public function requiresRepositoryAPI() { | public function requiresRepositoryAPI() { | ||||
return true; | return true; | ||||
} | } | ||||
public function requiresAuthentication() { | public function requiresAuthentication() { | ||||
return !$this->getArgument('branch'); | // We need authentication if the branch specifies a revision or a task | ||||
$branch = $this->getArgument('branch'); | |||||
if (!isset($branch[0]) || preg_match('/^[DT](\d+)$/', $branch[0])) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | } | ||||
public function getArguments() { | public function getArguments() { | ||||
return array( | return array( | ||||
'view-all' => array( | 'view-all' => array( | ||||
'help' => 'Include closed and abandoned revisions.', | 'help' => 'Include closed and abandoned revisions.', | ||||
), | ), | ||||
'by-status' => array( | 'by-status' => array( | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if ($err) { | ||||
if ($diff['branch'] != '') { | if ($diff['branch'] != '') { | ||||
$name = $diff['branch']; | $name = $diff['branch']; | ||||
list($err, $stdout, $stderr) = $api->execManualLocal( | list($err, $stdout, $stderr) = $api->execManualLocal( | ||||
$command, | $command, | ||||
$name); | $name); | ||||
} | } | ||||
} catch (ConduitClientException $ex) {} | } catch (ConduitClientException $ex) {} | ||||
} else if (preg_match('/^T(\d+)$/', $name, $match)) { | |||||
// The specified branch looks like a task - Try to assign it to me | |||||
try { | |||||
$info = $this->getConduit()->callMethodSynchronous( | |||||
'maniphest.info', | |||||
array( | |||||
'task_id' => $match[1], | |||||
)); | |||||
if ($info['ownerPHID'] != $this->getUserPHID()) { | |||||
if ($info['ownerPHID'] != null) { | |||||
$owner = $this->getConduit()->callMethodSynchronous( | |||||
'user.query', | |||||
array( | |||||
'phids' => array($info['ownerPHID']), | |||||
)); | |||||
if (isset($owner[0])) { | |||||
echo "Task is already assigned to ".$owner[0]['userName'].".\n"; | |||||
} else { | |||||
echo "Task is already assigned to someone else.\n"; | |||||
} | |||||
} else { | |||||
$result = $this->getConduit()->callMethodSynchronous( | |||||
'maniphest.update', | |||||
array( | |||||
'id' => $match[1], | |||||
'ownerPHID' => $this->getUserPHID(), | |||||
)); | |||||
if ($result) { | |||||
echo "T{$match[1]} is now assigned to you.\n"; | |||||
} | |||||
} | |||||
} | |||||
} catch (ConduitClientException $ex) {} | |||||
} | } | ||||
} | } | ||||
if ($err) { | if ($err) { | ||||
if ($api instanceof ArcanistMercurialAPI) { | if ($api instanceof ArcanistMercurialAPI) { | ||||
$rev = ''; | $rev = ''; | ||||
if ($start) { | if ($start) { | ||||
$rev = csprintf('-r %s', $start); | $rev = csprintf('-r %s', $start); | ||||
▲ Show 20 Lines • Show All 218 Lines • Show Last 20 Lines |