From 24f4e51cc536a723b7838686284d1c21c6de088b Mon Sep 17 00:00:00 2001 From: Jan Pecha Date: Wed, 27 Apr 2022 14:18:41 +0200 Subject: [PATCH] GitRepository: pull(), push() & fetch() - accepts string[] in $remote https://github.com/czproject/git-php/issues/77#issuecomment-1110222085 --- readme.md | 4 ++-- src/GitRepository.php | 6 +++--- tests/GitPhp/GitRepository.remotes.phpt | 8 ++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index df7276d..a8b139c 100644 --- a/readme.md +++ b/readme.md @@ -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']); diff --git a/src/GitRepository.php b/src/GitRepository.php index 4da289d..71a2caa 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -459,7 +459,7 @@ public function hasChanges() /** * Pull changes from a remote - * @param string|NULL $remote + * @param string|string[]|NULL $remote * @param array|NULL $options * @return static * @throws GitException @@ -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|NULL $options * @return static * @throws GitException @@ -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|NULL $options * @return static * @throws GitException diff --git a/tests/GitPhp/GitRepository.remotes.phpt b/tests/GitPhp/GitRepository.remotes.phpt index d85fd58..aeda5c3 100644 --- a/tests/GitPhp/GitRepository.remotes.phpt +++ b/tests/GitPhp/GitRepository.remotes.phpt @@ -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:password@example.com/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:password@example.com/MyUser/MyRepo.git']); +$repo->push(['origin', 'master']); $repo->fetch('origin'); +$repo->fetch(['origin', 'master']); $repo->pull('origin'); +$repo->pull(['origin', 'master']);