Skip to content

Commit

Permalink
GitRepository: pull(), push() & fetch() - accepts string[] in $remote
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Apr 27, 2022
1 parent 8e061b2 commit 24f4e51
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ $repo->pull('origin');
// pushs changes to remote
$repo->push('remote-name', ['--options']);
$repo->push('origin');
$repo->push('origin', ['master', '-u']);
$repo->push(['origin', 'master'], ['-u']);

// fetchs changes from remote
$repo->fetch('remote-name', ['--options']);
$repo->fetch('origin');
$repo->fetch('origin', ['master']);
$repo->fetch(['origin', 'master']);

// adds remote repository
$repo->addRemote('remote-name', 'repository-url', ['--options']);
Expand Down
6 changes: 3 additions & 3 deletions src/GitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public function hasChanges()

/**
* Pull changes from a remote
* @param string|NULL $remote
* @param string|string[]|NULL $remote
* @param array<mixed>|NULL $options
* @return static
* @throws GitException
Expand All @@ -473,7 +473,7 @@ public function pull($remote = NULL, array $options = NULL)

/**
* Push changes to a remote
* @param string|NULL $remote
* @param string|string[]|NULL $remote
* @param array<mixed>|NULL $options
* @return static
* @throws GitException
Expand All @@ -487,7 +487,7 @@ public function push($remote = NULL, array $options = NULL)

/**
* Run fetch command to get latest branches
* @param string|NULL $remote
* @param string|string[]|NULL $remote
* @param array<mixed>|NULL $options
* @return static
* @throws GitException
Expand Down
8 changes: 8 additions & 0 deletions tests/GitPhp/GitRepository.remotes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ $repo->setRemoteUrl('origin3', 'test-url', [
$repo->removeRemote('origin2');

$runner->assert(['push', '--end-of-options', 'origin']);
$runner->assert(['push', '--repo', 'https://user:[email protected]/MyUser/MyRepo.git', '--end-of-options']);
$runner->assert(['push', '--end-of-options', 'origin', 'master']);
$runner->assert(['fetch', '--end-of-options', 'origin']);
$runner->assert(['fetch', '--end-of-options', 'origin', 'master']);
$runner->assert(['pull', '--end-of-options', 'origin']);
$runner->assert(['pull', '--end-of-options', 'origin', 'master']);
$repo->push('origin');
$repo->push(NULL, ['--repo' => 'https://user:[email protected]/MyUser/MyRepo.git']);
$repo->push(['origin', 'master']);
$repo->fetch('origin');
$repo->fetch(['origin', 'master']);
$repo->pull('origin');
$repo->pull(['origin', 'master']);

0 comments on commit 24f4e51

Please sign in to comment.