/**
  * Checks if the given repository has already been cloned to it's temporary cache directory.
  * If it is, the clone is updated by pulling in all changes from the source URL, otherwise
  * the source repository is cloned to the directory.
  *
  * @param \Mrimann\CoMo\Domain\Model\Repository $repository
  * @param $workingDirectory
  *
  * @return boolean returns TRUE if preparation was successful, FALSE otherwise
  */
 protected function prepareCachedClone(\Mrimann\CoMo\Domain\Model\Repository $repository, $workingDirectory)
 {
     // If working directory does not exist, create it by cloning repository into it
     // and then change into that directory
     if (!is_dir($workingDirectory . '/.git')) {
         $this->outputLine($workingDirectory);
         chdir($workingDirectory);
         $this->outputLine('Created directory, going to clone now...');
         $cloneResult = '';
         exec('git clone ' . $repository->getUrl() . ' .', $foo, $cloneResult);
         if ($cloneResult > 0) {
             $this->outputLine('Oops, something went wrong while cloning...');
             $result = FALSE;
         } else {
             $this->outputLine('Finished cloning from ' . $repository->getUrl());
             $result = TRUE;
         }
     } else {
         chdir($workingDirectory);
         // If there's a clone alredy, just pull the latest changes from the origin
         $this->outputLine('going to pull changes from remote repo...');
         $pullResult = '';
         exec('git pull', $unusedOutput, $pullResult);
         if ($pullResult > 0) {
             $this->outputLine('Oops, something went wrong while pulling the repository...');
             $result = FALSE;
         } else {
             $this->outputLine('finished pulling changes.');
             $result = TRUE;
         }
     }
     return $result;
 }
Пример #2
0
 /**
  * @test
  */
 public function setUrlSetsUrl()
 {
     $this->fixture->setUrl('http://foo/bar.git');
     $this->assertEquals('http://foo/bar.git', $this->fixture->getUrl());
 }