From d017e3f2096dda7194600a76bc7328808811c8da Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 19 Aug 2013 01:21:17 +0200 Subject: [PATCH] Adjust GitDriver tag parsing to resolve to SHAs --- src/Composer/Repository/Vcs/GitDriver.php | 11 ++++++++--- .../Composer/Test/Repository/Vcs/GitHubDriverTest.php | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 79e3ae0aa..b220ea573 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -159,9 +159,14 @@ class GitDriver extends VcsDriver public function getTags() { if (null === $this->tags) { - $this->process->execute('git tag', $output, $this->repoDir); - $output = $this->process->splitLines($output); - $this->tags = $output ? array_combine($output, $output) : array(); + $this->tags = array(); + + $this->process->execute('git show-ref --tags', $output, $this->repoDir); + foreach ($output = $this->process->splitLines($output) as $tag) { + if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+)$}', $tag, $match)) { + $this->tags[$match[2]] = $match[1]; + } + } } return $this->tags; diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 3783fd06d..a3cb9dd23 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -252,11 +252,11 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase $process->expects($this->at(2)) ->method('execute') - ->with($this->stringContains('git tag')); + ->with($this->stringContains('git show-ref --tags')); $process->expects($this->at(3)) ->method('splitLines') - ->will($this->returnValue(array($identifier))); + ->will($this->returnValue(array($sha.' refs/tags/'.$identifier))); $process->expects($this->at(4)) ->method('execute')