public function __construct(array $options = array()) { $defaults = array('create' => false, 'initialise' => false, 'filepath' => nZEDb_ROOT); $options += $defaults; parent::__construct($options['filepath'], $options['create'], $options['initialise']); $this->branch = parent::active_branch(); }
public function __construct($name) { $basepath = dirname(__FILE__) . '/../'; $this->_repo_name = $name; $this->_repo_path = $basepath . $this->_repo_name; parent::__construct($this->_repo_path); }
/** * Create a new git repository * * Accepts a creation path, and, optionally, a source path * * @access public * @param string repository path * @param string directory to source * @return GitRepo */ public static function &create($repo_path, $source = null) { return GitRepo::create_new($repo_path, $source); }
/** * Clones a remote repo into a directory and then returns a GitRepo object * for the newly created local repo * * Accepts a creation path and a remote to clone from * * @access public * @param string repository path * @param string remote source * @return GitRepo **/ public static function &clone_remote($repo_path, $remote) { return GitRepo::create_new($repo_path, $remote, true); }
/** * Clones a remote repo into a directory and then returns a GitRepo object * for the newly created local repo * * Accepts a creation path and a remote to clone from * * @access public * @param string repository path * @param string remote source * @param string reference path * @return GitRepo **/ public static function &clone_remote($repo_path, $remote, $reference = null) { return GitRepo::create_new($repo_path, $remote, true, $reference); }
</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"; } // pull from origin $repo->run('pull'); // If file already exits warn and stop
echo substr($keyFiles[$minKey], 0, strrpos($keyFiles[$minKey], ".")); echo "许可证文件内容, 详细文本之间的差别请看下面:</p>\r\n <p><span style=\"background-color:#005500\"> </span>代表比标准文本增加的部分</p><p><span style=\"background-color:#990000\"> </span>代表比标准文本减少的部分</span></p>\r\n </div>\r\n <div id=\"originaldiv\">\r\n <div>您的许可证比较结果</div>\r\n <div id=\"originalcontent\"><pre>"; echo $comparedStandardLicenseFileContent; echo "</pre></div>\r\n </div>\r\n <div id=\"standarddiv\">\r\n <div>"; echo substr($keyFiles[$minKey], 0, strrpos($keyFiles[$minKey], ".")); echo "</div>\r\n <div id=\"standardcontent\"><pre>"; echo htmlspecialchars($licensecollection[$keyFiles[$minKey]]); echo "</pre></div>\r\n <div class=\"contact-us\">如果对检测结果有任何意见和反馈, 您可以<a href=\"http://www.kaiyuanshe.cn/feedback.php\">联系我们</a></div>\r\n <div class=\"page-jump\">\r\n <input type=\"button\" value=\"完成\" class=\"resolver-next\" data-redirect=\"/index.php\">\r\n </div>\r\n </div>\r\n </div>"; RemoveStatusRecords($sessionId, $conn, $logger, $loghelperArr); } } else { $logger->log('debug', 'License file not found', $loghelperArr); InsertStatusRecords($sessionId, "快速检测未找到许可文件,正在克隆代码仓库副本以便进一步检测", $conn, $logger, $loghelperArr); // Git clone the repository based on git URL Git::windows_mode(); $repo = new GitRepo(); // Get git client folder name $comresult = stripos($urlText, '.git'); if ($comresult !== FALSE) { $indexOfLastSplash = strrpos($urlText, "/"); $indexOfLastDot = strrpos($urlText, '.'); $GitName = substr($urlText, $indexOfLastSplash + 1, $indexOfLastDot - $indexOfLastSplash - 1); } else { $indexOfLastSplash = strrpos($urlText, '/'); $GitName = substr($urlText, $indexOfLastSplash + 1); } $logger->log('debug', 'GitName: ' . $GitName, $loghelperArr); $ran = rand(); $timeparts = explode(' ', microtime()); $etime = $timeparts[1] . substr($timeparts[0], 1); $tempName = $ran . $timeparts[1];
/** * Clones a remote repo into a directory and then returns a GitRepo object * for the newly created local repo * * Accepts a creation path and a remote to clone from * * @access public * @param string $repoPath repository path * @param string $remote remote source * @param string $reference reference path * @return GitRepo **/ public static function cloneRemote($repoPath, $remote, $reference = null) { return GitRepo::create($repoPath, $remote, true, $reference); }
* * The Git.php test suite * * @package Git.php * @version 0.1.1-a * @author James Brumond * @copyright Copyright 2010 James Brumond * @license http://github.com/kbjr/Git.php * @link http://code.kbjrweb.com/project/gitphp */ define("DIR", dirname(__FILE__)); // include the git library require DIR . "/../Git.php"; $Git_Tests = array('Git' => function () { $return = null; $repo = new GitRepo(); $found = $repo->test_git(); if ($found) { $return = array(0, "Git was located and tested successfully"); } else { $return = array(1, "Git could not be found at the default location"); } return $return; }, 'Git::create()' => function () { $return = null; $repo = Git::create(DIR . "/create"); if (!Git::is_repo($repo)) { $return = array(2, "Git::create() failed to produce expected output."); } else { $return = array(0, "Git::create() executed successfully"); }
/** * Deletes temporary "base" repo * * @param GitRepo $repo * @param string $repo */ function cleanup($repo, $mainline) { $repo->removeRemote($mainline); }