1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00

include task ids in the commit messages returned by "arc amend"

Summary:
when "arc diff" generates a revision, it attaches a task id
if one is included.  However, "arc amend" did not return a task id,
effectively stripping it from the commit message.  This diff fixes
that.

NOTE: This is dependent on revision 549 https://secure.phabricator.com/D549

Test Plan:
0. created a custom class to append Facebook task IDs to commit messages and
attached it to the differential.append-commit-message-class config variable
1. created a new diff in the www repot
2. included Task ID: 609350 in the git commit message
3. "arc diff" to generate the revision
4. "arc amend"
5. ensure that the "Task ID:" field remained in the git commit message

Reviewed By: epriestley
Reviewers: dpepper, jungejason, epriestley
CC: aran, epriestley, mgummelt
Differential Revision: 546
This commit is contained in:
mgummelt 2011-06-28 15:47:43 -07:00
parent ae78ea38e6
commit 3c785cdb5a
5 changed files with 58 additions and 0 deletions

View file

@ -355,6 +355,12 @@ return array(
'/.*/' => 80,
),
// Class for appending custom fields to be included in the commit
// messages generated by "arc amend". Should inherit
// DifferentialCommitMessageModifier
'differential.modify-commit-message-class' => null,
// -- Maniphest ------------------------------------------------------------- //
'maniphest.enabled' => true,

View file

@ -140,6 +140,7 @@ phutil_register_library_map(array(
'DifferentialCommitMessage' => 'applications/differential/parser/commitmessage',
'DifferentialCommitMessageData' => 'applications/differential/data/commitmessage',
'DifferentialCommitMessageField' => 'applications/differential/data/commitmessage',
'DifferentialCommitMessageModifier' => 'applications/differential/data/commitmessage',
'DifferentialCommitMessageParserException' => 'applications/differential/parser/commitmessage/exception',
'DifferentialController' => 'applications/differential/controller/base',
'DifferentialDAO' => 'applications/differential/storage/base',

View file

@ -154,6 +154,15 @@ class DifferentialCommitMessageData {
$fields[] = new DifferentialCommitMessageField('Differential Revision',
$revision->getID());
// append custom commit message fields
$modify_class = PhabricatorEnv::getEnvConfig(
'differential.modify-commit-message-class');
if ($modify_class) {
$modifier = newv($modify_class, array($revision));
$fields = $modifier->modifyFields($fields);
}
$this->fields = $fields;
}

View file

@ -0,0 +1,39 @@
<?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 DifferentialCommitMessageModifier {
protected $revision;
/**
* @param DifferentialRevision The revision to generate fields for
*/
public function __construct(DifferentialRevision $revision) {
$this->revision = $revision;
}
/**
* Implementation of this function should remove, modify, or append
* fields to the $fields representing the fields for the given
* $revision. It should return the modified dict. These fields are
* included in the commit message generated by 'arc amend'.
*
* @param array The array of fields to modify
* @return array The updated array of fields
*/
abstract public function modifyFields(array $fields);
}

View file

@ -9,9 +9,12 @@
phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');
phutil_require_source('DifferentialCommitMessageData.php');
phutil_require_source('DifferentialCommitMessageField.php');
phutil_require_source('DifferentialCommitMessageModifier.php');