run() public méthode

Runs a Git command and captures the output.
See also: GitWrapper::run()
public run ( array $args, boolean $setDirectory = true ) : GitWorkingCopy
$args array The arguments passed to the command method.
$setDirectory boolean Set the working directory, defaults to true.
Résultat GitWorkingCopy
 /**
  * Pushes the deployment build to the temporary git repository.
  */
 public function main()
 {
     // Check if all required properties are present.
     $this->checkRequiredProperties();
     // Add the remote for the starterkit if it doesn't exist yet.
     $remote_branch = 'remotes/' . $this->starterkitRemote . '/' . $this->starterkitBranch;
     $remote_exists = $this->subsiteRepository->hasRemote($this->starterkitRemote);
     if (!$remote_exists) {
         $this->log('Adding remote repository.');
         // Only track the given branch, and don't download any tags.
         $options = ['--no-tags' => TRUE, '-t' => [$this->starterkitBranch]];
         $this->subsiteRepository->addRemote($this->starterkitRemote, $this->starterkitRepository, $options);
     }
     // Check if the tracking branch exists and create it if it doesn't.
     try {
         $this->subsiteRepository->run(array('rev-parse', $remote_branch));
     } catch (GitException $e) {
         $this->log('Adding tracking branch.');
         $this->subsiteRepository->remote('set-branches', '--add', $this->starterkitRemote, $this->starterkitBranch);
     }
     // Fetch the latest changes.
     $this->log('Fetching latest changes.');
     $this->subsiteRepository->fetch($this->starterkitRemote);
     // Check if the latest commit on the remote is merged into the current
     // branch.
     $this->subsiteRepository->clearOutput();
     $latest_commit = (string) $this->subsiteRepository->run(array('rev-parse', $remote_branch));
     $merge_base = (string) $this->subsiteRepository->run(array('merge-base @ ' . $remote_branch));
     // If the latest commit on the remote is not merged into the current branch,
     // the repository is not up-to-date.
     if ($merge_base !== $latest_commit) {
         throw new \BuildException('The current branch is not up to date with the starterkit.');
     }
     $this->log('The starterkit is up to date.');
 }
 protected function assertNoRemoteMaster(GitWorkingCopy $repository)
 {
     try {
         $repository->run(array('rev-parse remote/HEAD'));
     } catch (GitException $e) {
         // Expected result. The remote master does not exist.
         return;
     }
     throw new \Exception("Expecting that the remote master doesn't exist, but it does.");
 }
Exemple #3
0
 /**
  * Returns currently active branch (HEAD) of the working copy.
  *
  * @return string
  */
 public function head()
 {
     return trim((string) $this->git->run(array('rev-parse --abbrev-ref HEAD')));
 }
 /**
  * Get an array of all files in the current repo
  *
  * @return array
  */
 protected function getAllFiles()
 {
     $files = $this->repository->run(['ls-files', '--full-name'])->getOutput();
     return array_map('trim', explode("\n", $files));
 }