From f08c748658638ec146ddaece6c290a934ee504d1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 24 Aug 2012 02:06:25 +0200 Subject: [PATCH] Fix tests, fix handling of branches with slashes in GitDriver, fixes #935 --- src/Composer/Repository/Vcs/GitDriver.php | 2 +- .../Composer/Test/Repository/Vcs/GitHubDriverTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 9c1345e9d..e3d264cd0 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -168,7 +168,7 @@ class GitDriver extends VcsDriver $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir); foreach ($this->process->splitLines($output) as $branch) { if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) { - if (preg_match('{^(?:\* )? *(?:[^/ ]+?/)?(\S+) *([a-f0-9]+) .*$}', $branch, $match)) { + if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+) .*$}', $branch, $match)) { $branches[$match[1]] = $match[2]; } } diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 38b5d7b80..d8fdebd07 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -156,7 +156,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase { $repoUrl = 'http://github.com/composer/packagist'; $repoApiUrl = 'https://api.github.com/repos/composer/packagist'; - $identifier = 'tree/3.2/master'; + $identifier = 'feature/3.2-foo'; $sha = 'SOMESHA'; $io = $this->getMock('Composer\IO\IOInterface'); @@ -175,12 +175,12 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase $remoteFilesystem->expects($this->at(1)) ->method('getContents') - ->with($this->equalTo('github.com'), $this->equalTo('https://raw.github.com/composer/packagist/tree/3.2/master/composer.json'), $this->equalTo(false)) + ->with($this->equalTo('github.com'), $this->equalTo('https://raw.github.com/composer/packagist/feature%2F3.2-foo/composer.json'), $this->equalTo(false)) ->will($this->returnValue('{"support": {"source": "'.$repoUrl.'" }}')); $remoteFilesystem->expects($this->at(2)) ->method('getContents') - ->with($this->equalTo('github.com'), $this->equalTo('https://api.github.com/repos/composer/packagist/commits/tree%2F3.2%2Fmaster'), $this->equalTo(false)) + ->with($this->equalTo('github.com'), $this->equalTo('https://api.github.com/repos/composer/packagist/commits/feature%2F3.2-foo'), $this->equalTo(false)) ->will($this->returnValue('{"commit": {"committer":{ "date": "2012-09-10"}}}')); $gitHubDriver = new GitHubDriver($repoUrl, $io, $this->config, null, $remoteFilesystem); @@ -191,7 +191,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase $dist = $gitHubDriver->getDist($identifier); $this->assertEquals('zip', $dist['type']); - $this->assertEquals('https://github.com/composer/packagist/zipball/tree/3.2/master', $dist['url']); + $this->assertEquals('https://github.com/composer/packagist/zipball/feature/3.2-foo', $dist['url']); $this->assertEquals($identifier, $dist['reference']); $source = $gitHubDriver->getSource($identifier); @@ -201,7 +201,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase $dist = $gitHubDriver->getDist($sha); $this->assertEquals('zip', $dist['type']); - $this->assertEquals('https://github.com/composer/packagist/zipball/tree/3.2/master', $dist['url']); + $this->assertEquals('https://github.com/composer/packagist/zipball/feature/3.2-foo', $dist['url']); $this->assertEquals($identifier, $dist['reference']); $source = $gitHubDriver->getSource($sha);