init() public method

Create an empty git repository or reinitialize an existing one.
public init ( array $options = [] ) : GitWorkingCopy
$options array (optional) An associative array of command line options.
return GitWorkingCopy
Esempio n. 1
0
 /**
  * Set up the git repository for our build.
  *
  * @param GitWorkingCopy $workingCopy
  * @param string $url
  * @param string $branch
  * @return mixed
  */
 protected function doGitInit(GitWorkingCopy $workingCopy, $url, $branch)
 {
     $workingCopy->init();
     $workingCopy->remote('add', 'origin', $url);
     try {
         $this->output->writeln("Attempting to fetch <path>origin/{$branch}</path>", OutputInterface::VERBOSITY_VERBOSE);
         $workingCopy->fetch('origin', $branch)->checkout('-f', $branch);
     } catch (GitException $exception) {
         $this->output->writeln("Fetch failed, creating new branch instead", OutputInterface::VERBOSITY_VERBOSE);
         $workingCopy->checkout('--orphan', $branch)->run(['commit', '--allow-empty', '-m', "Branch created by steak"])->push('-u', 'origin', $branch);
     }
     return $workingCopy->clearOutput();
 }