本文整理汇总了PHP中DiffusionRequest::getCommit方法的典型用法代码示例。如果您正苦于以下问题:PHP DiffusionRequest::getCommit方法的具体用法?PHP DiffusionRequest::getCommit怎么用?PHP DiffusionRequest::getCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiffusionRequest
的用法示例。
在下文中一共展示了DiffusionRequest::getCommit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newBlameFuture
protected function newBlameFuture(DiffusionRequest $request, $path)
{
$repository = $request->getRepository();
$commit = $request->getCommit();
// NOTE: We're using "--debug" to make "--changeset" give us the full
// commit hashes.
return $repository->getLocalCommandFuture('annotate --debug --changeset --rev %s -- %s', $commit, $path);
}
示例2: buildRawDiffResponse
private function buildRawDiffResponse(DiffusionRequest $drequest)
{
$raw_diff = $this->callConduitWithDiffusionRequest('diffusion.rawdiffquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath()));
$file = PhabricatorFile::buildFromFileDataOrHash($raw_diff, array('name' => $drequest->getCommit() . '.diff', 'ttl' => 60 * 60 * 24, 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$file->attachToObject($drequest->getRepository()->getPHID());
unset($unguarded);
return $file->getRedirectResponse();
}
示例3: buildNormalContent
private function buildNormalContent(DiffusionRequest $drequest)
{
$repository = $drequest->getRepository();
$phids = array();
$content = array();
try {
$history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => 0, 'limit' => 15));
$history = DiffusionPathChange::newFromConduit($history_results['pathChanges']);
foreach ($history as $item) {
$data = $item->getCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
$history_exception = null;
} catch (Exception $ex) {
$history_results = null;
$history = null;
$history_exception = $ex;
}
try {
$browse_results = DiffusionBrowseResultSet::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.browsequery', array('path' => $drequest->getPath(), 'commit' => $drequest->getCommit())));
$browse_paths = $browse_results->getPaths();
foreach ($browse_paths as $item) {
$data = $item->getLastCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
$browse_exception = null;
} catch (Exception $ex) {
$browse_results = null;
$browse_paths = null;
$browse_exception = $ex;
}
$phids = array_keys($phids);
$handles = $this->loadViewerHandles($phids);
$readme = null;
if ($browse_results) {
$readme_path = $browse_results->getReadmePath();
if ($readme_path) {
$readme_content = $this->callConduitWithDiffusionRequest('diffusion.filecontentquery', array('path' => $readme_path, 'commit' => $drequest->getStableCommit()));
if ($readme_content) {
$readme = id(new DiffusionReadmeView())->setUser($this->getViewer())->setPath($readme_path)->setContent($readme_content['corpus']);
}
}
}
$content[] = $this->buildBrowseTable($browse_results, $browse_paths, $browse_exception, $handles);
$content[] = $this->buildHistoryTable($history_results, $history, $history_exception);
try {
$content[] = $this->buildTagListTable($drequest);
} catch (Exception $ex) {
if (!$repository->isImporting()) {
$content[] = $this->renderStatusMessage(pht('Unable to Load Tags'), $ex->getMessage());
}
}
try {
$content[] = $this->buildBranchListTable($drequest);
} catch (Exception $ex) {
if (!$repository->isImporting()) {
$content[] = $this->renderStatusMessage(pht('Unable to Load Branches'), $ex->getMessage());
}
}
if ($readme) {
$content[] = $readme;
}
return $content;
}
示例4: buildCorpus
private function buildCorpus($show_blame, $show_color, $file_corpus, $needs_blame, DiffusionRequest $drequest, $path, $data)
{
$viewer = $this->getViewer();
$blame_timeout = 15;
$blame_failed = false;
$highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
$blame_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
$can_highlight = strlen($file_corpus) <= $highlight_limit;
$can_blame = strlen($file_corpus) <= $blame_limit;
if ($needs_blame && $can_blame) {
$blame = $this->loadBlame($path, $drequest->getCommit(), $blame_timeout);
list($blame_list, $blame_commits) = $blame;
if ($blame_list === null) {
$blame_failed = true;
$blame_list = array();
}
} else {
$blame_list = array();
$blame_commits = array();
}
if (!$show_color) {
$corpus = $this->renderPlaintextCorpus($file_corpus, $blame_list, $blame_commits, $show_blame);
} else {
if ($can_highlight) {
require_celerity_resource('syntax-highlighting-css');
$highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename($path, $file_corpus);
$lines = phutil_split_lines($highlighted);
} else {
$lines = phutil_split_lines($file_corpus);
}
$rows = $this->buildDisplayRows($lines, $blame_list, $blame_commits, $show_blame, $show_color);
$corpus_table = javelin_tag('table', array('class' => 'diffusion-source remarkup-code PhabricatorMonospaced', 'sigil' => 'phabricator-source'), $rows);
if ($this->getRequest()->isAjax()) {
return $corpus_table;
}
$id = celerity_generate_unique_node_id();
$repo = $drequest->getRepository();
$symbol_repos = nonempty($repo->getSymbolSources(), array());
$symbol_repos[] = $repo->getPHID();
$lang = last(explode('.', $drequest->getPath()));
$repo_languages = $repo->getSymbolLanguages();
$repo_languages = nonempty($repo_languages, array());
$repo_languages = array_fill_keys($repo_languages, true);
$needs_symbols = true;
if ($repo_languages && $symbol_repos) {
$have_symbols = id(new DiffusionSymbolQuery())->existsSymbolsInRepository($repo->getPHID());
if (!$have_symbols) {
$needs_symbols = false;
}
}
if ($needs_symbols && $repo_languages) {
$needs_symbols = isset($repo_languages[$lang]);
}
if ($needs_symbols) {
Javelin::initBehavior('repository-crossreference', array('container' => $id, 'lang' => $lang, 'repositories' => $symbol_repos));
}
$corpus = phutil_tag('div', array('id' => $id), $corpus_table);
Javelin::initBehavior('load-blame', array('id' => $id));
}
$edit = $this->renderEditButton();
$file = $this->renderFileButton();
$header = id(new PHUIHeaderView())->setHeader(pht('File Contents'))->addActionLink($edit)->addActionLink($file);
$corpus = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($corpus)->setCollapsed(true);
$messages = array();
if (!$can_highlight) {
$messages[] = pht('This file is larger than %s, so syntax highlighting is disabled ' . 'by default.', phutil_format_bytes($highlight_limit));
}
if ($show_blame && !$can_blame) {
$messages[] = pht('This file is larger than %s, so blame is disabled.', phutil_format_bytes($blame_limit));
}
if ($blame_failed) {
$messages[] = pht('Failed to load blame information for this file in %s second(s).', new PhutilNumber($blame_timeout));
}
if ($messages) {
$corpus->setInfoView(id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setErrors($messages));
}
return $corpus;
}
示例5: buildRefs
private function buildRefs(DiffusionRequest $request)
{
// Not turning this into a proper Query class since it's pretty simple,
// one-off, and Git-specific.
$type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
$repository = $request->getRepository();
if ($repository->getVersionControlSystem() != $type_git) {
return null;
}
list($stdout) = $repository->execxLocalCommand('log --format=%s -n 1 %s --', '%d', $request->getCommit());
// %d, gives a weird output format
// similar to (remote/one, remote/two, remote/three)
$refs = trim($stdout, "() \n");
if (!$refs) {
return null;
}
$refs = explode(',', $refs);
$refs = array_map('trim', $refs);
$ref_links = array();
foreach ($refs as $ref) {
$ref_links[] = phutil_render_tag('a', array('href' => $request->generateURI(array('action' => 'browse', 'branch' => $ref))), phutil_escape_html($ref));
}
$ref_links = implode(', ', $ref_links);
return $ref_links;
}
示例6: newBlameFuture
protected function newBlameFuture(DiffusionRequest $request, $path)
{
$repository = $request->getRepository();
$commit = $request->getCommit();
return $repository->getRemoteCommandFuture('blame --force %s', $repository->getSubversionPathURI($path, $commit));
}
示例7: buildNormalContent
private function buildNormalContent(DiffusionRequest $drequest)
{
$repository = $drequest->getRepository();
$phids = array();
$content = array();
try {
$history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => 0, 'limit' => 15));
$history = DiffusionPathChange::newFromConduit($history_results['pathChanges']);
foreach ($history as $item) {
$data = $item->getCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
$history_exception = null;
} catch (Exception $ex) {
$history_results = null;
$history = null;
$history_exception = $ex;
}
try {
$browse_results = DiffusionBrowseResultSet::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.browsequery', array('path' => $drequest->getPath(), 'commit' => $drequest->getCommit())));
$browse_paths = $browse_results->getPaths();
foreach ($browse_paths as $item) {
$data = $item->getLastCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
$browse_exception = null;
} catch (Exception $ex) {
$browse_results = null;
$browse_paths = null;
$browse_exception = $ex;
}
$phids = array_keys($phids);
$handles = $this->loadViewerHandles($phids);
if ($browse_results) {
$readme = $this->callConduitWithDiffusionRequest('diffusion.readmequery', array('paths' => $browse_results->getPathDicts(), 'commit' => $drequest->getStableCommit()));
} else {
$readme = null;
}
$content[] = $this->buildBrowseTable($browse_results, $browse_paths, $browse_exception, $handles);
$content[] = $this->buildHistoryTable($history_results, $history, $history_exception, $handles);
try {
$content[] = $this->buildTagListTable($drequest);
} catch (Exception $ex) {
if (!$repository->isImporting()) {
$content[] = $this->renderStatusMessage(pht('Unable to Load Tags'), $ex->getMessage());
}
}
try {
$content[] = $this->buildBranchListTable($drequest);
} catch (Exception $ex) {
if (!$repository->isImporting()) {
$content[] = $this->renderStatusMessage(pht('Unable to Load Branches'), $ex->getMessage());
}
}
if ($readme) {
$box = new PHUIBoxView();
$box->appendChild($readme);
$box->addPadding(PHUI::PADDING_LARGE);
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('README'));
$panel->appendChild($box);
$content[] = $panel;
}
return $content;
}
示例8: buildRawDiffResponse
private function buildRawDiffResponse(DiffusionRequest $drequest)
{
$diff_info = $this->callConduitWithDiffusionRequest('diffusion.rawdiffquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath()));
$file_phid = $diff_info['filePHID'];
$file = id(new PhabricatorFileQuery())->setViewer($this->getViewer())->withPHIDs(array($file_phid))->executeOne();
if (!$file) {
throw new Exception(pht('Failed to load file ("%s") returned by "%s".', $file_phid, 'diffusion.rawdiffquery'));
}
return $file->getRedirectResponse();
}