private function initRepo()
 {
     //get path to the repo root (by default DokuWiki's savedir)
     if (defined('DOKU_FARM')) {
         $repoPath = $this->getConf('repoPath');
     } else {
         $repoPath = DOKU_INC . $this->getConf('repoPath');
     }
     //set the path to the git binary
     $gitPath = trim($this->getConf('gitPath'));
     if ($gitPath !== '') {
         Git::set_bin($gitPath);
     }
     //init the repo and create a new one if it is not present
     io_mkdir_p($repoPath);
     $repo = new GitRepo($repoPath, true, true);
     //set git working directory (by default DokuWiki's savedir)
     $repoWorkDir = DOKU_INC . $this->getConf('repoWorkDir');
     Git::set_bin(Git::get_bin() . ' --work-tree ' . escapeshellarg($repoWorkDir));
     $params = str_replace(array('%mail%', '%user%'), array($this->getAuthorMail(), $this->getAuthor()), $this->getConf('addParams'));
     if ($params) {
         Git::set_bin(Git::get_bin() . ' ' . $params);
     }
     return $repo;
 }
Пример #2
0
function getBranch()
{
    try {
        Git::set_bin(Settings::$git);
        $repo = Git::open(dirname(__FILE__) . '/../../');
        return $repo->active_branch();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
Пример #3
0
 function update($dynamic_model_update = true)
 {
     if ($this->git_path == null) {
         throw $this->exception('public variable git_path must be defined in page class');
     }
     $class = get_class($this);
     preg_match('/page_(.*)_page_(.*)/', $class, $match);
     $this->component_namespace = $match[1];
     $mp = $this->add('Model_MarketPlace')->loadBy('namespace', $this->component_namespace);
     $this->component_name = $mp['name'];
     $component_path = getcwd() . DS . 'epan-components' . DS . $this->component_namespace;
     if ($_GET['git_exec_path']) {
         Git::set_bin($_GET['git_exec_path']);
     }
     try {
         if (file_exists($component_path . DS . '.git')) {
             $repo = Git::open($component_path);
         } else {
             $repo = Git::create($component_path);
         }
     } catch (Exception $e) {
         // No Git Found ... So just return
         return;
     }
     $remote_branches = $repo->list_remote_branches();
     if (count($remote_branches) == 0) {
         $repo->add_remote_address($this->git_path);
     }
     $branch = 'master';
     if ($_GET['git_branch']) {
         $branch = $_GET['git_branch'];
     }
     $repo->run('fetch --all');
     $repo->run('reset --hard origin/' . $branch);
     if ($dynamic_model_update) {
         $dir = $component_path . DS . 'lib' . DS . 'Model';
         if (file_exists($dir)) {
             $lst = scandir($dir);
             array_shift($lst);
             array_shift($lst);
             foreach ($lst as $item) {
                 $model = $this->add($this->component_namespace . '/Model_' . str_replace(".php", '', $item));
                 $model->add('dynamic_model/Controller_AutoCreator');
                 $model->tryLoadAny();
             }
         }
     }
     // Re process Config file
     $this->add('Model_MarketPlace')->loadBy('namespace', $this->component_namespace)->reProcessConfig();
     // Get new code from git
     // Get all models in lib/Model
     // add dynamic line on object
     // tryLoanAny
 }
 private function initRepo()
 {
     if (!class_exists("Git")) {
         require 'Git.php/Git.php';
     }
     $this->pullOnChange = c::get('gcapc-pull', false);
     $this->pushOnChange = c::get('gcapc-push', false);
     $this->commitOnChange = c::get('gcapc-commit', false);
     $this->gitBin = c::get('gcapc-gitBin', '');
     $this->windowsMode = c::get('gcapc-windowsMode', false);
     if ($this->windowsMode) {
         Git::windows_mode();
     }
     if ($this->gitBin) {
         Git::set_bin($this->gitBin);
     }
     $this->repo = Git::open($this->repoPath);
     if (!$this->repo->test_git()) {
         trigger_error('git could not be found or is not working properly. ' . Git::get_bin());
     }
 }
Пример #5
0
function gitpush($strRepo)
{
    global $repo_dir, $eqdkp_dir, $git_path, $isWindows;
    try {
        if ($isWindows) {
            Git::windows_mode();
        }
        Git::set_bin($git_path);
        $repoPath = $strRepo == 'local_core' ? $eqdkp_dir : $repo_dir . $strRepo;
        $repo = Git::open($repoPath);
        notify($repo->status(true), 'Git Status before push');
        $repo->push('origin', 'master');
        notify($repo->status(true), 'Git Status after push');
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
Пример #6
0
 /**
  * Constructor
  *
  * Accepts a repository path
  *
  * @access  public
  * @param   string  repository path
  * @param   bool    create if not exists?
  * @return  void
  */
 public function __construct($repo_path = null, $create_new = false, $_init = true)
 {
     if (is_string($repo_path)) {
         $this->set_repo_path($repo_path, $create_new, $_init);
     }
     if (file_exists('/usr/local/bin/git')) {
         Git::set_bin('/usr/local/bin/git');
     } elseif (file_exists('/usr/bin/git')) {
         Git::set_bin('/usr/bin/git');
     } else {
         Git::set_bin('git');
     }
 }
Пример #7
0
<?php

session_start();
require_once '../settings.php';
require_once 'Git.php';
try {
    Git::set_bin(Settings::$git);
    $repo = Git::open(dirname(__FILE__) . '/../../');
    $branches = $repo->list_branches();
} catch (Exception $e) {
    $error = "Error connecting to the local git repo <b>highcharts.com</b>. Make sure git is running.<br/><br>" . $e->getMessage();
}
if (@$_POST['branch']) {
    try {
        // Post to session
        $_SESSION['branch'] = @$_POST['branch'];
        $_SESSION['after'] = @$_POST['after'];
        $_SESSION['before'] = @$_POST['before'];
        // Prepare command
        $cmd = 'log > ' . sys_get_temp_dir() . '/log.txt --format="%h|%ci|%s|%p" ';
        // Date
        if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $_SESSION['after'])) {
            $cmd .= '--after={' . $_SESSION['after'] . '} --before={' . @$_SESSION['before'] . '}';
            // Tag or commit
        } else {
            $cmd .= '' . $_SESSION['after'] . '..' . (isset($_SESSION['before']) ? $_SESSION['before'] : 'HEAD');
        }
        // Repo
        $activeBranch = $repo->active_branch();
        $repo->checkout($_SESSION['branch']);
        $repo->run($cmd);
Пример #8
0
<?php

require dirname(__FILE__) . '/config.php';
require dirname(__FILE__) . '/php-git/Git.php';
Git::set_bin($pathToGitBinary);
$repo = Git::open($repositoryPath);
if ($repo->test_git() === false) {
    throw new Exception('Git is not installed in "' . $pathToGitBinary . '". Please update the path in config.php');
}
$log = $repo->log("%H - %ad: %s");
$log = preg_split('/$\\R?^/m', $log);
$i = 0;
foreach ($log as $line) {
    //902a2a161048582a21fefddf2d4ac29461a64e57 - Tue Jun 25 17:52:42 2013 +0200: Workshop Daten vereinheitlicht
    if (preg_match('/([a-z0-9]{40}) - (.*?): (.*)/i', $line, $matches)) {
        $data[] = array('id' => $i++, 'hash' => $matches[1], 'date' => strtotime($matches[2]), 'message' => $matches[3]);
    } else {
        die('Could not parse line "' . $line . '"');
    }
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>Billing for <?php 
echo $repositoryPath;
?>
</title>

		<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
Пример #9
0
 function update($dynamic_model_update = true, $git_exec_path = null, $git_branch = 'master')
 {
     if ($this->git_path == null) {
         throw $this->exception('public variable git_path must be defined in page class');
     }
     $installation_path = getcwd();
     if ($git_exec_path) {
         Git::set_bin($git_exec_path);
     }
     if (file_exists($installation_path . DS . '.git')) {
         $repo = Git::open($installation_path);
     } else {
         $repo = Git::create($installation_path);
     }
     $remote_branches = $repo->list_remote_branches();
     if (count($remote_branches) == 0) {
         $repo->add_remote_address($this->git_path);
     }
     $repo->run('fetch --all');
     $repo->run('reset --hard origin/' . $git_branch);
     if ($dynamic_model_update) {
         $model = $this->add('Model_Branch');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Staff');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanCategory');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Epan');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanTemplates');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanPage');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanPageSnapshots');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_MarketPlace');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_InstalledComponents');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Tools');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Plugins');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Alerts');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Aliases');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Messages');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Users');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
     }
     // fire queries to convert superuser to 100 etc
     $this->query('UPDATE users SET type=IF(type="SuperUser",100,IF(type="BackEndUser",80,IF(type=100,100,50)))');
     // change users type to int
     $this->query('ALTER TABLE `users` CHANGE `type` `type` INT NULL DEFAULT NULL');
     // re Process base Element Config
     $base_element_market_place = $this->add('Model_MarketPlace')->loadBy('namespace', 'baseElements');
     $base_element_market_place->reProcessConfig();
 }
Пример #10
0
 /**
  * @return \GitRepo|bool
  */
 public function getGitRepository()
 {
     try {
         if (!$this->repository) {
             $gitPath = self::loadMODX()->getOption('gitify.git_path', null, '/usr/bin/git');
             if (!empty($gitPath)) {
                 \Git::set_bin($gitPath);
             }
             $repositoryPath = self::loadMODX()->getOption('gitify.repository_path', null, MODX_BASE_PATH, true);
             $this->repository = \Git::open($repositoryPath);
         }
     } catch (\Exception $e) {
         return $e->getMessage();
     }
     return $this->repository;
 }