Esempio n. 1
0
 /**
  * @param Package $package
  * @return array
  */
 public function transform(Package $package)
 {
     list($vendor, $name) = $this->splitVendorAndName($package->getName());
     $this->diskFactory->disk('local')->makeDirectory('storage/modules/' . $package->getName());
     if ($this->diskFactory->disk('local')->allDirectories('storage/modules/' . $package->getName()) === []) {
         $this->git->clone($package->getRepository(), storage_path('modules/' . $package->getName()));
     }
     return ['vendor' => $vendor, 'name' => $name, 'excerpt' => $package->getDescription(), 'description' => $this->getReadmeFileFor($package), 'favourites' => $package->getFavers(), 'total_downloads' => $package->getDownloads()->getTotal(), 'monthly_downloads' => $package->getDownloads()->getMonthly(), 'daily_downloads' => $package->getDownloads()->getDaily()];
 }
Esempio n. 2
0
 public function testClone()
 {
     $git = new Git();
     $git->clone('https://github.com/kzykhys/Text.git', $this->directory);
     $git->setRepository($this->directory);
     $this->assertFileExists($this->directory . '/.git');
     $filesystem = new Filesystem();
     $filesystem->remove($this->directory);
     $git->setRepository('.');
     $git->clone('https://github.com/kzykhys/Text.git', $this->directory, array('shared' => true));
     $this->assertFileExists($this->directory . '/.git');
 }
Esempio n. 3
0
 public function testPush()
 {
     $filesystem = new Filesystem();
     $git = new Git();
     $git->init($this->directory, array('shared' => true, 'bare' => true));
     $git->clone('file://' . realpath($this->directory), $this->directory . '2');
     $git->setRepository($this->directory . '2');
     $filesystem->dumpFile($this->directory . '2/test.txt', 'foobar');
     $git->add('test.txt');
     $git->commit('test');
     $git->push('origin', 'master');
     $git->clone('file://' . realpath($this->directory), $this->directory . '3');
     $this->assertFileExists($this->directory . '3/test.txt');
     $filesystem->remove($this->directory . '2');
     $filesystem->remove($this->directory . '3');
 }
Esempio n. 4
0
 public function testSetBranchesAdd()
 {
     $git = new Git();
     $git->clone('https://github.com/kzykhys/Text.git', $this->directory);
     $git->setRepository($this->directory);
     $git->remote->branches->add('origin', array('gh-pages'));
 }
Esempio n. 5
0
 public function testRemote()
 {
     $git = new Git();
     $git->clone('https://github.com/kzykhys/Text.git', $this->directory);
     $git->setRepository($this->directory);
     $remotes = $git->remote();
     $this->assertEquals(array('origin' => array('fetch' => 'https://github.com/kzykhys/Text.git', 'push' => 'https://github.com/kzykhys/Text.git')), $remotes);
 }
Esempio n. 6
0
 public function testSetHeadRemote()
 {
     $git = new Git();
     $git->clone('https://github.com/kzykhys/Text.git', $this->directory);
     $git->setRepository($this->directory);
     $before = $git->branch(array('all' => true));
     $git->remote->head->delete('origin');
     $git->remote->head->remote('origin');
     $after = $git->branch(array('all' => true));
     $this->assertEquals($before, $after);
 }
Esempio n. 7
0
 public function testTrackingBranchStatus()
 {
     $filesystem = new Filesystem();
     $git = new Git();
     $git->clone('https://github.com/kzykhys/Text.git', $this->directory);
     $git->setRepository($this->directory);
     $filesystem->dumpFile($this->directory . '/test.txt', '1');
     $git->add('test.txt');
     $git->commit('test');
     $status = $git->status();
     $this->assertEquals('master', $status['branch']);
 }
Esempio n. 8
0
 public function testAllBranch()
 {
     $git = new Git();
     $git->clone('file://' . realpath($this->directory), $this->directory . '2');
     $git->setRepository($this->directory . '2');
     $branches = $git->branch(array('remotes' => true));
     $this->assertArrayHasKey('origin/master', $branches);
     $branches = $git->branch(array('all' => true));
     $this->assertArrayHasKey('master', $branches);
     $this->assertArrayHasKey('remotes/origin/master', $branches);
     $filesystem = new Filesystem();
     $filesystem->remove($this->directory . '2');
 }
Esempio n. 9
0
 public function testCloneWithGitCommandErrorsThrowsException()
 {
     $binary = '/usr/bin/git';
     $url = 'https://github.com/lshepstone/php-git.git';
     $path = $this->getMockRepoPath();
     $result = $this->getMockBuilder('\\PhpProc\\Result')->disableOriginalConstructor()->getMock();
     $result->expects($this->once())->method('hasErrors')->will($this->returnValue(true));
     $result->expects($this->once())->method('getStdErrContents')->will($this->returnValue(null));
     $process = $this->getMockBuilder('\\PhpProc\\Process')->disableOriginalConstructor()->getMock();
     $process->expects($this->once())->method('setCommand')->with($this->equalTo("{$binary} clone \"{$url}\" \"{$path}\""))->will($this->returnSelf());
     $process->expects($this->once())->method('execute')->will($this->returnValue($result));
     $git = new Git($binary, $process);
     $this->setExpectedException('\\PhpGit\\Exception\\RuntimeException');
     $git->clone($url, $path);
 }