1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Allow "differential.getcommitmessage" to be called without a revision ID in

order to generate a template

Summary: See T614. This allows us to generate an empty template by calling
Conduit, so we can build command-line editing workflows for SVN, Mercurial, and
conservative-Git.

Test Plan: Used web console to invoke Conduit method; got a reasonable empty
template out of it.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, epriestley, btrahan

Differential Revision: 1156
This commit is contained in:
epriestley 2011-12-01 16:01:48 -08:00
parent 462ad4169c
commit 19f2110e74
3 changed files with 18 additions and 5 deletions

View file

@ -67,6 +67,11 @@ class PhabricatorConduitAPIController
if (isset($_REQUEST['params']) && is_array($_REQUEST['params'])) {
$params_post = $request->getArr('params');
foreach ($params_post as $key => $value) {
if ($value == '') {
// Interpret empty string null (e.g., the user didn't type anything
// into the box).
$value = 'null';
}
$decoded_value = json_decode($value, true);
if ($decoded_value === null && strtolower($value) != 'null') {
// When json_decode() fails, it returns null. This almost certainly

View file

@ -22,12 +22,12 @@
class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
public function getMethodDescription() {
return "Retrieve Differential commit messages.";
return "Retrieve Differential commit messages or message templates.";
}
public function defineParamTypes() {
return array(
'revision_id' => 'required revision_id',
'revision_id' => 'optional revision_id',
'fields' => 'optional dict<string, wild>',
'edit' => 'optional bool',
);
@ -46,9 +46,13 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
protected function execute(ConduitAPIRequest $request) {
$id = $request->getValue('revision_id');
$revision = id(new DifferentialRevision())->load($id);
if (!$revision) {
throw new ConduitException('ERR_NOT_FOUND');
if ($id) {
$revision = id(new DifferentialRevision())->load($id);
if (!$revision) {
throw new ConduitException('ERR_NOT_FOUND');
}
} else {
$revision = new DifferentialRevision();
}
$revision->loadRelationships();

View file

@ -29,6 +29,10 @@ final class DifferentialRevisionIDFieldSpecification
return true;
}
public function shouldAppearOnCommitMessageTemplate() {
return false;
}
public function getCommitMessageKey() {
return 'revisionID';
}