Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from niels-nijens/fix-pull-existing-branch
Browse files Browse the repository at this point in the history
Add git pull to GitAdapter::checkout to make sure the checking out the current branch pulls the updates
  • Loading branch information
niels-nijens committed Mar 25, 2016
2 parents 7bfd10b + 29408a6 commit a6b759d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning 2](http://semver.org/).

## [Unreleased]
### Fixed
* Fixed updating the current branch of a git clone with the checkout command.

## [0.2.0] - 2016-03-31
### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/GitAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function checkout($version)

$escapedVersion = ProcessUtils::escapeArgument($version);
if ($this->processExecutor->isDirectory($this->repositoryDirectory) && $this->processExecutor->execute('git rev-parse --is-inside-work-tree', $this->repositoryDirectory)->isSuccessful()) {
$checkoutSuccesful = ($this->processExecutor->execute('git fetch', $this->repositoryDirectory)->isSuccessful() && $this->processExecutor->execute(sprintf('git checkout %s', $escapedVersion), $this->repositoryDirectory)->isSuccessful());
$checkoutSuccesful = ($this->processExecutor->execute('git fetch', $this->repositoryDirectory)->isSuccessful() && $this->processExecutor->execute(sprintf('git checkout %s', $escapedVersion), $this->repositoryDirectory)->isSuccessful() && $this->processExecutor->execute('git pull', $this->repositoryDirectory)->isSuccessful());
} else {
$escapedRepositoryUrl = ProcessUtils::escapeArgument($this->repositoryUrl);
$escapedRepositoryDirectory = ProcessUtils::escapeArgument($this->repositoryDirectory);
Expand Down
6 changes: 4 additions & 2 deletions tests/Adapter/GitAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ public function provideTestCheckout()
$processExecutorMock->expects($this->once())
->method('isDirectory')
->willReturn(true);
$processExecutorMock->expects($this->exactly(3))
$processExecutorMock->expects($this->exactly(4))
->method('execute')
->withConsecutive(
array($this->equalTo('git rev-parse --is-inside-work-tree'), $this->equalTo('/git/working-directory')),
array($this->equalTo('git fetch')),
array($this->equalTo($checkoutCommand), $this->equalTo('/git/working-directory'))
array($this->equalTo($checkoutCommand), $this->equalTo('/git/working-directory')),
array($this->equalTo('git pull'), $this->equalTo('/git/working-directory'))
)
->willReturnOnConsecutiveCalls(
new ProcessExecutionResult(0, '', ''),
new ProcessExecutionResult(0, '', ''),
new ProcessExecutionResult(0, '', ''),
new ProcessExecutionResult(0, '', '')
Expand Down

0 comments on commit a6b759d

Please sign in to comment.