Page MenuHomePhabricator

DifferentialSetBaseCommitConduitAPIMethod.php

Authored By
epriestley
May 4 2017, 7:59 PM
Size
1 KB
Referenced Files
None
Subscribers
None

DifferentialSetBaseCommitConduitAPIMethod.php

<?php
final class DifferentialSetBaseCommitConduitAPIMethod
extends DifferentialConduitAPIMethod {
public function getAPIMethodName() {
return 'differential.hack.setbasecommit';
}
public function getMethodDescription() {
return pht('(Temporary Hack) Set the base commit of a diff.');
}
protected function defineParamTypes() {
return array(
'diffID' => 'required id',
'commit' => 'required string',
);
}
protected function defineReturnType() {
return 'null';
}
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
$diff_id = $request->getValue('diffID');
if (!strlen($diff_id)) {
throw new Exception(
pht(
'To select a diff to affect, provide a "diffID".'));
}
$diff = id(new DifferentialDiffQuery())
->setViewer($viewer)
->withIDs(array($diff_id))
->executeOne();
if (!$diff) {
throw new Exception(
pht(
'No diff exists with ID "%s".',
$diff_id));
}
$commit = $request->getValue('commit');
if (!strlen($commit)) {
throw new Exception(
pht(
'Provide a "commit" to identify which commit to set as '.
'the base.'));
}
$diff
->setSourceControlBaseRevision($commit)
->save();
return null;
}
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
640569
Default Alt Text
DifferentialSetBaseCommitConduitAPIMethod.php (1 KB)

Event Timeline