From ebcd60eae55776b0a463720f60679818f23e1ef2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 5 Nov 2013 15:09:08 -0800 Subject: [PATCH] Fix an issue with non-bare Git repositories and non-master branches Summary: This is a little funky but fixes an issue with Git repos that are non-bare needing "origin/" to resolve branches other than "master". Eventually this should get cleaned up. Test Plan: Reporting user verified this fixed their issue. Auditors: btrahan --- .../diffusion/request/DiffusionGitRequest.php | 8 ++++++-- src/applications/diffusion/request/DiffusionRequest.php | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/applications/diffusion/request/DiffusionGitRequest.php b/src/applications/diffusion/request/DiffusionGitRequest.php index df3df74c72..2f411c6584 100644 --- a/src/applications/diffusion/request/DiffusionGitRequest.php +++ b/src/applications/diffusion/request/DiffusionGitRequest.php @@ -32,11 +32,15 @@ final class DiffusionGitRequest extends DiffusionRequest { return $this->commit; } + return $this->getResolvableBranchName($this->getBranch()); + } + + protected function getResolvableBranchName($branch) { if ($this->repository->isWorkingCopyBare()) { - return $this->getBranch(); + return $branch; } else { $remote = DiffusionBranchInformation::DEFAULT_GIT_REMOTE; - return $remote.'/'.$this->getBranch(); + return $remote.'/'.$branch; } } diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php index 9640df0a2f..928cc15422 100644 --- a/src/applications/diffusion/request/DiffusionRequest.php +++ b/src/applications/diffusion/request/DiffusionRequest.php @@ -643,7 +643,7 @@ abstract class DiffusionRequest { } if ($this->getSupportsBranches()) { - $branch = $this->getBranch(); + $branch = $this->getResolvableBranchName($this->getBranch()); } else { $branch = 'HEAD'; } @@ -660,6 +660,10 @@ abstract class DiffusionRequest { return $this->stableCommitName; } + protected function getResolvableBranchName($branch) { + return $branch; + } + private function resolveRefs(array $refs) { if ($this->shouldInitFromConduit()) { return DiffusionQuery::callConduitWithDiffusionRequest(