Skip to content

Commit

Permalink
[FEATURE] RS-1988 aoe/tagging library checkout-Prozess anpassen
Browse files Browse the repository at this point in the history
  • Loading branch information
michael.sandritter committed Jul 19, 2016
1 parent 94ac03e commit 7495be6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Vcs/Driver/GitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function tag($tag, $branch, $path)
try {
$this->getGit()->getAdapter()->execute('tag', array($tag), $path);
$this->getGit()->getAdapter()->execute('pull', ['origin', $branch], $path);
$this->getGit()->getAdapter()->execute('branch', [$branch ,'origin/' . $branch, '-f'], $path);
$this->getGit()->getAdapter()->execute('push', ['origin', $branch], $path);
$this->getGit()->getAdapter()->execute('push', array('origin', 'tag', $tag), $path);
} catch (\Exception $e) {
Expand Down Expand Up @@ -112,7 +113,6 @@ public function hasChangesSinceTag($tag, $branch, $path, OutputInterface $output
{
try {
$this->getGit()->getAdapter()->execute('fetch', ['origin'], $path);
$this->getGit()->getAdapter()->execute('branch', [$branch ,'origin/' . $branch, '-f'], $path);
$diff = $this->getGit()->getAdapter()->execute('diff', array('--ignore-all-space', $tag), $path);
} catch (\RuntimeException $e) {
if (false !== strpos($e->getMessage(), 'unknown revision or path')) {
Expand Down
26 changes: 19 additions & 7 deletions test/Vcs/Driver/GitDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ public function shouldTagAndPush()
);

$adapter->expects($this->at(2))->method('execute')->with(
'branch',
array('myBranch', 'feature/myBranch', '-f'),
'/home/my/vcs/repo'
);

$adapter->expects($this->at(3))->method('execute')->with(
'push',
array('origin', 'feature/myBranch'),
'/home/my/vcs/repo'
);

$adapter->expects($this->at(3))->method('execute')->with(
$adapter->expects($this->at(4))->method('execute')->with(
'push',
array('origin', 'tag', '0.2.5'),
'/home/my/vcs/repo'
Expand All @@ -57,11 +63,11 @@ public function shouldTagAndPush()
->disableOriginalConstructor()
->setMethods(array('getAdapter'))
->getMock();
$git->expects($this->exactly(4))->method('getAdapter')->will($this->returnValue($adapter));
$git->expects($this->any())->method('getAdapter')->will($this->returnValue($adapter));

$driver = $this->givenADriver();

$driver->expects($this->exactly(4))->method('getGit')->will(
$driver->expects($this->any())->method('getGit')->will(
$this->returnValue($git)
);

Expand Down Expand Up @@ -93,18 +99,24 @@ public function shouldCleanOnError()
);

$adapter->expects($this->at(2))->method('execute')->with(
'branch',
array('myBranch', 'feature/myBranch', '-f'),
'/home/my/vcs/repo'
);

$adapter->expects($this->at(3))->method('execute')->with(
'push',
array('origin', 'master'),
'/home/my/vcs/repo'
)->will($this->throwException(new \Exception('could not push to remote')));

$adapter->expects($this->at(3))->method('execute')->with(
$adapter->expects($this->at(4))->method('execute')->with(
'reset',
array('--hard'),
'/home/my/vcs/repo'
);

$adapter->expects($this->at(4))->method('execute')->with(
$adapter->expects($this->at(5))->method('execute')->with(
'tag',
array('-d', '0.2.5'),
'/home/my/vcs/repo'
Expand All @@ -114,11 +126,11 @@ public function shouldCleanOnError()
->disableOriginalConstructor()
->setMethods(array('getAdapter'))
->getMock();
$git->expects($this->exactly(5))->method('getAdapter')->will($this->returnValue($adapter));
$git->expects($this->exactly(6))->method('getAdapter')->will($this->returnValue($adapter));

$driver = $this->givenADriver();

$driver->expects($this->exactly(5))->method('getGit')->will(
$driver->expects($this->exactly(6))->method('getGit')->will(
$this->returnValue($git)
);

Expand Down

0 comments on commit 7495be6

Please sign in to comment.