pull() public method

Fetch from and merge with another repository or a local branch.
public pull ( ) : GitWorkingCopy
return GitWorkingCopy
Esempio n. 1
0
 public function deploy()
 {
     // Create the wrapper.
     $wrapper = new GitWrapper();
     $wrapper->streamOutput();
     // Iterate through each project.
     foreach ($this->projects as $name => $project) {
         // Check out all branches.
         foreach ($project['branches'] as $branch => $destination) {
             // Build our git interface.
             $git = null;
             if (!is_dir($destination)) {
                 $git = $wrapper->cloneRepository($project['repo'], $destination);
             } else {
                 $git = new GitWorkingCopy($wrapper, $destination);
             }
             // Fetch the latest.
             $git->fetch('origin');
             // Checkout the desired branch.
             $git->checkout($branch, array('force' => true));
             // Reset any local changes.
             $git->reset(array('hard' => true));
             // Pull the latest from the branch.
             $git->pull('origin', $branch, array('force' => true));
         }
     }
 }
Esempio n. 2
0
 /**
  * Deploy a version to an environment.
  *
  * @param $version
  *   A git branch, tag, or sha.
  */
 public function deploy($version)
 {
     // Checkout the branch
     $wrapper = new GitWrapper();
     $wrapper->streamOutput();
     $git = new GitWorkingCopy($wrapper, $this->getSourcePath());
     $git->checkout($version);
     $git->pull();
     // Reload config so any changes get picked up.
     $this->reloadConfig();
     // Run the deploy hooks, if there are any.
     if (isset($this->config['hooks']['deploy']) && !empty($this->config['hooks']['deploy'])) {
         chdir($this->getSourcePath());
         $process = new Process($this->config['hooks']['deploy']);
         $process->run(function ($type, $buffer) {
             if (Process::ERR === $type) {
                 // Error
                 echo $buffer;
             } else {
                 // OK
                 echo $buffer;
             }
         });
     }
     // @TODO: Save the environment
     // @TODO: Create EnvironmentFactory->save();
     // Returning the branch for now. The command is saving the info.
     return $this->getRepo()->getCurrentBranch();
 }
Esempio n. 3
0
 /**
  * Deploy a version to an environment.
  *
  * @param $version
  *   A git branch, tag, or sha.
  */
 public function deploy($version)
 {
     // Checkout the branch
     $wrapper = new GitWrapper();
     $wrapper->streamOutput();
     $git = new GitWorkingCopy($wrapper, $this->getSourcePath());
     $git->checkout($version);
     $git->pull();
     // Reload config so any changes get picked up.
     $this->reloadConfig();
     // Run the deploy hooks
     chdir($this->getSourcePath());
     $process = new Process($this->config['hooks']['deploy']);
     $process->run(function ($type, $buffer) {
         if (Process::ERR === $type) {
             // Error
             echo $buffer;
         } else {
             // OK
             echo $buffer;
         }
     });
     // Save new branch to yml
     $this->director->config['apps'][$this->app]['environments'][$this->name]['git_ref'] = $this->getRepo()->getCurrentBranch();
     $this->director->saveData();
 }