Exemplo n.º 1
0
 /**
  * Initialize a new git repository.
  *
  * @param string $project_dir
  * @param string $remote_url
  * @return GitRepository
  * @throws GitException
  */
 public static function init($project_dir, $remote_url = null)
 {
     $fs = new Filesystem();
     $fs->mkdir($project_dir);
     $git = new Git($project_dir);
     $git->exec('init');
     $repo = new GitRepository($git);
     if (!is_null($remote_url)) {
         $repo->addRemote('origin', $remote_url);
         $repo->setUpstream();
         $repo->config['remotes'][] = ['url' => $remote_url, 'name' => 'origin'];
         $repo->initialized = true;
     }
     return $repo;
 }
Exemplo n.º 2
0
 /**
  * Initialize a new git repository.
  *
  * @param string $path
  * @param string $remote_url
  * @param \Shell\Output\ProcessOutputInterface $output
  * @return GitRepository
  * @throws GitException
  */
 public static function init($path, $remote_url = null, $output = null)
 {
     $fs = new Filesystem();
     if (!$fs->isAbsolutePath($path)) {
         throw new InvalidArgumentException('Path must be absolute.');
     }
     $fs->mkdir($path);
     $git = new Git($path);
     $git->exec('init');
     $repo = new GitRepository($git, $output);
     if (!is_null($remote_url)) {
         $repo->addRemote('origin', $remote_url);
         $repo->setUpstream();
         $repo->config['remotes'][] = ['url' => $remote_url, 'name' => 'origin'];
         $repo->initialized = true;
     }
     return $repo;
 }