From 7360688afb5fb278d9a23e17fcaaca1f4ed31b1b Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 30 Oct 2013 13:06:03 -0700 Subject: [PATCH] Conditionally restore some "remote/" stuff removed by rP59922b7 Summary: Fixes T4035. I removed these two "remote/" things in rP59922b7, but we need them for non-bare repositories. Without them, the commands work and run fine and the output looks OK, but the results may not reflect the correct information (e.g., the log shows the working copy's master, which may not be in the same state as origin/master). I'm going to generally clean this up, but unbreak it for now. Test Plan: Viewed bare and non-bare repositories in Diffusion, got accurate history. Reviewers: btrahan, hach-que Reviewed By: btrahan CC: aran, mbishopim3 Maniphest Tasks: T4035 Differential Revision: https://secure.phabricator.com/D7445 --- .../DiffusionGitStableCommitNameQuery.php | 14 +++++++++++--- .../diffusion/request/DiffusionGitRequest.php | 8 +++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/applications/diffusion/query/stablecommitname/DiffusionGitStableCommitNameQuery.php b/src/applications/diffusion/query/stablecommitname/DiffusionGitStableCommitNameQuery.php index 8c03ad96e7..c30d81c393 100644 --- a/src/applications/diffusion/query/stablecommitname/DiffusionGitStableCommitNameQuery.php +++ b/src/applications/diffusion/query/stablecommitname/DiffusionGitStableCommitNameQuery.php @@ -6,9 +6,17 @@ extends DiffusionStableCommitNameQuery { protected function executeQuery() { $repository = $this->getRepository(); $branch = $this->getBranch(); - list($stdout) = $repository->execxLocalCommand( - 'rev-parse --verify %s', - $branch); + + if ($repository->isWorkingCopyBare()) { + list($stdout) = $repository->execxLocalCommand( + 'rev-parse --verify %s', + $branch); + } else { + list($stdout) = $repository->execxLocalCommand( + 'rev-parse --verify %s/%s', + DiffusionBranchInformation::DEFAULT_GIT_REMOTE, + $branch); + } $commit = trim($stdout); return substr($commit, 0, 16); diff --git a/src/applications/diffusion/request/DiffusionGitRequest.php b/src/applications/diffusion/request/DiffusionGitRequest.php index 975051d898..df3df74c72 100644 --- a/src/applications/diffusion/request/DiffusionGitRequest.php +++ b/src/applications/diffusion/request/DiffusionGitRequest.php @@ -31,7 +31,13 @@ final class DiffusionGitRequest extends DiffusionRequest { if ($this->commit) { return $this->commit; } - return $this->getBranch(); + + if ($this->repository->isWorkingCopyBare()) { + return $this->getBranch(); + } else { + $remote = DiffusionBranchInformation::DEFAULT_GIT_REMOTE; + return $remote.'/'.$this->getBranch(); + } } }