Skip to content

Commit 0fdab22

Browse files
authored
Merge pull request #71 from shivas/allow-.git-to-be-file
GitRevisionProvider: Recognize repository if .git is a file as well
2 parents 44611db + 2b6a029 commit 0fdab22

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Provider/GitRepositoryProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private function isGitRepository($path)
5252
return false;
5353
}
5454

55-
if (is_dir($path . DIRECTORY_SEPARATOR . '.git')) {
55+
if (file_exists($path . DIRECTORY_SEPARATOR . '.git')) {
5656
return true;
5757
}
5858

Tests/Provider/GitRepositoryProviderTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,23 @@ public function testIsSupportedGitDescribeError()
9393
/**
9494
* @covers \Shivas\VersioningBundle\Provider\GitRepositoryProvider::isSupported
9595
*/
96-
public function testIsSupported()
96+
public function testIsSupportedDir()
9797
{
9898
vfsStream::newDirectory('.git')->at($this->root);
9999
self::$gitDescribeOutput = '1.2.3';
100100
$this->assertTrue($this->gitRepositoryProvider->isSupported());
101101
}
102102

103+
/**
104+
* @covers \Shivas\VersioningBundle\Provider\GitRepositoryProvider::isSupported
105+
*/
106+
public function testIsSupportedFile()
107+
{
108+
vfsStream::newFile('.git')->at($this->root);
109+
self::$gitDescribeOutput = '1.2.3';
110+
$this->assertTrue($this->gitRepositoryProvider->isSupported());
111+
}
112+
103113
/**
104114
* @covers \Shivas\VersioningBundle\Provider\GitRepositoryProvider::getVersion
105115
*/

0 commit comments

Comments
 (0)