2012-07-31 16:27:48 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionCommitBranchesController extends DiffusionController {
|
|
|
|
|
2013-09-27 10:49:45 -07:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-31 16:27:48 -07:00
|
|
|
public function willProcessRequest(array $data) {
|
2013-05-14 15:32:19 -07:00
|
|
|
$data['user'] = $this->getRequest()->getUser();
|
2012-07-31 16:27:48 -07:00
|
|
|
$this->diffusionRequest = DiffusionRequest::newFromDictionary($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getDiffusionRequest();
|
|
|
|
|
2013-05-20 17:04:51 -07:00
|
|
|
$branches = array();
|
|
|
|
try {
|
|
|
|
$branches = $this->callConduitWithDiffusionRequest(
|
2014-01-17 16:11:04 -08:00
|
|
|
'diffusion.branchquery',
|
|
|
|
array(
|
|
|
|
'contains' => $request->getCommit(),
|
|
|
|
));
|
2013-05-20 17:04:51 -07:00
|
|
|
} catch (ConduitException $ex) {
|
|
|
|
if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') {
|
|
|
|
throw $ex;
|
|
|
|
}
|
|
|
|
}
|
2012-07-31 16:27:48 -07:00
|
|
|
|
2014-01-17 16:11:04 -08:00
|
|
|
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
|
|
|
|
|
2012-07-31 16:27:48 -07:00
|
|
|
$branch_links = array();
|
2014-01-17 16:11:04 -08:00
|
|
|
foreach ($branches as $branch) {
|
2013-01-17 18:43:35 -08:00
|
|
|
$branch_links[] = phutil_tag(
|
2012-07-31 16:27:48 -07:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $request->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
2014-01-17 16:11:04 -08:00
|
|
|
'branch' => $branch->getShortName(),
|
2012-07-31 16:27:48 -07:00
|
|
|
)),
|
|
|
|
),
|
2014-01-17 16:11:04 -08:00
|
|
|
$branch->getShortName());
|
2012-07-31 16:27:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
|
|
->setContent($branch_links ? implode(', ', $branch_links) : 'None');
|
|
|
|
}
|
|
|
|
}
|