@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve tag support in Diffusion

Summary:
- When viewing a commit, show its tags.
- For commits with many tags, show a list of all tags on the tag list interface.
- Improve some handling of symbolic references.
- When tags contain content, show it on the browse view reached by clicking the tag name.

Test Plan: Looked at commits with and without tags, clicked "More tags...", clicked tag names.

Reviewers: btrahan, vrana, davidreuss, jungejason

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1130

Differential Revision: https://secure.phabricator.com/D2290

+475 -31
+10
src/__phutil_library_map__.php
··· 99 99 'AphrontTokenizerTemplateView' => 'view/control/tokenizer', 100 100 'AphrontTypeaheadTemplateView' => 'view/control/typeahead', 101 101 'AphrontURIMapper' => 'aphront/mapper', 102 + 'AphrontUsageException' => 'aphront/exception/usage', 102 103 'AphrontView' => 'view/base', 103 104 'AphrontWebpageResponse' => 'aphront/response/webpage', 104 105 'AphrontWriteGuard' => 'aphront/writeguard', ··· 303 304 'DiffusionCommitChangeTableView' => 'applications/diffusion/view/commitchangetable', 304 305 'DiffusionCommitController' => 'applications/diffusion/controller/commit', 305 306 'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/base', 307 + 'DiffusionCommitTagsQuery' => 'applications/diffusion/query/committags/base', 306 308 'DiffusionContainsQuery' => 'applications/diffusion/query/contains/base', 307 309 'DiffusionController' => 'applications/diffusion/controller/base', 308 310 'DiffusionDiffController' => 'applications/diffusion/controller/diff', ··· 315 317 'DiffusionGitBranchQueryTestCase' => 'applications/diffusion/query/branch/git/__tests__', 316 318 'DiffusionGitBrowseQuery' => 'applications/diffusion/query/browse/git', 317 319 'DiffusionGitCommitParentsQuery' => 'applications/diffusion/query/parents/git', 320 + 'DiffusionGitCommitTagsQuery' => 'applications/diffusion/query/committags/git', 318 321 'DiffusionGitContainsQuery' => 'applications/diffusion/query/contains/git', 319 322 'DiffusionGitDiffQuery' => 'applications/diffusion/query/diff/git', 320 323 'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/git', ··· 334 337 'DiffusionMercurialBranchQuery' => 'applications/diffusion/query/branch/mercurial', 335 338 'DiffusionMercurialBrowseQuery' => 'applications/diffusion/query/browse/mercurial', 336 339 'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/mercurial', 340 + 'DiffusionMercurialCommitTagsQuery' => 'applications/diffusion/query/committags/mercurial', 337 341 'DiffusionMercurialContainsQuery' => 'applications/diffusion/query/contains/mercurial', 338 342 'DiffusionMercurialDiffQuery' => 'applications/diffusion/query/diff/mercurial', 339 343 'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/mercurial', ··· 359 363 'DiffusionRequest' => 'applications/diffusion/request/base', 360 364 'DiffusionSvnBrowseQuery' => 'applications/diffusion/query/browse/svn', 361 365 'DiffusionSvnCommitParentsQuery' => 'applications/diffusion/query/parents/svn', 366 + 'DiffusionSvnCommitTagsQuery' => 'applications/diffusion/query/committags/svn', 362 367 'DiffusionSvnContainsQuery' => 'applications/diffusion/query/contains/svn', 363 368 'DiffusionSvnDiffQuery' => 'applications/diffusion/query/diff/svn', 364 369 'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/svn', ··· 1105 1110 'AphrontTableView' => 'AphrontView', 1106 1111 'AphrontTokenizerTemplateView' => 'AphrontView', 1107 1112 'AphrontTypeaheadTemplateView' => 'AphrontView', 1113 + 'AphrontUsageException' => 'AphrontException', 1108 1114 'AphrontWebpageResponse' => 'AphrontResponse', 1109 1115 'CelerityResourceController' => 'AphrontController', 1110 1116 'CelerityResourceGraph' => 'AbstractDirectedGraph', ··· 1269 1275 'DiffusionCommitChangeTableView' => 'DiffusionView', 1270 1276 'DiffusionCommitController' => 'DiffusionController', 1271 1277 'DiffusionCommitParentsQuery' => 'DiffusionQuery', 1278 + 'DiffusionCommitTagsQuery' => 'DiffusionQuery', 1272 1279 'DiffusionContainsQuery' => 'DiffusionQuery', 1273 1280 'DiffusionController' => 'PhabricatorController', 1274 1281 'DiffusionDiffController' => 'DiffusionController', ··· 1280 1287 'DiffusionGitBranchQueryTestCase' => 'PhabricatorTestCase', 1281 1288 'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery', 1282 1289 'DiffusionGitCommitParentsQuery' => 'DiffusionCommitParentsQuery', 1290 + 'DiffusionGitCommitTagsQuery' => 'DiffusionCommitTagsQuery', 1283 1291 'DiffusionGitContainsQuery' => 'DiffusionContainsQuery', 1284 1292 'DiffusionGitDiffQuery' => 'DiffusionDiffQuery', 1285 1293 'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery', ··· 1299 1307 'DiffusionMercurialBranchQuery' => 'DiffusionBranchQuery', 1300 1308 'DiffusionMercurialBrowseQuery' => 'DiffusionBrowseQuery', 1301 1309 'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery', 1310 + 'DiffusionMercurialCommitTagsQuery' => 'DiffusionCommitTagsQuery', 1302 1311 'DiffusionMercurialContainsQuery' => 'DiffusionContainsQuery', 1303 1312 'DiffusionMercurialDiffQuery' => 'DiffusionDiffQuery', 1304 1313 'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery', ··· 1316 1325 'DiffusionRepositoryController' => 'DiffusionController', 1317 1326 'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery', 1318 1327 'DiffusionSvnCommitParentsQuery' => 'DiffusionCommitParentsQuery', 1328 + 'DiffusionSvnCommitTagsQuery' => 'DiffusionCommitTagsQuery', 1319 1329 'DiffusionSvnContainsQuery' => 'DiffusionContainsQuery', 1320 1330 'DiffusionSvnDiffQuery' => 'DiffusionDiffQuery', 1321 1331 'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
+16
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 504 504 return $response; 505 505 } 506 506 507 + if ($ex instanceof AphrontUsageException) { 508 + $error = new AphrontErrorView(); 509 + $error->setTitle(phutil_escape_html($ex->getTitle())); 510 + $error->appendChild(phutil_escape_html($ex->getMessage())); 511 + 512 + $view = new PhabricatorStandardPageView(); 513 + $view->setRequest($this->getRequest()); 514 + $view->appendChild($error); 515 + 516 + $response = new AphrontWebpageResponse(); 517 + $response->setContent($view->render()); 518 + 519 + return $response; 520 + } 521 + 522 + 507 523 // Always log the unhandled exception. 508 524 phlog($ex); 509 525
+1
src/aphront/default/configuration/__init__.php
··· 17 17 phutil_require_module('phabricator', 'infrastructure/env'); 18 18 phutil_require_module('phabricator', 'view/control/table'); 19 19 phutil_require_module('phabricator', 'view/dialog'); 20 + phutil_require_module('phabricator', 'view/form/error'); 20 21 phutil_require_module('phabricator', 'view/page/standard'); 21 22 22 23 phutil_require_module('phutil', 'error');
+37
src/aphront/exception/usage/AphrontUsageException.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + /** 20 + * These exceptions represent user error, and are not logged. 21 + * 22 + * @concrete-extensible 23 + */ 24 + class AphrontUsageException extends AphrontException { 25 + 26 + private $title; 27 + 28 + public function __construct($title, $message) { 29 + $this->title = $title; 30 + parent::__construct($message); 31 + } 32 + 33 + public function getTitle() { 34 + return $this->title; 35 + } 36 + 37 + }
+12
src/aphront/exception/usage/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'aphront/exception/base'); 10 + 11 + 12 + phutil_require_source('AphrontUsageException.php');
+18 -4
src/applications/diffusion/controller/base/DiffusionController.php
··· 213 213 $repository_name); 214 214 215 215 $raw_commit = $drequest->getRawCommit(); 216 - if ($spec['commit']) { 217 - $crumb_list[] = "r{$callsign}{$raw_commit}"; 216 + 217 + if ($spec['tags']) { 218 + if ($spec['commit']) { 219 + $crumb_list[] = "Tags for ".phutil_render_tag( 220 + 'a', 221 + array( 222 + 'href' => $drequest->generateURI( 223 + array( 224 + 'action' => 'commit', 225 + 'commit' => $raw_commit, 226 + )), 227 + ), 228 + phutil_escape_html("r{$callsign}{$raw_commit}")); 229 + } else { 230 + $crumb_list[] = 'Tags'; 231 + } 218 232 return $crumb_list; 219 233 } 220 234 221 - if ($spec['tags']) { 222 - $crumb_list[] = 'Tags'; 235 + if ($spec['commit']) { 236 + $crumb_list[] = "r{$callsign}{$raw_commit}"; 223 237 return $crumb_list; 224 238 } 225 239
+30 -11
src/applications/diffusion/controller/browse/DiffusionBrowseController.php
··· 33 33 'view' => 'browse', 34 34 )); 35 35 36 + if ($drequest->getTagContent()) { 37 + $title = 'Tag: '.$drequest->getSymbolicCommit(); 38 + 39 + $tag_view = new AphrontPanelView(); 40 + $tag_view->setHeader(phutil_escape_html($title)); 41 + $tag_view->appendChild( 42 + $this->markupText($drequest->getTagContent())); 43 + 44 + $content[] = $tag_view; 45 + } 46 + 36 47 if (!$results) { 37 48 38 49 if ($browse_query->getReasonForEmptyResultSet() == ··· 88 99 $readme_content = nl2br($readme_content); 89 100 } else { 90 101 // Markup extensionless files as remarkup so we get links and such. 91 - 92 - $engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine(); 93 - $readme_content = $engine->markupText($readme_content); 94 - 95 - $readme_content = phutil_render_tag( 96 - 'div', 97 - array( 98 - 'class' => 'phabricator-remarkup', 99 - ), 100 - $readme_content); 102 + $readme_content = $this->markupText($readme_content); 101 103 } 102 104 103 105 $readme_panel = new AphrontPanelView(); ··· 126 128 return $this->buildStandardPageResponse( 127 129 $nav, 128 130 array( 129 - 'title' => basename($drequest->getPath()), 131 + 'title' => array( 132 + nonempty(basename($drequest->getPath()), '/'), 133 + $drequest->getRepository()->getCallsign().' Repository', 134 + ), 130 135 )); 136 + } 137 + 138 + private function markupText($text) { 139 + $engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine(); 140 + $text = $engine->markupText($text); 141 + 142 + $text = phutil_render_tag( 143 + 'div', 144 + array( 145 + 'class' => 'phabricator-remarkup', 146 + ), 147 + $text); 148 + 149 + return $text; 131 150 } 132 151 133 152 }
+50
src/applications/diffusion/controller/commit/DiffusionCommitController.php
··· 351 351 $props['Branches'] = $branches; 352 352 } 353 353 354 + 355 + $tags = $this->renderTags($request); 356 + if ($tags) { 357 + $props['Tags'] = $tags; 358 + } 359 + 354 360 if ($task_phids) { 355 361 $task_list = array(); 356 362 foreach ($task_phids as $phid) { ··· 720 726 return $action_list; 721 727 } 722 728 729 + private function renderTags(DiffusionRequest $request) { 730 + $tag_limit = 10; 731 + 732 + $tag_query = DiffusionCommitTagsQuery::newFromDiffusionRequest($request); 733 + $tag_query->setLimit($tag_limit + 1); 734 + $tags = $tag_query->loadTags(); 735 + 736 + if (!$tags) { 737 + return null; 738 + } 739 + 740 + $has_more_tags = (count($tags) > $tag_limit); 741 + $tags = array_slice($tags, 0, $tag_limit); 742 + 743 + $tag_links = array(); 744 + foreach ($tags as $tag) { 745 + $tag_links[] = phutil_render_tag( 746 + 'a', 747 + array( 748 + 'href' => $request->generateURI( 749 + array( 750 + 'action' => 'browse', 751 + 'commit' => $tag->getName(), 752 + )), 753 + ), 754 + phutil_escape_html($tag->getName())); 755 + } 756 + 757 + if ($has_more_tags) { 758 + $tag_links[] = phutil_render_tag( 759 + 'a', 760 + array( 761 + 'href' => $request->generateURI( 762 + array( 763 + 'action' => 'tags', 764 + )), 765 + ), 766 + "More tags\xE2\x80\xA6"); 767 + } 768 + 769 + $tag_links = implode(', ', $tag_links); 770 + 771 + return $tag_links; 772 + } 723 773 724 774 }
+1
src/applications/diffusion/controller/commit/__init__.php
··· 18 18 phutil_require_module('phabricator', 'applications/differential/view/changesetlistview'); 19 19 phutil_require_module('phabricator', 'applications/diffusion/controller/base'); 20 20 phutil_require_module('phabricator', 'applications/diffusion/data/pathchange'); 21 + phutil_require_module('phabricator', 'applications/diffusion/query/committags/base'); 21 22 phutil_require_module('phabricator', 'applications/diffusion/query/contains/base'); 22 23 phutil_require_module('phabricator', 'applications/diffusion/query/mergedcommits/base'); 23 24 phutil_require_module('phabricator', 'applications/diffusion/query/parents/base');
+26 -6
src/applications/diffusion/controller/taglist/DiffusionTagListController.php
··· 29 29 $pager->setURI($request->getRequestURI(), 'offset'); 30 30 $pager->setOffset($request->getInt('offset')); 31 31 32 - $query = DiffusionTagListQuery::newFromDiffusionRequest($drequest); 33 - $query->setOffset($pager->getOffset()); 34 - $query->setLimit($pager->getPageSize() + 1); 35 - $tags = $query->loadTags(); 32 + if ($drequest->getRawCommit()) { 33 + $is_commit = true; 34 + 35 + $query = DiffusionCommitTagsQuery::newFromDiffusionRequest($drequest); 36 + $query->setOffset($pager->getOffset()); 37 + $query->setLimit($pager->getPageSize() + 1); 38 + $tags = $query->loadTags(); 39 + } else { 40 + $is_commit = false; 41 + 42 + $query = DiffusionTagListQuery::newFromDiffusionRequest($drequest); 43 + $query->setOffset($pager->getOffset()); 44 + $query->setLimit($pager->getPageSize() + 1); 45 + $tags = $query->loadTags(); 46 + } 47 + 36 48 $tags = $pager->sliceResults($tags); 37 49 38 50 $content = null; 39 51 if (!$tags) { 40 52 $content = new AphrontErrorView(); 41 53 $content->setTitle('No Tags'); 42 - $content->appendChild('This repository has no tags.'); 54 + if ($is_commit) { 55 + $content->appendChild('This commit has no tags.'); 56 + } else { 57 + $content->appendChild('This repository has no tags.'); 58 + } 43 59 $content->setSeverity(AphrontErrorView::SEVERITY_NODATA); 44 60 } else { 45 61 $commits = id(new PhabricatorAuditCommitQuery()) ··· 69 85 70 86 return $this->buildStandardPageResponse( 71 87 array( 72 - $this->buildCrumbs(array('tags' => true)), 88 + $this->buildCrumbs( 89 + array( 90 + 'tags' => true, 91 + 'commit' => $drequest->getRawCommit(), 92 + )), 73 93 $content, 74 94 ), 75 95 array(
+1
src/applications/diffusion/controller/taglist/__init__.php
··· 8 8 9 9 phutil_require_module('phabricator', 'applications/audit/query/commit'); 10 10 phutil_require_module('phabricator', 'applications/diffusion/controller/base'); 11 + phutil_require_module('phabricator', 'applications/diffusion/query/committags/base'); 11 12 phutil_require_module('phabricator', 'applications/diffusion/query/taglist/base'); 12 13 phutil_require_module('phabricator', 'applications/diffusion/view/taglist'); 13 14 phutil_require_module('phabricator', 'applications/phid/handle/data');
+51
src/applications/diffusion/query/committags/base/DiffusionCommitTagsQuery.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + abstract class DiffusionCommitTagsQuery extends DiffusionQuery { 20 + 21 + private $limit; 22 + private $offset; 23 + 24 + public function setOffset($offset) { 25 + $this->offset = $offset; 26 + return $this; 27 + } 28 + 29 + public function getOffset() { 30 + return $this->offset; 31 + } 32 + 33 + public function setLimit($limit) { 34 + $this->limit = $limit; 35 + return $this; 36 + } 37 + 38 + protected function getLimit() { 39 + return $this->limit; 40 + } 41 + 42 + final public static function newFromDiffusionRequest( 43 + DiffusionRequest $request) { 44 + return self::newQueryObject(__CLASS__, $request); 45 + } 46 + 47 + final public function loadTags() { 48 + return $this->executeQuery(); 49 + } 50 + 51 + }
+12
src/applications/diffusion/query/committags/base/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/diffusion/query/base'); 10 + 11 + 12 + phutil_require_source('DiffusionCommitTagsQuery.php');
+64
src/applications/diffusion/query/committags/git/DiffusionGitCommitTagsQuery.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class DiffusionGitCommitTagsQuery 20 + extends DiffusionCommitTagsQuery { 21 + 22 + protected function executeQuery() { 23 + $drequest = $this->getRequest(); 24 + $repository = $drequest->getRepository(); 25 + 26 + list($err, $stdout) = $repository->execLocalCommand( 27 + 'tag -l --contains %s', 28 + $drequest->getCommit()); 29 + 30 + if ($err) { 31 + // Git exits with an error code if the commit is bogus. 32 + return array(); 33 + } 34 + 35 + $stdout = trim($stdout); 36 + if (!strlen($stdout)) { 37 + return array(); 38 + } 39 + 40 + $tag_names = explode("\n", $stdout); 41 + $tag_names = array_fill_keys($tag_names, true); 42 + 43 + $tag_query = DiffusionTagListQuery::newFromDiffusionRequest($drequest); 44 + $tags = $tag_query->loadTags(); 45 + 46 + $result = array(); 47 + foreach ($tags as $tag) { 48 + if (isset($tag_names[$tag->getName()])) { 49 + $result[] = $tag; 50 + } 51 + } 52 + 53 + if ($this->getOffset()) { 54 + $result = array_slice($result, $this->getOffset()); 55 + } 56 + 57 + if ($this->getLimit()) { 58 + $result = array_slice($result, 0, $this->getLimit()); 59 + } 60 + 61 + return $result; 62 + } 63 + 64 + }
+13
src/applications/diffusion/query/committags/git/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/diffusion/query/committags/base'); 10 + phutil_require_module('phabricator', 'applications/diffusion/query/taglist/base'); 11 + 12 + 13 + phutil_require_source('DiffusionGitCommitTagsQuery.php');
+27
src/applications/diffusion/query/committags/mercurial/DiffusionMercurialCommitTagsQuery.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class DiffusionMercurialCommitTagsQuery 20 + extends DiffusionCommitTagsQuery { 21 + 22 + protected function executeQuery() { 23 + // TODO: Implement this. 24 + return array(); 25 + } 26 + 27 + }
+12
src/applications/diffusion/query/committags/mercurial/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/diffusion/query/committags/base'); 10 + 11 + 12 + phutil_require_source('DiffusionMercurialCommitTagsQuery.php');
+27
src/applications/diffusion/query/committags/svn/DiffusionSvnCommitTagsQuery.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class DiffusionSvnCommitTagsQuery 20 + extends DiffusionCommitTagsQuery { 21 + 22 + protected function executeQuery() { 23 + // No meaningful concept of tags in Subversion. 24 + return array(); 25 + } 26 + 27 + }
+12
src/applications/diffusion/query/committags/svn/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/diffusion/query/committags/base'); 10 + 11 + 12 + phutil_require_source('DiffusionSvnCommitTagsQuery.php');
+15 -3
src/applications/diffusion/request/base/DiffusionRequest.php
··· 31 31 protected $callsign; 32 32 protected $path; 33 33 protected $line; 34 + protected $symbolicCommit; 34 35 protected $commit; 35 36 protected $branch; 37 + protected $commitType = 'commit'; 38 + protected $tagContent; 36 39 37 40 protected $repository; 38 41 protected $repositoryCommit; ··· 174 177 * @task new 175 178 */ 176 179 final private function initializeFromDictionary(array $data) { 177 - $this->path = idx($data, 'path'); 178 - $this->commit = idx($data, 'commit'); 179 - $this->line = idx($data, 'line'); 180 + $this->path = idx($data, 'path'); 181 + $this->symbolicCommit = idx($data, 'commit'); 182 + $this->commit = idx($data, 'commit'); 183 + $this->line = idx($data, 'line'); 180 184 181 185 if ($this->getSupportsBranches()) { 182 186 $this->branch = idx($data, 'branch'); ··· 206 210 return $this->commit; 207 211 } 208 212 213 + public function getSymbolicCommit() { 214 + return $this->symbolicCommit; 215 + } 216 + 209 217 public function getBranch() { 210 218 return $this->branch; 219 + } 220 + 221 + public function getTagContent() { 222 + return $this->tagContent; 211 223 } 212 224 213 225 public function loadCommit() {
+39 -7
src/applications/diffusion/request/git/DiffusionGitRequest.php
··· 30 30 return; 31 31 } 32 32 33 - // Expand commit short forms to full 40-character hashes. This does not 34 - // verify them, --verify exits with return code 0 for anything that 35 - // looks like a valid hash. 33 + // Expand short commit names and verify 34 + 35 + $future = $this->getRepository()->getLocalCommandFuture( 36 + 'cat-file --batch'); 37 + $future->write($this->commit); 38 + list($stdout) = $future->resolvex(); 39 + 40 + list($hash, $type) = explode(' ', $stdout); 41 + if ($type == 'missing') { 42 + throw new Exception("Bad commit '{$this->commit}'."); 43 + } 44 + 45 + switch ($type) { 46 + case 'tag': 47 + $this->commitType = 'tag'; 36 48 37 - list($commit) = $this->getRepository()->execxLocalCommand( 38 - 'rev-parse --verify %s', 39 - $this->commit); 40 - $this->commit = trim($commit); 49 + $matches = null; 50 + $ok = preg_match( 51 + '/^object ([a-f0-9]+)$.*?\n\n(.*)$/sm', 52 + $stdout, 53 + $matches); 54 + if (!$ok) { 55 + throw new Exception( 56 + "Unparseable output from cat-file: {$stdout}"); 57 + } 58 + 59 + $hash = $matches[1]; 60 + $this->tagContent = trim($matches[2]); 61 + break; 62 + case 'commit': 63 + break; 64 + default: 65 + throw new AphrontUsageException( 66 + "Invalid Object Name", 67 + "The reference '{$this->commit}' does not name a valid ". 68 + "commit or a tag in this repository."); 69 + break; 70 + } 71 + 72 + $this->commit = $hash; 41 73 } 42 74 43 75 public function getBranch() {
+1
src/applications/diffusion/request/git/__init__.php
··· 6 6 7 7 8 8 9 + phutil_require_module('phabricator', 'aphront/exception/usage'); 9 10 phutil_require_module('phabricator', 'applications/diffusion/data/branch'); 10 11 phutil_require_module('phabricator', 'applications/diffusion/request/base'); 11 12