function getGitLsFiles() { $history = array(); if (!gitIsAlive()) { return $history; } $files = array(); git('ls-files', $files); foreach ($files as $file) { $githist = getGitHistory($file, '-1'); foreach ($githist as $item) { unset($item['message']); array_push($history, $item); } } return $history; }
function getGitHistory($file = "") { $output = array(); // FIXME: Find a better way to find the files that changed than --name-only git("log --name-only --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- {$file}", $output); $history = array(); $historyItem = array(); foreach ($output as $line) { $logEntry = explode(">", $line, 6); if (sizeof($logEntry) > 1) { // Populate history structure $historyItem = array("author" => $logEntry[2], "email" => $logEntry[3], "linked-author" => $logEntry[3] == "" ? $logEntry[2] : "<a href=\"mailto:{$logEntry['3']}\">{$logEntry['2']}</a>", "date" => $logEntry[4], "message" => $logEntry[5], "commit" => $logEntry[0]); } else { if (!isset($historyItem["page"])) { $historyItem["page"] = $line; $history[] = $historyItem; } } } return $history; }
<!-- Download --> <section id="download" class="section"> <div class="container"> <h2 class="section-title">Download</h2> <p>There are three quick start ways to download Turret available:</p> <div class="row"> <div class="column-1-2 column-large-1-2 column-xlarge-1-3"> <p>Install with <a href="https://www.npmjs.com/package/bigfishtv-turret">npm</a></p> <?php bash('npm install bigfishtv-turret'); ?> </div> <div class="column-1-2 column-large-1-2 column-xlarge-1-3"> <p>Clone the repo from GitHub</p> <?php git('git clone https://github.com/bigfishtv/turret.git'); ?> </div> <div class="column-1-2 column-large-1-2 column-xlarge-1-3"> <p>Download the latest release</p> <a class="button button-primary" href="https://github.com/bigfishtv/turret/archive/master.zip">Download from Github</a> </div> </div> </div> </section> <!-- Structure --> <section id="structure" class="section"> <div class="container"> <h2 class="section-title">Structure</h2> <h3 class="section-block-title">Selectors</h3>
function git($command, &$output = "") { global $GIT, $DATA_DIR; $gitDir = dirname(__FILE__) . "/{$DATA_DIR}/.git"; $gitWorkTree = dirname(__FILE__) . "/{$DATA_DIR}"; // Workaround for git version < 1.7.7.2 (http://stackoverflow.com/a/9747584/2587532) $gitVersion = exec("git --version | awk '{print \$3}'"); if (version_compare($gitVersion, "1.7.7.2", "<") && preg_match("/^(pull)/", $command)) { $output = array(); // split "pull remote branch" into separat elements $elements = explode(" ", $command); // execute fetch command $command_part1 = "fetch " . $elements[1]; $result_part1 = git($command_part1, $output); // execute merge command $command_part2 = "merge " . $elements[1] . "/" . $elements[2]; $result_part2 = git($command_part2, $output); // check result if ($result_part1 == 1 && $result_part2 == 1) { return 1; } else { return 0; } } else { $gitCommand = "{$GIT} --git-dir={$gitDir} --work-tree={$gitWorkTree} {$command}"; } $output = array(); $result; // FIXME: Only do the escaping and the 2>&1 if we're not in safe mode // (otherwise it will be escaped anyway). // FIXME: Removed escapeShellCmd because it clashed with author. $oldUMask = umask(022); exec($gitCommand . " 2>&1", $output, $result); $umask = $oldUMask; // FIXME: The -1 is a hack to avoid 'commit' on an unchanged repo to // fail. if ($result != 0) { // FIXME: HTMLify these strings print "<h1>Error</h1>\n<pre>\n"; print "\$" . $gitCommand . "\n"; print join("\n", $output) . "\n"; //print "Error code: " . $result . "\n"; print "</pre>"; return 0; } return 1; }
die("[okapi-update] OKAPI working branch is dirty"); } $current_okapi_branch = git('rev-parse --abbrev-ref HEAD'); if ($current_okapi_branch != 'master') { echo "[okapi-update] checking out OKAPI master branch\n"; echo git('checkout master'); } $changes = git("log upstream/master..master"); if ($changes) { die("[okapi-update] there are unpushed local commits:\n" . $changes); } echo "[okapi-update] ok.\n"; // fetch current OKAPI revision echo "[okapi-update] pulling and replicating OKAPI master\n"; echo git('pull ' . OKAPI_REMOTE . ' master') . "\n"; $okapi_version_number = git('rev-list HEAD --count') + 318; $okapi_git_revision = git('rev-parse HEAD'); echo "OKAPI ver. {$okapi_version_number}\n"; echo "OKAPI rev. {$okapi_git_revision}\n"; // replicate OKAPI source code into OC code and inject version numbers passthru(str_replace('%source', OKAPI_SOURCE_PATH . '/okapi', str_replace('%dest', $opt['rootpath'] . '/okapi', DIRECTORY_TREE_REPLICATOR))); $core = file_get_contents($opt['rootpath'] . '/okapi/core.php'); $core = str_replace("\$version_number = null", "\$version_number = " . $okapi_version_number, str_replace("\$git_revision = null", "\$git_revision = '" . $okapi_git_revision . "'", $core)); file_put_contents($opt['rootpath'] . '/okapi/core.php', $core); chdir($opt['rootpath']); passthru("git status"); // commit changes to OC code echo "[okapi-update] committing to local OC Git repo\n"; echo git('add .') . "\n"; echo git('commit -m "OKAPI r' . $okapi_version_number . '"') . "\n";
search($cmd[1], $cmd[2]); }else{ error(4); } break;*/ case "/moo": moo(); break; case "/pull": git("pull github master"); break; case "/status": git("status"); break; case "/log": git('log --pretty=format:"%h - %an, %ar : %s"'); break; case "/burn": case "/燒毀": burn($dict); break; case "/keygen": keygen(); break; default: if (strpos($message, "@" . BOT_NAME)) { sendMsg("我沒這指令, 你想做什麼??"); } //error(3); break; }
// Save $handle = fopen($wikiFile, "w"); fputs($handle, stripslashes($_POST['data'])); fclose($handle); $commitMessage = addslashes("Changed {$wikiPage}"); $author = addslashes(getAuthorForUser(getUser())); if (!git("init")) { return; } if (!git("add {$wikiPage}")) { return; } if (!git("commit --allow-empty --no-verify --message='{$commitMessage}' --author='{$author}'")) { return; } if (!git("gc")) { return; } header("Location: " . getViewURL($wikiPage)); return; } } else { header("Content-Type: text/html;charset=utf-8"); // Global history if ($wikiPage == "history") { $wikiHistory = getGitHistory(); $wikiPage = ""; include getThemeDir() . "/history.php"; } else { if ($wikiSubPage == "view") { if (!file_exists($wikiFile)) {
public function makeBranch($branchName) { if($this->hasBranch($branchName)) { return true; } else { $output=$this-git(sprintf("checkout -b %s", $branchName)); if($output=="Switched to a new branch '".$branchName."'") { return true; } else { return false; } } }