1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +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'])) { if (isset($_REQUEST['params']) && is_array($_REQUEST['params'])) {
$params_post = $request->getArr('params'); $params_post = $request->getArr('params');
foreach ($params_post as $key => $value) { 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); $decoded_value = json_decode($value, true);
if ($decoded_value === null && strtolower($value) != 'null') { if ($decoded_value === null && strtolower($value) != 'null') {
// When json_decode() fails, it returns null. This almost certainly // When json_decode() fails, it returns null. This almost certainly

View file

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

View file

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