Exemple #1
0
 /**
  * Probe the repository to determine what branch we are currently on
  *
  * @param bool $silent Do not throw exceptions if something goes wrong
  * @throws GD_Exception
  * @return string|false Branch name or false if failed
  */
 public function getCurrentBranch($silent = false)
 {
     $this->runShell('git status');
     if ($this->_last_errno == 0) {
         if ($this->_last_output[0] == "# Not currently on any branch.") {
             if (!$silent) {
                 throw new GD_Exception("Git repository for {$this->_project->getName()} was not on a branch.", self::GIT_STATUS_ERROR_NOT_ON_BRANCH);
             } else {
                 return false;
             }
         } else {
             if (preg_match("/# On branch ([a-zA-Z0-9-.]*)/", $this->_last_output[0], $matches)) {
                 return $matches[1];
             } else {
                 if (!$silent) {
                     throw new GD_Exception("Unhandled error in getCurrentBranch", self::GIT_STATUS_ERROR_UNKNOWN);
                 } else {
                     return false;
                 }
             }
         }
     } else {
         if (!$silent) {
             throw new GD_Exception("Git status did not work.", self::GIT_STATUS_ERROR_UNKNOWN);
         } else {
             return false;
         }
     }
 }
Exemple #2
0
 public function isValid($value)
 {
     $this->_setValue($value);
     $git = GD_Git::FromProject($this->_project);
     try {
         if ($git->checkValidRepository()) {
             if ($git->gitCheckout($value)) {
                 return true;
             }
         }
         $this->_error(self::INVALID);
         return false;
     } catch (GD_Exception $ex) {
         GD_Debug::Log("Repository for {$this->_project->getName()} was not valid [{$ex->getStringCode()}]", GD_Debug::DEBUG_BASIC);
         $this->_error(self::NO_REPO);
         return false;
     }
 }
 /**
  * Should return an array of mapped fields to use in the MAL_Model_MapperAbstract::Save function
  * @param GD_Model_Project $obj
  */
 protected function getSaveData($obj)
 {
     $data = array('name' => $obj->getName(), 'slug' => $obj->getSlug(), 'repository_types_id' => $obj->getRepositoryTypesId(), 'repository_url' => $obj->getRepositoryUrl(), 'deployment_branch' => $obj->getDeploymentBranch(), 'ssh_keys_id' => $obj->getSSHKeysId());
     return $data;
 }