Browse Source

Adjust GitDriver tag parsing to resolve to SHAs

Jordi Boggiano 11 years ago
parent
commit
d017e3f209

+ 8 - 3
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;

+ 2 - 2
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')