Skip to content

Commit 24f4e51

Browse files
committed
GitRepository: pull(), push() & fetch() - accepts string[] in $remote
#77 (comment)
1 parent 8e061b2 commit 24f4e51

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ $repo->pull('origin');
206206
// pushs changes to remote
207207
$repo->push('remote-name', ['--options']);
208208
$repo->push('origin');
209-
$repo->push('origin', ['master', '-u']);
209+
$repo->push(['origin', 'master'], ['-u']);
210210

211211
// fetchs changes from remote
212212
$repo->fetch('remote-name', ['--options']);
213213
$repo->fetch('origin');
214-
$repo->fetch('origin', ['master']);
214+
$repo->fetch(['origin', 'master']);
215215

216216
// adds remote repository
217217
$repo->addRemote('remote-name', 'repository-url', ['--options']);

src/GitRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public function hasChanges()
459459

460460
/**
461461
* Pull changes from a remote
462-
* @param string|NULL $remote
462+
* @param string|string[]|NULL $remote
463463
* @param array<mixed>|NULL $options
464464
* @return static
465465
* @throws GitException
@@ -473,7 +473,7 @@ public function pull($remote = NULL, array $options = NULL)
473473

474474
/**
475475
* Push changes to a remote
476-
* @param string|NULL $remote
476+
* @param string|string[]|NULL $remote
477477
* @param array<mixed>|NULL $options
478478
* @return static
479479
* @throws GitException
@@ -487,7 +487,7 @@ public function push($remote = NULL, array $options = NULL)
487487

488488
/**
489489
* Run fetch command to get latest branches
490-
* @param string|NULL $remote
490+
* @param string|string[]|NULL $remote
491491
* @param array<mixed>|NULL $options
492492
* @return static
493493
* @throws GitException

tests/GitPhp/GitRepository.remotes.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ $repo->setRemoteUrl('origin3', 'test-url', [
3535
$repo->removeRemote('origin2');
3636

3737
$runner->assert(['push', '--end-of-options', 'origin']);
38+
$runner->assert(['push', '--repo', 'https://user:[email protected]/MyUser/MyRepo.git', '--end-of-options']);
39+
$runner->assert(['push', '--end-of-options', 'origin', 'master']);
3840
$runner->assert(['fetch', '--end-of-options', 'origin']);
41+
$runner->assert(['fetch', '--end-of-options', 'origin', 'master']);
3942
$runner->assert(['pull', '--end-of-options', 'origin']);
43+
$runner->assert(['pull', '--end-of-options', 'origin', 'master']);
4044
$repo->push('origin');
45+
$repo->push(NULL, ['--repo' => 'https://user:[email protected]/MyUser/MyRepo.git']);
46+
$repo->push(['origin', 'master']);
4147
$repo->fetch('origin');
48+
$repo->fetch(['origin', 'master']);
4249
$repo->pull('origin');
50+
$repo->pull(['origin', 'master']);

0 commit comments

Comments
 (0)