public function createGitRepo(RepoEntity $repo)
 {
     $dir = $this->getRepoDir($repo);
     $this->filesystem->mkdirs($dir);
     $gitRepo = \phpGitRepo::create($dir);
     $gitRepo->git('remote add origin ' . $repo->getGitUrl());
     $gitRepo->git('pull origin master');
     return $gitRepo;
 }
Beispiel #2
0
 /**
  * Returns the git repository directory
  *
  * @return string
  */
 public function getDir()
 {
     return $this->gitRepo->getDir();
 }
try
{
  $repo = _createTmpGitRepo($t, array('git_executable' => '/usr/bin/git-foobar'));
  $repo->git('status');
  $t->fail('/usr/bin/git-foobar is not a valid git binary');
}
catch(RuntimeException $e)
{
  $t->pass('/usr/bin/git-foobar is not a valid git binary');
}

$repoDir = sys_get_temp_dir().'/php-git-repo/'.uniqid();
mkdir($repoDir);
try
{
  $repo = phpGitRepo::create($repoDir);
  $t->pass('Create a new Git repository in filesystem');
}
catch(InvalidArgumentException $e)
{
  $t->fail($e->getMessage());
}

$repo = _createTmpGitRepo($t);
file_put_contents($repo->getDir().'/README', 'No, finally, do not read me.');
$repo->git('add README');
$repo->git('commit -m "Add README"');
unlink($repo->getDir().'/README');
$repo->git('rm README');
$repo->git('commit -m "Remove README"');