diff --git a/src/PHPGit/Command/ArchiveCommand.php b/src/PHPGit/Command/ArchiveCommand.php index a6c9bd0..315ccb1 100644 --- a/src/PHPGit/Command/ArchiveCommand.php +++ b/src/PHPGit/Command/ArchiveCommand.php @@ -50,6 +50,10 @@ public function __invoke($file, $tree = null, $path = null, array $options = arr $builder->add('--prefix=' . $options['prefix']); } + if ($options['remote']) { + $builder->add('--remote=' . $options['remote']); + } + $builder->add('-o')->add($file); if ($tree) { @@ -79,12 +83,14 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'format' => null, - 'prefix' => null + 'prefix' => null, + 'remote' => null )); $resolver->setAllowedTypes(array( 'format' => array('null', 'string'), - 'prefix' => array('null', 'string') + 'prefix' => array('null', 'string'), + 'remote' => array('null', 'string') )); $resolver->setAllowedValues(array( diff --git a/test/PHPGit/Command/ArchiveCommandTest.php b/test/PHPGit/Command/ArchiveCommandTest.php index 982c8f7..8525f38 100644 --- a/test/PHPGit/Command/ArchiveCommandTest.php +++ b/test/PHPGit/Command/ArchiveCommandTest.php @@ -29,4 +29,17 @@ public function testArchive() $this->assertFileExists($this->directory . '/test.zip'); } + public function testRemoteArchive() + { + $git = new Git(); + $git->init($this->directory); + + # We expect to get github.com to throw an exception since it doesn't allow remote archives + $this->setExpectedException('PHPGit\Exception\GitException', "Invalid command: 'git-upload-archive '"); + $git->archive($this->directory . '/test_test.zip', 'master', null, array( + 'format' => 'zip', + 'remote' => 'ssh://git@github.com/kzykhys/PHPGit.git' + )); + } + } \ No newline at end of file