Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
[BUGFIX] added constraint testing if git diff is null or empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
michael.sandritter committed Jul 15, 2016
1 parent 9bd4061 commit 39a19db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Vcs/Driver/GitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function hasChangesSinceTag($tag, $path)
throw $e;
}

if (null === $diff) {
if (null === $diff || "" === $diff) {
return false;
}

Expand Down
32 changes: 31 additions & 1 deletion test/Vcs/Driver/GitDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function shouldAbortRebaseOnPullError()
/**
* @test
*/
public function shouldNotHaveChangesSinceTag()
public function shouldNotHaveChangesSinceTagWithNullValueFromGitAdapter()
{
$adapter = $this->givenAnAdapter();

Expand All @@ -184,6 +184,36 @@ public function shouldNotHaveChangesSinceTag()
$this->assertFalse($driver->hasChangesSinceTag('0.2.5', '/home/my/vcs/repo'));
}

/**
* @test
*/
public function shouldNotHaveChangesSinceTagWithEmptyStringValueFromGitAdapter()
{
$adapter = $this->givenAnAdapter();

$adapter->expects($this->once())->method('execute')->with(
'diff',
array('--ignore-all-space', '0.2.5'),
'/home/my/vcs/repo'
)->will($this->returnValue(""));

$git = $this->getMockBuilder('Webcreate\\Vcs\\Git')
->disableOriginalConstructor()
->setMethods(array('getAdapter'))
->getMock();
$git->expects($this->once())->method('getAdapter')->will($this->returnValue($adapter));

$driver = $this->givenADriver();

$driver->expects($this->once())->method('getGit')->will(
$this->returnValue($git)
);

/** @var GitDriver $driver */
$this->assertFalse($driver->hasChangesSinceTag('0.2.5', '/home/my/vcs/repo'));
}


/**
* @test
*/
Expand Down

0 comments on commit 39a19db

Please sign in to comment.