Summary: Ref T2784. This one was a wee bit complicated. Had to add PhabricatorUser and concept of initFromConduit (or not) to DiffusionRequest. Test Plan: foreach repo, visited CALLSIGN and clicked a commit and verified they laoded correctly. Hacked code to hit NOT via Conduit and repeated tests to great success. Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin Maniphest Tasks: T2784 Differential Revision: https://secure.phabricator.com/D5928
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group diffusion
|
|
*/
|
|
final class DiffusionGitRequest extends DiffusionRequest {
|
|
|
|
protected function getSupportsBranches() {
|
|
return true;
|
|
}
|
|
|
|
protected function didInitialize() {
|
|
if (!$this->commit) {
|
|
return;
|
|
}
|
|
|
|
$this->expandCommitName();
|
|
}
|
|
|
|
public function getBranch() {
|
|
if ($this->branch) {
|
|
return $this->branch;
|
|
}
|
|
if ($this->repository) {
|
|
return $this->repository->getDefaultBranch();
|
|
}
|
|
throw new Exception("Unable to determine branch!");
|
|
}
|
|
|
|
public function getCommit() {
|
|
if ($this->commit) {
|
|
return $this->commit;
|
|
}
|
|
$remote = DiffusionBranchInformation::DEFAULT_GIT_REMOTE;
|
|
return $remote.'/'.$this->getBranch();
|
|
}
|
|
|
|
public function getStableCommitName() {
|
|
if (!$this->stableCommitName) {
|
|
if ($this->commit) {
|
|
$this->stableCommitName = $this->commit;
|
|
} else {
|
|
$branch = $this->getBranch();
|
|
list($stdout) = $this->getRepository()->execxLocalCommand(
|
|
'rev-parse --verify %s/%s',
|
|
DiffusionBranchInformation::DEFAULT_GIT_REMOTE,
|
|
$branch);
|
|
$this->stableCommitName = trim($stdout);
|
|
}
|
|
}
|
|
return substr($this->stableCommitName, 0, 16);
|
|
}
|
|
|
|
}
|