本文整理汇总了PHP中Git::open方法的典型用法代码示例。如果您正苦于以下问题:PHP Git::open方法的具体用法?PHP Git::open怎么用?PHP Git::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Git
的用法示例。
在下文中一共展示了Git::open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checklog
/**
* Check Log
*
* This function finds that last tag for the current release and shows you
* any changes between them
*
* @param The git module directory
* @return String of `git log` output
*/
function checklog($moddir)
{
$repo = Git::open($moddir);
$ltags = $repo->list_tags();
if ($ltags === false) {
return 'No Tags found!';
}
list($rawname, $ver, $supported) = freepbx::check_xml_file($moddir);
//Get current module version
preg_match('/(\\d*\\.\\d*)\\./i', $ver, $matches);
$rver = $matches[1];
//cycle through the tags and create a new array with relavant tags
$tagArray = array();
foreach ($ltags as $tag) {
if (preg_match('/release\\/(.*)/i', $tag, $matches)) {
if (strpos($matches[1], $rver) !== false) {
$tagArray[] = $matches[1];
}
}
}
if (!empty($tagArray)) {
usort($tagArray, "freepbx::version_compare_freepbx");
$htag = array_pop($tagArray);
$tagref = $repo->show_ref_tag($htag);
return $repo->log($tagref, 'HEAD');
}
return;
}
示例2: inspect
public static function inspect()
{
$repo = Git::open(ABSPATH);
if (is_object($repo) && $repo->test_git()) {
$status_data = $repo->run('status --porcelain');
$changed_files = array();
if (preg_match_all('/(^.+?)\\s(.*)$/m', $status_data, $changes, PREG_SET_ORDER)) {
foreach ($changes as $changed_item) {
$change = trim($changed_item[1]);
$file = trim($changed_item[2]);
$changed_files[$change][] = $file;
}
}
$routine_options = ACI_Routine_Handler::get_options(__CLASS__);
if (!is_array($routine_options)) {
$routine_options = array();
}
if (!is_array($routine_options['changed_files'])) {
$routine_options['changed_files'] = array();
}
if (empty($routine_options['ignore_files'])) {
$routine_options['ignore_files'] = self::$_default_ignore_files;
} else {
if (!is_array($routine_options['ignore_files'])) {
$routine_options['ignore_files'] = (array) $routine_options['ignore_files'];
}
}
foreach (array_keys($changed_files) as $change) {
foreach ($routine_options['ignore_files'] as $file_path) {
if (!empty($file_path)) {
$files_to_ignore = preg_grep('/^' . str_replace('\\*', '*', preg_quote($file_path, '/') . '/'), $changed_files[$change]);
if (is_array($files_to_ignore) && count($files_to_ignore) > 0) {
foreach (array_keys($files_to_ignore) as $ignore_file_key) {
unset($changed_files[$change][$ignore_file_key]);
}
}
}
}
if (count($changed_files[$change]) > 0) {
switch ($change) {
case 'A':
AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' NEW file(s).', __CLASS__);
break;
case 'M':
AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' MODIFIED file(s).', __CLASS__);
break;
case 'D':
AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' DELETED file(s).', __CLASS__);
break;
case '??':
AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' UNTRACKED file(s).', __CLASS__);
break;
}
}
}
$routine_options['changed_files'] = $changed_files;
ACI_Routine_Handler::set_options(__CLASS__, $routine_options);
}
}
示例3: getBranch
function getBranch()
{
try {
Git::set_bin(Settings::$git);
$repo = Git::open(dirname(__FILE__) . '/../../');
return $repo->active_branch();
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例4: update
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
}
示例5: generateGitBranchBlock
/**
* A custom method within the Plugin to generate the content
*
* @return string : HTML
*/
function generateGitBranchBlock()
{
$output = '';
$do_user_git = new UserGitrepo();
$git_repo = $do_user_git->CheckGitProjectExist($_SESSION["do_project"]->idproject);
if (is_array($git_repo)) {
include_once 'plugin/Git/class/Git.class.php';
$repo_path = "plugin/Git/repos/";
//$output .= '<br />';
$e_del_gitrepo = new Event("UserGitrepo->eventSelfDelProjectGitRepo");
$e_del_gitrepo->addParam("goto", "Project/" . $_SESSION["do_project"]->idproject);
$e_del_gitrepo->addParam("idgit_project", $git_repo["idgit_project"]);
$output .= '<div id="templt" class="co_worker_item co_worker_desc">';
$output .= '<div style="position: relative;">';
//$output .= '<b>Repository Name : '.$git_repo['git_repo'].'<br /></b>';
$idproject_task = (int) $_GET['idprojecttask'];
$repo_name = $git_repo['git_repo'];
$folder = "{$repo_path}" . "{$repo_name}";
if (is_dir($folder)) {
$repo = Git::open($folder);
$branch_name = $repo->branchlist($idproject_task);
$branch_name = split(' ', $branch_name);
//echo'<pre>';print_r($branch_name);echo'</pre>';
$size = sizeof($branch_name);
for ($i = 1; $i < $size; $i++) {
$branch_title = split('/', $branch_name[$i]);
//echo'<pre>';print_r($branch_title);echo'</pre>';
$b_size = sizeof($branch_title);
$b_name = split(' ', $branch_title[$b_size - 1]);
$br_name .= $b_name[0] . '<br />';
}
if (!empty($br_name)) {
$output .= _('Currently The Following Git branches are associated with this Task <br />');
//$output .= '<br />Branches assoicated with current task are :<br />';
$output .= '<b>' . $br_name . '</b>';
} else {
$output .= _('No Git branches found which are associated with this Task <br />');
}
} else {
$output .= _('Invalid Respository, Missing git repository in the plugin/Git/repos/' . $repo_name . ', Please check and try again <br />');
}
$output .= '</div></div>';
} else {
$output .= 'No Git Repository is associated with this Project Task';
}
return $output;
}
示例6: initRepo
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());
}
}
示例7: gitPanel
private function gitPanel($site)
{
$gitContentContainer = '';
// var_dump($site);
if ($site->git) {
$text = '<i class="fa fa-git"></i>';
$title = 'Git Controlled WP_Content';
$gitContentContainer = new html('div', array('class' => 'collapse ', 'id' => 'git_' . $site->name));
$innerContainer = new html('div', array('class' => 'options-tab'));
$repo = Git::open('../../' . $site->name . '/htdocs/wp-content');
// -or- Git::create('/path/to/repo')
// $status = $repo->status();
// Git Active Branch
$activeBranch = new html('code', array('text' => 'current branch: ' . $repo->active_branch(), 'class' => 'options-label git-branch'));
// Git Repo Controls
$repoControls = new html('div', array('class' => ''));
$pullBtn = new html('a', array('class' => 'btn git-pull btn-primary btn-sm', 'text' => 'Pull', 'disabled' => 'disabled', 'data-git-path' => '../../../' . $site->name . '/htdocs/wp-content'));
// $refreshBtn = new html('a', array(
// 'class' => 'btn btn-info btn-sm',
// 'text' => 'Refresh'
// ));
$repoControls->append($pullBtn);
// Git Commit Log
$commitLog = explode(PHP_EOL, $repo->run('log -6 --oneline'));
array_pop($commitLog);
$commitsHtml = new html('ul', array('class' => 'list-unstyled compact'));
foreach ($commitLog as $key => $logEntry) {
$entry = new html('li', array('text' => $logEntry, 'class' => 'compact'));
$commitsHtml->append($entry);
}
// $repo->add('.');
// $repo->commit('Some commit message');
// $repo->push('origin', 'master');
// Add Elements to Git HTML Container
$innerContainer->append($activeBranch)->append($repoControls)->append($commitsHtml);
$gitContentContainer->append($innerContainer);
}
return $gitContentContainer;
}
示例8: GitRepo
<head>
<title>index</title>
</head>
<body>
<form action="<?php
$PHP_SELF;
?>
" method="POST">
<div class="status">
<?php
// check if repo exists
if (is_dir($repo_path)) {
// open local repo
$repo = Git::open($repo_path);
} else {
// clone remote repo
$repo = new GitRepo($repo_path, true, false);
$repo->clone_remote($source);
}
if (!empty($_POST['file_title'])) {
$f_title = trim($_POST['file_title']);
$f_desc = trim($_POST['file_description']);
$f_tags = trim($_POST['file_tags']);
$f_code = trim($_POST['file_code']);
// TITLE
// if title not end in .js make it end in .js
if (!preg_match('/.js$/', $f_title)) {
$f_title = $f_title . ".js";
}
示例9: refreshRepo
/**
* Refresh a local repo with changes from remote
*
* Updates from remote, it will attempt to stash your working changes first
*
* @param string $directory Location of repo
* @param string $remote The name of the remote origin
* @param string $final_branch The final branch to checkout after updating (null means whatever it was on before)
* @return bool
*/
public static function refreshRepo($directory, $remote = 'origin', $final_branch = null)
{
freepbx::outn("Attempting to open " . $directory . "...");
//Attempt to open the module as a git repo, bail if it's not a repo
try {
$repo = Git::open($directory);
freepbx::out("Done");
} catch (Exception $e) {
freepbx::out("Skipping");
return false;
}
$stash = $repo->add_stash();
if (!empty($stash)) {
freepbx::out("\tStashing Uncommited changes..Done");
}
freepbx::outn("\tRemoving unreachable object from the remote...");
$repo->prune($remote);
freepbx::out("Done");
freepbx::outn("\tCleaning Untracked Files...");
$repo->clean(true, true);
freepbx::out("Done");
freepbx::outn("\tFetching Changes...");
$repo->fetch();
freepbx::out("Done");
freepbx::outn("\tDetermine Active Branch...");
$activeb = $repo->active_branch();
freepbx::out($activeb);
$lbranches = $repo->list_branches();
$rbranches = $repo->list_remote_branches();
foreach ($rbranches as $k => &$rbranch) {
if (preg_match('/' . $remote . '\\/(.*)/i', $rbranch)) {
$rbranch = str_replace($remote . '/', '', $rbranch);
$rbranch_array[] = $rbranch;
}
}
array_unique($rbranch_array);
freepbx::out("\tUpdating Branches...");
$ubranches = array();
foreach ($lbranches as $branch) {
freepbx::outn("\t\tUpdating " . $branch . "...");
if (!in_array($branch, $rbranch_array)) {
//Delete branches that are not available on the remote, otherwise we end up throwing an exception
freepbx::out("Removing as it no longer exists on the remote");
$repo->delete_branch($branch, true);
continue;
}
$repo->checkout($branch);
$repo->pull($remote, $branch);
freepbx::out("Done");
$ubranches[] = $branch;
}
foreach ($rbranches as $branch) {
if (!in_array($branch, $ubranches)) {
freepbx::outn("\t\tChecking Out " . $branch . "...");
try {
$repo->checkout($branch);
freepbx::out("Done");
} catch (Exception $e) {
freepbx::out("Branch Doesnt Exist...Skipping");
}
}
}
$lbranches = $repo->list_branches();
$branch = !empty($final_branch) && in_array($final_branch, $lbranches) ? $final_branch : $activeb;
freepbx::out("\tPutting you back on " . $branch . " ...");
$repo->checkout($branch);
freepbx::out("Done");
if (!empty($stash) && empty($final_branch)) {
freepbx::outn("\tRestoring Uncommited changes...");
try {
$repo->apply_stash();
$repo->drop_stash();
freepbx::out("Done");
} catch (Exception $e) {
freepbx::out("Failed to restore stash!, Please check your directory");
}
}
$repo->add_merge_driver();
}
示例10:
<?php
require_once 'git.php/Git.php';
$repo = Git::open('../');
// -or- Git::create('/path/to/repo')
$repo->pull('origin', 'master');
示例11: update
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();
}
示例12: exit
freepbx::switchBranch($dir, $options['switch']);
}
exit(0);
}
if (isset($options['refresh'])) {
foreach (glob($directory . "/*", GLOB_ONLYDIR) as $dir) {
freepbx::refreshRepo($dir);
}
exit(0);
}
if (isset($options['addmergedriver'])) {
foreach (glob($directory . "/*", GLOB_ONLYDIR) as $dir) {
freepbx::outn("Attempting to open " . $dir . "...");
//Attempt to open the module as a git repo, bail if it's not a repo
try {
$repo = Git::open($dir);
freepbx::out("Done");
} catch (Exception $e) {
freepbx::out("Skipping");
continue;
}
$gitatts = $repo->add_merge_driver();
if (!empty($gitatts)) {
file_put_contents($dir . '/.gitattributes', $gitatts);
}
}
exit(0);
}
if (isset($options['setup'])) {
if (is_link($directory)) {
freepbx::out("Confused. {$directory} is a symbolic link. Please resolve then run this again");
示例13: foreach
foreach (glob($langRepoPath . '/pot/*.pot') as $pot) {
$fileinfo = pathinfo($pot);
$module = $fileinfo['filename'];
if ($fileinfo['filename'] != 'amp') {
$moduleDirectory = $directory . "/" . $module;
$langDirectory = $moduleDirectory . "/i18n";
} else {
//framework is different
$moduleDirectory = $directory . "/framework";
$langDirectory = $moduleDirectory . "/amp_conf/htdocs/admin/i18n";
}
if (file_exists($moduleDirectory)) {
freepbx::outn('Opening ' . $module . '...');
freepbx::refreshRepo($moduleDirectory);
try {
$repo = Git::open($moduleDirectory);
freepbx::out("Done");
$ab = $repo->active_branch();
$repo->checkout("master");
} catch (Exception $e) {
freepbx::out("Skipping");
continue;
}
if (!file_exists($langDirectory)) {
freepbx::out('WARNING: Creating Missing i18n folder in ' . $module, 1);
mkdir($langDirectory, 0777, true);
}
foreach (glob($langRepoPath . '/po/*', GLOB_ONLYDIR) as $langpath) {
$lang = basename($langpath);
if (file_exists($langpath . "/" . $module . ".po")) {
$author = $langrepo->get_last_author("po/" . $lang . "/" . $module . ".po");
示例14:
<?php
if (isset($_GET['commithash'])) {
$commithash = $_GET['commithash'];
$repo_name = $_GET['repo_name'];
$repo_folder = 'plugin/Git/repos/' . $repo_name . '';
if (is_dir($repo_folder)) {
include_once 'class/Git.class.php';
$repo = Git::open($repo_folder);
$commitlog = $repo->commitdetails($commithash);
echo $commitlog;
} else {
echo 'Invalid Repository Please try again. ';
}
} else {
echo 'Invalid Option Please try again. ';
}
示例15: UserGitrepo
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
include_once 'config.php';
include_once 'plugin/Git/class/UserGitrepo.class.php';
include_once 'plugin/Git/class/Git.class.php';
$do_usergit = new UserGitrepo();
$do_usergit->getAll();
$rows = $do_usergit->getNumRows();
$repo_path = "plugin/Git/repos/";
$commitlog = array();
while ($do_usergit->fetch()) {
$repo_name = $do_usergit->getData('git_repo');
$folder = "{$repo_path}" . "{$repo_name}";
if (is_dir($folder)) {
$repo = Git::open($folder);
echo '<pre>';
print_r($repo->log());
echo '</pre>';
$commitlog = $repo->log();
$commit_log = split('\\^', $commitlog);
foreach ($commit_log as $commits) {
if (!empty($commits)) {
$commit_hash = split(";", $commits);
$user = split("--", $commit_hash[1]);
$user_email = $user[0];
$user_email = trim($user_email);
$date = split(":", $user[1]);
$date_log = $date[0];
$note = $date[1];
$task_ids = '';