Exemplo n.º 1
0
 /**
  * Clone a repository (clone is a reserved keyword).
  *
  * @param string $path
  * @param string $remote_url
  * @param null $repo
  * @param \Shell\Output\ProcessOutputInterface $output
  * @param bool $background
  * @return GitRepository|Process
  * @throws GitException
  */
 public static function copy($path, $remote_url, &$repo = null, $output = null, $background = false)
 {
     $fs = new Filesystem();
     if (!$fs->isAbsolutePath($path)) {
         throw new InvalidArgumentException('Path must be absolute.');
     }
     $fs->mkdir($path);
     $git = new Git($path);
     $repo = new GitRepository($git, $output);
     $args = [$remote_url, $path];
     if ($background) {
         $onSuccess = function () use(&$repo) {
             $repo->processGitConfig();
             $repo->setUpstream();
             $repo->initialized = true;
         };
         return $git->execNonBlocking('clone', $args, [], [], $onSuccess);
     } else {
         $git->exec('clone', $args, ['--verbose' => true]);
         $repo->processGitConfig();
         $repo->setUpstream();
         $repo->initialized = true;
         return $repo;
     }
 }
Exemplo n.º 2
0
 /**
  * Clone a repository (clone is a reserved keyword).
  *
  * @param string $project_dir
  * @param string $remote_url
  * @param null $repo
  * @param bool $background
  * @return GitRepository|Process
  * @throws GitException
  */
 public static function copy($project_dir, $remote_url, &$repo = null, $background = false)
 {
     $fs = new Filesystem();
     $fs->mkdir($project_dir);
     $git = new Git($project_dir);
     $repo = new GitRepository($git);
     $args = [$remote_url, $project_dir];
     if ($background) {
         $onSuccess = function () use(&$repo) {
             $repo->processGitConfig();
             $repo->setUpstream();
             $repo->initialized = true;
         };
         return $git->execNonBlocking('clone', $args, [], [], $onSuccess);
     } else {
         $git->exec('clone', $args);
         $repo->processGitConfig();
         $repo->setUpstream();
         $repo->initialized = true;
         return $repo;
     }
 }
Exemplo n.º 3
0
 public function test_open()
 {
     $repo = GitRepository::open('/Users/jacob/dev/tweetmon');
     $this->assertNotNull($repo);
 }
Exemplo n.º 4
0
 public function test_isCommit_notfound()
 {
     $sha = 'f80a9ff4857bb23cb734925d7496e89431ad5bcq';
     $repo = GitRepository::open(realpath(__DIR__ . '/../'), new \Shell\Output\OutputHandler());
     $exists = $repo->verifyCommitExists($sha);
     $this->assertFalse($exists);
 }