示例#1
0
 /**
  * Process existing git configuration files. Files are read
  * from the system level to the local level, overwriting options
  * as we go.
  *
  * @return void
  */
 protected function processGitConfig()
 {
     $configs = ["/etc/gitconfig", realpath("~/.gitconfig"), "{$this->git->getProjectDirectory()}/.git/config"];
     foreach ($configs as $index => $file) {
         if (!is_file($file)) {
             continue;
         }
         if ($index === 2) {
             $this->initialized = true;
         }
         foreach (parse_ini_file($file, true) as $section => $values) {
             if (substr($section, 0, 6) === 'remote') {
                 $remote = substr($section, 7);
                 if (!isset($this->config['remotes'])) {
                     $this->config['remotes'] = [];
                 }
                 $this->config['remotes'][$remote] = ['name' => $remote, 'url' => $values['url']];
             } elseif (substr($section, 0, 6) === 'branch') {
                 $this->config['branches'][] = substr($section, 7);
             } elseif ($section === 'user') {
                 $this->config['user'] = $values;
             }
         }
     }
 }
示例#2
0
 public static function getGitInfo()
 {
     \LIB\lib_git::php();
     $result = array('git_project' => '', 'git_system' => '');
     try {
         $repo = \GIT\Git::open(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEPATH));
         $result['git_project'] = '<a href="http://www.mojotrollz.eu/git/hosting/commit/' . $repo->run('rev-parse HEAD') . '" target="_blank">' . $repo->run('rev-parse --short HEAD') . '</a><br/>';
         $result['git_project'] .= $repo->run('log -1 --pretty=%B');
     } catch (\Exception $ex) {
         $result['git_project'] = $ex->getMessage();
     }
     try {
         $repo = \GIT\Git::open(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEPATH) . \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_SYSTEMPATHREL));
         $result['git_system'] .= '<li>';
         $result['git_system'] = '<a href="http://www.mojotrollz.eu/git/system/commit/' . $repo->run('rev-parse HEAD') . '" target="_blank">' . $repo->run('rev-parse --short HEAD') . '</a><br/>';
         $result['git_system'] .= $repo->run('log -1 --pretty=%B');
     } catch (\Exception $ex) {
         $result['git_system'] = $ex->getMessage();
     }
     return $result;
 }