mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Allow the todo
workflow to add project tags.
Summary: Fixes T4418. Allows Maniphests created through the `arc todo` workflow to have projects assigned. Test Plan: ``` > ./bin/arc --trace --conduit-uri='http://phabricator.joshuaspence.com' todo "Test project" --project foo --project bar libphutil loaded from '/home/joshua/workspace/github.com/phacility/libphutil/src'. arcanist loaded from '/home/joshua/workspace/github.com/phacility/arcanist/src'. Config: Reading user configuration file "/home/joshua/.arcrc"... Config: Did not find system configuration at "/etc/arcconfig". Working Copy: Reading .arcconfig from "/home/joshua/workspace/github.com/phacility/arcanist/.arcconfig". Working Copy: Path "/home/joshua/workspace/github.com/phacility/arcanist" is part of `git` working copy "/home/joshua/workspace/github.com/phacility/arcanist". Working Copy: Project root is at "/home/joshua/workspace/github.com/phacility/arcanist". Config: Did not find local configuration at "/home/joshua/workspace/github.com/phacility/arcanist/.git/arc/config". Loading phutil library from '/home/joshua/workspace/github.com/phacility/arcanist/src'... >>> [0] <conduit> conduit.connect() <bytes = 618> >>> [1] <http> http://phabricator.joshuaspence.com/api/conduit.connect <<< [1] <http> 1,050,487 us <<< [0] <conduit> 1,051,585 us >>> [2] <conduit> project.query() <bytes = 199> >>> [3] <http> http://phabricator.joshuaspence.com/api/project.query <<< [3] <http> 294,584 us <<< [2] <conduit> 294,986 us >>> [4] <conduit> maniphest.createtask() <bytes = 313> >>> [5] <http> http://phabricator.joshuaspence.com/api/maniphest.createtask <<< [5] <http> 637,693 us <<< [4] <conduit> 638,098 us Created task T6: 'Test project' at http://phabricator.joshuaspence.com/T6 ``` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T4418 Differential Revision: https://secure.phabricator.com/D9457
This commit is contained in:
parent
3de9e4aaea
commit
f4615cd86b
1 changed files with 32 additions and 9 deletions
|
@ -35,15 +35,19 @@ EOTEXT
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getArguments() {
|
public function getArguments() {
|
||||||
return array(
|
return array(
|
||||||
'*' => 'summary',
|
'*' => 'summary',
|
||||||
'cc' => array(
|
'cc' => array(
|
||||||
'param' => 'cc',
|
'param' => 'cc',
|
||||||
'short' => 'C',
|
'short' => 'C',
|
||||||
'repeat' => true,
|
'repeat' => true,
|
||||||
'help' => 'Other users to CC on the new task.',
|
'help' => pht('Other users to CC on the new task.'),
|
||||||
|
),
|
||||||
|
'project' => array(
|
||||||
|
'param' => 'project',
|
||||||
|
'repeat' => true,
|
||||||
|
'help' => pht('Projects to assign to the task.'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +55,8 @@ EOTEXT
|
||||||
public function run() {
|
public function run() {
|
||||||
$summary = implode(' ', $this->getArgument('summary'));
|
$summary = implode(' ', $this->getArgument('summary'));
|
||||||
$ccs = $this->getArgument('cc');
|
$ccs = $this->getArgument('cc');
|
||||||
|
$slugs = $this->getArgument('project');
|
||||||
|
|
||||||
$conduit = $this->getConduit();
|
$conduit = $this->getConduit();
|
||||||
|
|
||||||
if (trim($summary) == '') {
|
if (trim($summary) == '') {
|
||||||
|
@ -60,7 +66,7 @@ EOTEXT
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'title' => $summary,
|
'title' => $summary,
|
||||||
'ownerPHID' => $this->getUserPHID()
|
'ownerPHID' => $this->getUserPHID(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($ccs) {
|
if ($ccs) {
|
||||||
|
@ -68,7 +74,7 @@ EOTEXT
|
||||||
$users = $conduit->callMethodSynchronous(
|
$users = $conduit->callMethodSynchronous(
|
||||||
'user.query',
|
'user.query',
|
||||||
array(
|
array(
|
||||||
'usernames' => $ccs
|
'usernames' => $ccs,
|
||||||
));
|
));
|
||||||
foreach ($users as $user => $info) {
|
foreach ($users as $user => $info) {
|
||||||
$phids[] = $info['phid'];
|
$phids[] = $info['phid'];
|
||||||
|
@ -76,10 +82,27 @@ EOTEXT
|
||||||
$args['ccPHIDs'] = $phids;
|
$args['ccPHIDs'] = $phids;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $conduit->callMethodSynchronous(
|
if ($slugs) {
|
||||||
'maniphest.createtask',
|
$phids = array();
|
||||||
$args);
|
$projects = $conduit->callMethodSynchronous(
|
||||||
|
'project.query',
|
||||||
|
array(
|
||||||
|
'slugs' => $slugs,
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach ($slugs as $slug) {
|
||||||
|
$project = idx($projects['slugMap'], $slug);
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
throw new ArcanistUsageException('No such project: "'.$slug.'"');
|
||||||
|
}
|
||||||
|
$phids[] = $project;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args['projectPHIDs'] = $phids;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $conduit->callMethodSynchronous('maniphest.createtask', $args);
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"Created task T%s: '<fg:green>**%s**</fg>' at <fg:blue>**%s**</fg>\n",
|
"Created task T%s: '<fg:green>**%s**</fg>' at <fg:blue>**%s**</fg>\n",
|
||||||
$result['id'],
|
$result['id'],
|
||||||
|
|
Loading…
Reference in a new issue