mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Tasks can be defined in the commit message (Phabricator part).
Summary: Phabricator did not support giving the task ids in the commit message. Currently there is no default implementation for this, but there is a Facebook specific implementation. At some point default implementation for Maniphest tasks to revisions will be added. Test Plan: Tested with the Facebook specific implementation that task ids are recognized in the commit message and tasks are automatically attached to revisions. The task attached to this revision was added from the commit message. Reviewed By: jungejason Reviewers: jungejason, epriestley CC: dpepper, edward, gpatangay, tuomaspelkonen, jungejason Differential Revision: 240996
This commit is contained in:
parent
74777227a3
commit
9367c41a28
8 changed files with 85 additions and 1 deletions
|
@ -156,6 +156,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/revisionupdatehistory',
|
||||
'DifferentialRevisionViewController' => 'applications/differential/controller/revisionview',
|
||||
'DifferentialSubscribeController' => 'applications/differential/controller/subscribe',
|
||||
'DifferentialTasksAttacher' => 'applications/differential/tasks',
|
||||
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
|
||||
'DiffusionBranchInformation' => 'applications/diffusion/data/branch',
|
||||
'DiffusionBranchQuery' => 'applications/diffusion/query/branch/base',
|
||||
|
|
|
@ -66,6 +66,7 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
|
|||
'testPlan' => 'Test Plan',
|
||||
'blameRevision' => 'Blame Revision',
|
||||
'revertPlan' => 'Revert Plan',
|
||||
'tasks' => 'Tasks',
|
||||
);
|
||||
|
||||
foreach ($fields as $field => $value) {
|
||||
|
|
|
@ -62,6 +62,7 @@ class ConduitAPI_differential_parsecommitmessage_Method
|
|||
'ccPHIDs' => $message->getCCPHIDs(),
|
||||
'revisionID' => $message->getRevisionID(),
|
||||
'gitSVNID' => $message->getGitSVNID(),
|
||||
'tasks' => $message->getTasks(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class DifferentialRevisionEditor {
|
|||
protected $diff;
|
||||
protected $comments;
|
||||
protected $silentUpdate;
|
||||
protected $tasks = null;
|
||||
|
||||
public function __construct(DifferentialRevision $revision, $actor_phid) {
|
||||
$this->revision = $revision;
|
||||
|
@ -55,6 +56,11 @@ class DifferentialRevisionEditor {
|
|||
$editor->addDiff($diff, null);
|
||||
$editor->save();
|
||||
|
||||
// Tasks can only be updated after revision has been saved to the
|
||||
// database. Currently tasks are updated only when a revision is created.
|
||||
// UI must be used to modify tasks after creating one.
|
||||
$editor->updateTasks();
|
||||
|
||||
return $revision;
|
||||
}
|
||||
|
||||
|
@ -70,6 +76,7 @@ class DifferentialRevisionEditor {
|
|||
|
||||
$this->setReviewers($fields['reviewerPHIDs']);
|
||||
$this->setCCPHIDs($fields['ccPHIDs']);
|
||||
$this->setTasks($fields['tasks']);
|
||||
}
|
||||
|
||||
public function getRevision() {
|
||||
|
@ -86,6 +93,10 @@ class DifferentialRevisionEditor {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setTasks(array $tasks) {
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
|
||||
public function addDiff(DifferentialDiff $diff, $comments) {
|
||||
if ($diff->getRevisionID() &&
|
||||
$diff->getRevisionID() != $this->getRevision()->getID()) {
|
||||
|
@ -555,5 +566,20 @@ class DifferentialRevisionEditor {
|
|||
return $comment;
|
||||
}
|
||||
|
||||
private function updateTasks() {
|
||||
if ($this->tasks) {
|
||||
$task_class = PhabricatorEnv::getEnvConfig(
|
||||
'differential.attach-task-class');
|
||||
if ($task_class) {
|
||||
PhutilSymbolLoader::loadClass($task_class);
|
||||
$task_attacher = newv($task_class, array());
|
||||
$ret = $task_attacher->attachTasksToRevision(
|
||||
$this->actorPHID,
|
||||
$this->revision,
|
||||
$this->tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ phutil_require_module('phabricator', 'infrastructure/env');
|
|||
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ class DifferentialCommitMessage {
|
|||
protected $revisionID;
|
||||
protected $gitSVNID;
|
||||
|
||||
protected $tasks = array();
|
||||
|
||||
protected function __construct() {
|
||||
|
||||
}
|
||||
|
@ -160,6 +162,14 @@ class DifferentialCommitMessage {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setTasks(array $tasks) {
|
||||
$this->tasks = $tasks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTasks() {
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
public static function newFromRawCorpus($raw_corpus) {
|
||||
$message = new DifferentialCommitMessage();
|
||||
|
@ -202,6 +212,9 @@ class DifferentialCommitMessage {
|
|||
case 'Commenters':
|
||||
// Just drop this.
|
||||
break;
|
||||
case 'Tasks':
|
||||
$message->setTasks($data);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unrecognized field '{$field}'.");
|
||||
}
|
||||
|
@ -298,7 +311,9 @@ class DifferentialCommitMessage {
|
|||
'CC' => 'CC',
|
||||
'Revert' => 'Revert Plan',
|
||||
'Revert Plan' => 'Revert Plan',
|
||||
|
||||
'Task ID' => 'Tasks',
|
||||
'Task IDs' => 'Tasks',
|
||||
'Tasks' => 'Tasks',
|
||||
'git-svn-id' => 'git-svn-id',
|
||||
|
||||
// This appears only in "arc amend"-ed messages, just discard it.
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
abstract class DifferentialTasksAttacher {
|
||||
/**
|
||||
* Implementation of this function should attach given tasks to
|
||||
* the given revision. The function is called when 'arc' has task
|
||||
* ids defined in the commit message.
|
||||
*/
|
||||
abstract public function attachTasksToRevision(
|
||||
$user_phid,
|
||||
DifferentialRevision $revision,
|
||||
array $task_ids);
|
||||
}
|
10
src/applications/differential/tasks/__init__.php
Normal file
10
src/applications/differential/tasks/__init__.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
phutil_require_source('DifferentialTasksAttacher.php');
|
Loading…
Reference in a new issue