/** * Parse the response of a git-log command. * * @param Repository $repository The project repository * @param string $output * @return array<Commit> */ public static function parse(Repository $repository, $output) { $commits = array(); if (!empty($output)) { foreach (explode("\n", $output) as $line) { $commit = new Commit($repository, 'HEAD'); $commit->init($line); $commits[$commit->getHash()] = $commit; } } return $commits; }
public function forumIdWrite($id) { $json = Input::get('json'); $data = json_decode($json); $writer = Student::where('auth', '=', $data->auth)->first(); $sn = Topic::max('sn') + 1; $body = base64_decode($data->body); $topics = Topic::find($id); $topics->sn = $sn; $topics->save(); $commit = new Commit(); $commit->stu_id = $writer->id; $commit->topic_id = $id; $commit->body = $body; $commit->day = date("Y/m/d"); $commit->save(); return "suc"; }
/** * Browse repository * * @param null * @return void */ function browse() { if ($this->active_repository->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_repository->canView($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->active_commit->isNew()) { $this->active_commit = $this->active_repository->getLastCommit(); if (instance_of($this->active_commit, 'Commit')) { $this->active_revision = $this->active_commit->getRevision(); } else { flash_error('This repository is not updated yet. You need to update it first before you can browse it.'); $this->redirectToReferer($this->active_repository->getViewUrl()); } // if } // if $peg_revision = $this->request->get('peg'); // wireframe stuff $this->wireframe->addPageAction(lang('Change Revision'), '#', null, array('id' => 'change_revision')); $this->wireframe->addPageAction(lang('Commit History'), $this->active_repository->getHistoryUrl()); // path info $path_info = $this->repository_engine->getInfo($this->active_file, $this->active_revision, false, $peg_revision); // file source $file_source = file_source_can_be_displayed($path_info['path']) ? $this->repository_engine->cat($this->active_revision, $this->active_file, $peg_revision) : false; $file_path_info = pathinfo($this->active_file); $parent_directory = array_var($file_path_info, 'dirname', ''); $latest_revision = $path_info['revision']; $file_latest_revision = Commits::findByRevision($latest_revision, $this->active_repository); if (!instance_of($file_latest_revision, 'Commit')) { $file_latest_revision = $this->active_commit; } // if // check if path is directory or file if ($path_info['type'] == 'directory') { /**** DIRECTORY ****/ $this->smarty->assign(array('list' => $this->repository_engine->browse($this->active_revision, $this->active_file, $peg_revision), 'parent_directory' => $parent_directory == "/" ? "" : $parent_directory, 'can_go_up' => array_var($file_path_info, 'basename') !== '')); // custom template $this->setTemplate(array('module' => SOURCE_MODULE, 'controller' => $this->controller_name, 'template' => 'browse_directory')); } else { /**** FILE ****/ $this->smarty->assign(array('lines' => implode("\n", range(1, count($file_source))), 'source' => $file_source !== false ? implode("\n", $file_source) : $file_source)); // custom template $this->setTemplate(array('module' => SOURCE_MODULE, 'controller' => $this->controller_name, 'template' => 'browse_file')); js_assign('compare_url', $this->active_repository->getFileCompareUrl($this->active_commit, $this->active_file, $this->request->get('peg'))); } // if js_assign('browse_url', $this->active_repository->getBrowseUrl(null, $this->active_file, $this->request->get('peg'))); // general template vars for both directory and file $this->smarty->assign(array('navigation' => $this->repository_engine->linkify($this->active_revision, $this->active_file), 'latest_revision' => $file_latest_revision, 'active_commit' => $this->active_commit, 'active_revision' => $this->active_revision)); }
public function actionIndex() { //commits from github $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://api.github.com/repos/nodejs/node-v0.x-archive/commits?per_page=25&page=1"); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); $cont = curl_exec($curl); $commits = json_decode($cont); curl_close($curl); //echo count($commits); //die; //add to database foreach ($commits as $item) { $commit = new Commit(); $commit->sha = $item->sha; $commit->url = $item->html_url; $commit->committer = $item->author->login; $commit->save(); } $criteria = new CDbCriteria(); //$criteria->addCondition('status=1'); //counts $count = Commit::model()->count($criteria); $pages = new CPagination($count); $pageSize = isset(Yii::app()->params['commitsPerPage']) ? Yii::app()->params['commitsPerPage'] : 25; $pages->pageSize = $pageSize; $pages->applyLimit($criteria); //sorting $sort = new CSort('Commit'); $sort->defaultOrder = array('committer' => CSort::SORT_ASC); $sort->attributes = array('id' => array('asc' => "id", 'desc' => "id DESC"), 'sha' => array('asc' => "sha", 'desc' => "sha DESC"), 'committer' => array('asc' => "committer", 'desc' => "committer DESC")); $sort->applyOrder($criteria); $items = Commit::model()->findAll($criteria); $this->render('index', array('items' => $items, 'pages' => $pages, 'sort' => $sort, 'commits' => $commits)); }
/** * @return array */ public function toGitHubApiDataArray() { $data = array('body' => $this->body); if (TRUE === $this->commit instanceof Commit) { if (NULL !== $this->path) { $data['commit_id'] = $this->commit->getId(); $data['path'] = $this->path; $data['position'] = $this->position; } } elseif (TRUE === $this->pullRequest instanceof PullRequest) { $data['sha1'] = $this->pullRequest->getId(); } return $data; }
/** * Retrieves the commits since the given revision and populates a set of Commit Models. * * By default the commit models are not saved unless the $save parameter is set to true. * * @param mixed $since the revision where to start retrieving objects * @param boolean $save * * @return array of Commit objects */ public function getCommits($since = null, $save = false) { // first, load the most recent version $this->pull(); // retrieve commits if (!is_null($since)) { $parameters = array($since . '..'); } else { $parameters = array(); } $cwd = getcwd(); chdir($this->getLocalRepoPath()); $content = $this->execute('log', $parameters, array('raw' => '')); chdir($cwd); $changes = $this->parseGitLogRawOutput($content); // generate commit objects with changes $commits = array(); foreach ($changes as $revision => $change) { $commit = new Commit(); $commit->setRevision($revision); $commit->setScmId($this->getScm()->getId()); $commit->setAuthor($change['author']); $commit->setTimestamp(date("Y-m-d H:i:s", strtotime($change['timestamp']))); $commit->setMessage($change['message']); foreach ($change['filechanges'] as $path => $action) { $change = new FileChange(); $change->setCommit($commit); $change->setFilePath($path); switch ($action) { case 'A': $change->setFileChangeTypeId(1); break; case 'M': $change->setFileChangeTypeId(2); break; case 'D': $change->setFileChangeTypeId(3); break; default: $change->setFileChangeTypeId(4); break; } $commit->getFileChange()->add($change); } if ($save) { $commit->save(); } echo '.'; $commits[] = $commit; } return $commits; }
/** * Commit item send * * @param itemId - required - * The item id. * @param sendEmailNotifications - optional - * If true, an email notification is sent to the sender and the recipients. * If false, no email is sent. * @param expiration - optional - * The expiration duration in minutes. * A value of 0 indicates that the item never expires. * @return The Commit object containing the download URL (link to the download page) * or the error code and message returned by the server. * */ public function commitSend($itemId, $sendEmailNotifications = '', $expiration = '') { $parameters = array(); $urld = 'dpi/v1/item/commit/' . $itemId; if ($expiration !== '') { $parameters['expiration'] = $expiration; } if ($sendEmailNotifications !== '') { $parameters['sendEmailNotifications'] = $sendEmailNotifications; } $this->response = $this->_restTransportInstance->sendRequest($urld, $parameters, 'POST', $this->_authToken); $responseBody = simplexml_load_string($this->response); $returnObject = new Commit(); if ($responseBody === false) { $errorCode = 'N/A'; $errorMessage = 'The server has encountered an error, please try again.'; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } else { if (empty($responseBody->errorStatus)) { $downloadUrl = (string) $responseBody->downloadUrl; $returnObject->setDownloadUrl($downloadUrl); } else { $errorCode = (string) $responseBody->errorStatus->code; $errorMessage = (string) $responseBody->errorStatus->message; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } } return $returnObject; }
<?php # # $Id: categories.php,v 1.2 2006-12-17 12:06:08 dan Exp $ # # Copyright (c) 1998-2006 DVL Software Limited # require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/common.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/freshports.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/user_tasks.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/commit.php'; $Commit = new Commit($db); $Commit->DateNewestPort(); freshports_ConditionalGet($Commit->last_modified); freshports_Start('Categories', 'freshports - new ports, applications', 'FreeBSD, index, applications, ports'); $Debug = 0; DEFINE('VIRTUAL', '<sup>*</sup>'); $Primary['t'] = ''; $Primary['f'] = VIRTUAL; $AllowedToEdit = $User->IsTaskAllowed(FRESHPORTS_TASKS_CATEGORY_VIRTUAL_DESCRIPTION_SET); if ($AllowedToEdit) { $ColSpan = 5; } else { $ColSpan = 4; } if ($User->id) { # obtain a list of the categories on this users watchlists require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/category-listing.php'; $CategoryListing = new Categories($db);
The short description is encoded as ISO-8859-15. The commit is encoded as UTF-8. <p> The short description is obtained from a "make -V COMMENT". <p> The commit messages arrives via an XML file encoded with ISO-8859-1. <h2>Test iconv output</h2> <?php $str = "Full-screen task manager similar to Exposé(tm)"; echo "<p>{$str}</p>\n"; echo "<p>" . iconv("ISO-8859-15", "UTF-8", $str) . "</p>\n"; echo "<p>" . htmlentities($str) . "</p>\n"; $str = "Antônio Carlos Venâncio Júnior"; echo "<p>{$str}</p>\n"; echo "<p>" . iconv("ISO-8859-1", "UTF-8", $str) . "</p>\n"; echo "<p>" . htmlentities($str) . "</p>\n"; $Commit = new Commit($db); $Commit->FetchByMessageId('*****@*****.**'); echo "<pre>{$Commit->commit_description}</pre>\n"; $Port = new Port($db); $Port->Fetch('deskutils', 'kompose'); echo "<pre>{$Port->short_description}</pre>\n"; echo "<pre>" . iconv("ISO-8859-15", "UTF-8", $Port->short_description) . "</pre>\n"; ?> The end </body> </head>
public function set(Commit $commit) { $this->setHash($commit->hashHash()); $this->setLabel($commit->getLabel()); $this->setComments($commit->getComments()); }
/** * Get log data * * @param integer $revision_to * @param mixed $revision_from * @return array */ function getLogs($revision_to, $revision_from = 'HEAD', $logs_per_query = 100) { // get multiple logs or a single one if (!is_null($revision_from)) { $r = $revision_from . ':' . $revision_to; } else { $r = $revision_to; $this->triggerred_by_handler = true; } // if $string = 'log -r ' . $r . ' --xml --verbose ' . $this->active_repository->getUrl(); $this->execute($string); $log_data = xml2array(implode("\n", $this->output), 1, array('path', 'logentry')); $insert_data = array(); $i = 1; // this is because we get commits from SVN sorted from newest to oldest $logs = is_array($log_data['log']['logentry']) ? array_reverse($log_data['log']['logentry']) : array(); // loop through array of log entries foreach ($logs as $key => $log_entry) { // prevent duplicate entries in case when there are two separate update processes // (like, both scheduled task and aC user triggered the update if (Commits::count("parent_id = '" . $this->active_repository->getId() . "' AND integer_field_1 = '" . $log_entry['attr']['revision'] . "'") > 0) { continue; } // if $paths = array(); $k = 0; foreach ($log_entry['paths']['path'] as $path) { $paths[$k]['path'] = mysql_real_escape_string($path['value']); // paths can contain file names with characters that can break the query $paths[$k]['action'] = $path['attr']['action']; $k++; } // foreach $date = new DateTimeValue($log_entry['date']['value']); $log_date = $date->getYear() . "-" . $date->getMonth() . '-' . $date->getDay() . ' ' . $date->getHour() . ':' . $date->getMinute() . ':' . $date->getSecond(); $commit_message = Commit::analyze_message($log_entry['msg']['value'], $log_entry['author']['value'], $log_entry['attr']['revision'], $this->active_repository, $this->active_project); $insert_data[$i][$key] = "('Commit','Source','" . $this->active_project->getId() . "','" . $this->active_repository->getId() . "','Repository','" . mysql_real_escape_string($commit_message) . "','" . $log_entry['attr']['revision'] . "','" . serialize($paths) . "','" . mysql_real_escape_string($log_entry['author']['value']) . "','{$log_date}', '" . STATE_VISIBLE . "', '" . $this->active_repository->getVisibility() . "')"; $i = count($insert_data[$i]) < $logs_per_query ? $i : $i + 1; } // foreach return array('data' => $insert_data, 'total' => count($logs)); }
public function notify(Commit $commit) { $this->register(); return $this->doNotify($commit->isSuccessful() ? 'Success' : 'Fail', $commit->getProject()->getName(), $this->format($this->format, $commit)); }
private function createCommit($project, $result) { $commit = new Commit($project, $result['sha']); $commit->setAuthor($result['author']); $commit->setMessage($result['message']); $commit->setDate(\DateTime::createFromFormat('Y-m-d H:i:s', $result['date'])); if ($result['build_date']) { $commit->setBuildDate(\DateTime::createFromFormat('Y-m-d H:i:s', $result['build_date'])); } $commit->setStatusCode($result['status']); $commit->setOutput($result['output']); return $commit; }
public function renderCommitHead(Commit $commit) { return $this->indent . '- [' . $commit->getHash() . '] ' . $commit->getLabel(); }
function FetchNth($N) { # # call Fetch first. # then call this function N times, where N is the number # returned by Fetch # if ($this->Debug) { echo "fetching row {$N}<br>"; } $commit = new Commit($this->dbh); $myrow = pg_fetch_array($this->LocalResult, $N); $commit->PopulateValues($myrow); return $commit; }
/** * Execute the job. * * @return void */ public function handle() { Commit::create(['body' => $request->input('body'), 'to_comment' => $request->input('to_comment'), 'user_name' => \Auth::user()->name, 'user_id' => \Auth::id()]); flash()->success('Dodałeś adnotację do komentarza!'); return redirect('/profile'); }
if (!isset($_GET['commitId'])) { die('Must specify a commit to view'); } if (!isset($_GET['file'])) { die('Must specify a filename'); } require_once 'config/Config.class.php'; require_once 'class/Commit.class.php'; // Library File include 'framework/lib/library.php'; $title = 'View File Change'; $subtitle = Config::get('siteName'); $commitId = $_GET['commitId']; $file = $_GET['file']; $repoId = $_GET['repoId']; $commit = new Commit($commitId); $data = $commit->getData(); $data['commitAuthor'] = htmlspecialchars($data['commitAuthor']); $diff = shell_exec("./getFileChange.pl {$repoId} '{$commitId}' '{$file}'"); $diff = nl2br(htmlspecialchars($diff)); $content = <<<EOT <div class="indent"> \t<h3 class="indent">{$data['commitMessage']}</h3> \t<table class="indent"> \t\t<tr> \t\t\t<td class="bold">Commit:</td> \t\t\t<td>{$data['commitVal']}</td> \t\t</tr> \t\t<tr> \t\t\t<td class="bold">Author:</td> \t\t\t<td>{$data['commitAuthor']}</td>
/** * Convert raw object into immutable Tag. * * @param string $body Raw body of the commit. * @param int $size Size of the body, optional. * @param string $hash SHA-1 hash of the full commit including header, optional. * @return Tag */ public static function fromRaw($body, $size = false, $hash = false) { list($headers, $message) = Commit::messageParser($body); return new self($headers['object'][0], $headers['type'][0], $headers['tag'][0], $headers['tagger'][0], $message, $size, $hash); }
protected function getPlaceholders(Commit $commit) { $project = $commit->getProject(); return array('%slug%' => $project->getSlug(), '%name%' => $project->getName(), '%status%' => $commit->getStatus(), '%status_code%' => $commit->getStatusCode(), '%STATUS%' => strtoupper($commit->getStatus()), '%sha%' => $commit->getSha(), '%short_sha%' => $commit->getShortSha(), '%author%' => $commit->getAuthor(), '%message%' => $commit->getMessage()); }
/** * SyncRepositoryTask::execute() * * @param array $arguments * @param array $options * @return */ protected function execute($arguments = array(), $options = array()) { // ログファイルの設定 $file_logger = new sfFileLogger($this->dispatcher, array('file' => $this->configuration->getRootDir() . '/log/' . $this->getName() . '.log')); $this->dispatcher->connect('application.log', array($file_logger, 'listenToLogEvent')); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); // 更新フラグのあるリポジトリの最初の1件を取得する。 $repository = RepositoryTable::getInstance()->findOneByForceUpdate(1); if (!$repository) { return false; } // 更新フラグを消しておく。 $repository->setForceUpdate(0); $repository->save(); // リポジトリを同期する。 $this->log(sprintf('リポジトリ %s の同期を開始します', $repository->getRepositoryName())); // リポジトリキャッシュルートディレクトリ $cache_root = sfConfig::get('sf_root_dir') . '/../data/repos/'; $dir_root = $cache_root . $repository->getCacheKey(); $do_clone = false; if ($repository->getForceClone()) { // 一旦このディレクトリ配下をすべて削除する sfToolkit::clearDirectory($dir_root_repo); // 強制clone $do_clone = true; } else { if (!is_dir($dir_root)) { // ディレクトリがない。 mkdir($dir_root, 0777, true); // このディレクトリ配下にcloneを取得する。 $do_clone = true; } else { // リポジトリは取得済か? $dir_root_repo = $dir_root . DIRECTORY_SEPARATOR . $repository->getRepositoryName(); try { $git = new myVersionControl_Git($dir_root_repo); $git->setGitCommandPath('git'); // pullする。 $this->log('リポジトリをpullしています'); $pullMessage = $git->getCommand('pull')->execute(); if (preg_match('/up\\-to\\-date/i', $pullMessage)) { $this->log('更新はありません'); return; } } catch (Exception $e) { // 一旦このディレクトリ配下をすべて削除する sfToolkit::clearDirectory($dir_root_repo); // cloneする $do_clone = true; } } } if ($do_clone) { $this->log('リポジトリをcloneしています'); $git = new myVersionControl_Git($dir_root); $git->setGitCommandPath('git'); $git->createClone($repository->getRepository()); // リポジトリ $dir_root_repo = $dir_root . DIRECTORY_SEPARATOR . $repository->getRepositoryName(); try { $git = new myVersionControl_Git($dir_root_repo); $git->setGitCommandPath('git'); } catch (Exception $e) { // 一旦このディレクトリ配下をすべて削除する sfToolkit::clearDirectory($dir_root_repo); return; } } // このリポジトリの対象ファイルリストを取得する。 $files = sfFinder::type('file')->prune('.git')->discard('.git')->relative()->in($search_dir = $dir_root . DIRECTORY_SEPARATOR . $repository->getRepositoryName() . $repository->getSubdirectory()); $page_path_root = $repository->getBindPath(); // --------------------------------------------- // ファイル別に処理 $new_commit_found = false; foreach ($files as $file) { $this->log(sprintf('ファイル:%s', $file)); $info = pathinfo($file); $file_path = $search_dir . DIRECTORY_SEPARATOR . $file; // ファイルの更新タイムスタンプが新しいものだけ処理する if (filemtime($file_path) < time() - 86400) { $this->log('更新なし'); continue; } // このファイルが対象かどうかチェックする。 if (!PageTable::needProcess($file)) { $this->log('ページ取り込み対象外'); // 画像データなら、パブリックディレクトリにコピーする。 if (preg_match('/^(png|jpg|gif)$/', $info['extension'])) { $target_path = $repository->getImagePublicPath($file); $target_dir = dirname($target_path); if (!is_dir($target_dir)) { mkdir($target_dir, 0777, true); } $this->log('ファイルをパブリックディレクトリにコピーします。'); copy($file_path, $target_path); chmod($target_path, 0666); } continue; } // 各ページに対応するURLパスを求める。 if ('.' !== $info['dirname']) { $page_path = strtolower($page_path_root . '/' . $info['dirname'] . '/' . $info['filename']); } else { $page_path = strtolower($page_path_root . '/' . $info['filename']); } // ページに対応するレコードを取得する。 $page = Doctrine_Core::getTable('Page')->findOneByPath($page_path); if (!$page) { $page = new Page(); $page->setPath($page_path); $page->setRepository($repository); } echo $file; // ページごとにコミット履歴を取得する。 $commits = $git->getCommits('master', $file_path); foreach ($commits as $commit) { // 既存ページの場合はコミットがすでに取り込み済かチェックする。 $commit_record = null; if (!$page->isNew()) { $commit_record = Doctrine_Core::getTable('Commit')->findOneByCommitKeyAndPageId($commit->__toString(), $page->getId()); } if (!$commit_record) { // コミットを登録する。 $new_commit_found = true; $this->log(sprintf('コミット %s を取得しています', $commit)); $commit_record = new Commit(); $commit_record->setAuthorHandle($commit->getAuthorHandle()); $commit_record->setAuthorEmail($commit->getAuthorEmail()); $commit_record->setCommitterHandle($commit->getCommitterHandle()); $commit_record->setCommitterEmail($commit->getCommitterEmail()); $commit_record->setCommittedAt(date('Y/m/d H:i:s', $commit->getCommittedAt())); $commit_record->setCommitKey($commit); $commit_record->setPage($page); $commit_record->save(); $commit_record->free(); unset($commit_record); } } // 新規のコミットが無い場合は、処理をスキップする。 if (!$new_commit_found) { continue; } $new_commit_found = true; $page->setContentType($type = PageTable::checkType($file)); $content = file_get_contents($file_path); if ('UTF-8' !== ($encoding = mb_detect_encoding($content))) { $content = mb_convert_encoding($content, 'UTF-8', $encoding); } $page->setContentRaw($content); // ページのレンダリングモードに合わせてレンダリングする。 $page->setContentRendered($rendered = PageTable::renderContent($content, $type)); // DOMパース用に、特殊文字を置換する。 $html = mb_convert_encoding($rendered, 'HTML-ENTITIES', 'ASCII, JIS, UTF-8, EUC-JP, SJIS'); // レンダリング結果をパースする。 $dom = new DomDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); // タイトルを探す。 $domElements = $xpath->query('//title | //h1'); if (count($domElements)) { $page->setTitle($domElements->item(0)->nodeValue); } // 見出しをパースする $domElements = $xpath->query('//h1 | //h2 | //h3'); $indexes = array(); $now_h1 = array(); $now_h2 = array(); foreach ($domElements as $domElement) { switch ($domElement->nodeName) { case 'h1': $indexes[] = array('type' => 'h1', 'text' => $domElement->nodeValue, 'id' => $domElement->getAttribute('id'), 'children' => array()); $now_h1 =& $indexes[count($indexes) - 1]['children']; break; case 'h2': $now_h1[] = array('type' => 'h2', 'text' => $domElement->nodeValue, 'id' => $domElement->getAttribute('id'), 'children' => array()); $now_h2 =& $now_h1[count($now_h1) - 1]['children']; break; case 'h3': $now_h2[] = array('type' => 'h3', 'text' => $domElement->nodeValue, 'id' => $domElement->getAttribute('id'), 'children' => array()); break; default: break; } } $page->setIndexJson(json_encode($indexes)); // 保存する。 $page->save(); $page->free(); unset($page); } // 新しいコミットがあった場合、キャッシュを削除する。 if ($new_commit_found) { $frontend_cache_dir = sfConfig::get('sf_cache_dir') . '/frontend/prod/template'; $cache = new sfFileCache(array('cache_dir' => $frontend_cache_dir)); $cache->clean(); } $this->log(sprintf('リポジトリ %s の同期が完了しました', $repository->getRepositoryName())); }
/** * @param Commit $commit */ public function addCommit(Commit $commit) { $this->commits[(string) $commit->getHash()] = $commit; }
/** * Get any object from the repository. * * @param string $name Reference name or (partial) object hash * @return Object Immutable Object of given name. * @throws \InvalidArgumentException * @throws \OutOfBoundsException */ public function get($name) { $hash = false; if (ctype_xdigit($name)) { $hash_len = strlen($name); if ($hash_len < 4) { throw new \InvalidArgumentException('Hash must be at least 4 characters long.'); } if ($hash_len % 2) { throw new \InvalidArgumentException('Hash must be divisible by two.'); } $hash = $name; } elseif (array_key_exists($name, $this->refs)) { $hash = $this->refs[$name]; } else { throw new \InvalidArgumentException('Invalid ref: ' . $name); } $data = false; $objectPath = $this->path . '/objects/' . substr($hash, 0, 2) . '/' . substr($hash, 2); if (strlen($hash) < 40) { $hits = glob($objectPath . '*'); if (count($hits) > 0) { $data = gzuncompress(file_get_contents($hits[0])); } } elseif (file_exists($objectPath)) { $data = gzuncompress(file_get_contents($objectPath)); } if (!$data) { foreach ($this->packs as &$pack) { $data = $pack->search($hash); if ($data) { break; } } } if (!$data) { throw new \OutOfBoundsException($name); } $hash = strlen($hash) == 40 ? $hash : sha1($data); list($prefix, $body) = explode("", $data, 2); list($type, $size) = explode(' ', $prefix, 2); switch ($type) { case 'commit': return Commit::fromRaw($body, $size, $hash); case 'tag': return Tag::fromRaw($body, $size, $hash); case 'tree': return Tree::fromRaw($body, $size, $hash); case 'blob': return Blob::fromRaw($body, $size, $hash); default: throw new InvalidArgumentException($type); } }
/** * Appends commit along with comments. * @param Commit commit object */ public function addCommit(Commit $commit) { $new = $this->findCommit($commit->getHash()); $new->setLabel($commit->getLabel()); $new->addComments($commit->getComments()); }
if (isset($_GET['commit_id'])) { $commit_id = pg_escape_string($_GET['commit_id']); } if (isset($_GET['revision'])) { $revision = pg_escape_string($_GET['revision']); } # I'm quite sure we use only message_id, and never commit_id. if ($message_id != '') { require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/commit.php'; $Commit = new Commit($db); $Commit->FetchByMessageId($message_id); freshports_ConditionalGet($Commit->last_modified); } else { if ($revision != '') { require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/commit.php'; $Commit = new Commit($db); // Get the message IDs for this revision $message_id_array = $Commit->FetchByRevision($revision); if (count($message_id_array) == 1) { header('Location: /commit.php?message_id=' . $message_id_array[0]); exit; } freshports_ConditionalGet($Commit->last_modified); if ($Debug) { echo 'oh... got something back there: <pre>' . print_r($message_id_array, true) . '</pre>'; } } } if (isset($_REQUEST['page'])) { $PageNo = $_REQUEST['page']; }
public function testJsonSerialize() { $commit = new Commit(); $commit->setMessage('Message'); $this->assertInternalType('array', $commit->jsonSerialize()); }
<?php // test/unit/model/doctrine/CommitTest.php require_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; // test環境でDB初期化 $configuration = ProjectConfiguration::getApplicationConfiguration('taskapp', 'test', true); new sfDatabaseManager($configuration); Doctrine_Core::loadData(dirname(__FILE__) . '/CommitFixture.yml'); $t = new lime_test(12); // construct $t->diag('__construct()'); $t->ok(new Commit() instanceof Commit, 'Commitインスタンス化'); $page = PageTable::getInstance()->findOneByPath('/foo/bar'); // create $t->diag('create'); $commit = new Commit(); $commit->setCommittedAt('2010/05/19 01:02:03'); $commit->setAuthorHandle('author_handle'); $commit->setAuthorEmail('author_email'); $commit->setCommitterHandle('committer_handle'); $commit->setCommitterEmail('committer_email'); $commit->setCommitKey('commit_key'); $commit->setPage($page); $commit->save(); $commit = CommitTable::getInstance()->findOneByCommitKey('commit_key'); $t->ok($commit instanceof Commit, 'レコードが正しく保存された'); $t->is($commit->getDateTimeObject('committed_at')->format('Y/m/d H:i:s'), '2010/05/19 01:02:03', 'コミット日時の保存'); $t->is($commit->getAuthorHandle(), 'author_handle', '作者ハンドルの保存'); $t->is($commit->getAuthorEmail(), 'author_email', '作者メールアドレスの保存'); $t->is($commit->getCommitterHandle(), 'committer_handle', 'コミッターハンドルの保存'); $t->is($commit->getCommitterEmail(), 'committer_email', 'コミッターメールアドレスの保存');
protected function createCommit($id = 'id', $authorName = 'author_name', $authorEmail = 'author_email', $committerName = 'committer_name', $committerEmail = 'committer_email', $message = 'message') { $commit = new Commit(); return $commit->setId($id)->setAuthorName($authorName)->setAuthorEmail($authorEmail)->setCommitterName($committerName)->setCommitterEmail($committerEmail)->setMessage($message); }
public static function skipCommit(Commit $commit) { $subject = $commit->getSubject(); static $equals = ['' => 1, 'bump' => 1, 'minor' => 1, 'bumped' => 1]; if (isset($equals[$subject])) { return true; } static $starts = ['version bump', 'bumped version', "merge branch 'master'"]; foreach ($starts as $start) { if (strtolower(substr($subject, 0, strlen($start))) === $start) { return true; } } return false; }