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