@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.

Move lint/unit test warning code forward to Transactions

Summary: Ref T2222. Makes the "lint/unit errors" warnings work again.

Test Plan: Viewed some revisions with and without these warnings.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

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

+74 -127
-1
resources/celerity/packages.php
··· 138 138 'javelin-behavior-differential-populate', 139 139 'javelin-behavior-differential-show-more', 140 140 'javelin-behavior-differential-diff-radios', 141 - 'javelin-behavior-differential-accept-with-errors', 142 141 'javelin-behavior-differential-comment-jump', 143 142 'javelin-behavior-differential-add-reviewers-and-ccs', 144 143 'javelin-behavior-differential-keyboard-navigation',
-2
src/__phutil_library_map__.php
··· 399 399 'DifferentialLandingToHostedGit' => 'applications/differential/landing/DifferentialLandingToHostedGit.php', 400 400 'DifferentialLandingToHostedMercurial' => 'applications/differential/landing/DifferentialLandingToHostedMercurial.php', 401 401 'DifferentialLintField' => 'applications/differential/customfield/DifferentialLintField.php', 402 - 'DifferentialLintFieldSpecification' => 'applications/differential/field/specification/DifferentialLintFieldSpecification.php', 403 402 'DifferentialLintStatus' => 'applications/differential/constants/DifferentialLintStatus.php', 404 403 'DifferentialLocalCommitsView' => 'applications/differential/view/DifferentialLocalCommitsView.php', 405 404 'DifferentialMail' => 'applications/differential/mail/DifferentialMail.php', ··· 452 451 'DifferentialTransactionQuery' => 'applications/differential/query/DifferentialTransactionQuery.php', 453 452 'DifferentialTransactionView' => 'applications/differential/view/DifferentialTransactionView.php', 454 453 'DifferentialUnitField' => 'applications/differential/customfield/DifferentialUnitField.php', 455 - 'DifferentialUnitFieldSpecification' => 'applications/differential/field/specification/DifferentialUnitFieldSpecification.php', 456 454 'DifferentialUnitStatus' => 'applications/differential/constants/DifferentialUnitStatus.php', 457 455 'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php', 458 456 'DifferentialViewPolicyField' => 'applications/differential/customfield/DifferentialViewPolicyField.php',
+13
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 336 336 $comment_form = new DifferentialAddCommentView(); 337 337 $comment_form->setRevision($revision); 338 338 339 + $review_warnings = array(); 340 + foreach ($field_list->getFields() as $field) { 341 + $review_warnings[] = $field->getWarningsForDetailView(); 342 + } 343 + $review_warnings = array_mergev($review_warnings); 344 + 345 + if ($review_warnings) { 346 + $review_warnings_panel = id(new AphrontErrorView()) 347 + ->setSeverity(AphrontErrorView::SEVERITY_WARNING) 348 + ->setErrors($review_warnings); 349 + $comment_form->setErrorView($review_warnings_panel); 350 + } 351 + 339 352 // TODO: Restore the ability for fields to add accept warnings. 340 353 341 354 $comment_form->setActions($this->getRevisionCommentActions($revision));
+6
src/applications/differential/customfield/DifferentialCustomField.php
··· 76 76 return implode(', ', $out); 77 77 } 78 78 79 + public function getWarningsForDetailView() { 80 + if ($this->getProxy()) { 81 + return $this->getProxy()->getWarningsForDetailView(); 82 + } 83 + return array(); 84 + } 79 85 80 86 /* -( Integration with Commit Messages )----------------------------------- */ 81 87
+21
src/applications/differential/customfield/DifferentialLintField.php
··· 233 233 234 234 return "Show Full Lint Results (".implode(', ', $show).")"; 235 235 } 236 + 237 + public function getWarningsForDetailView() { 238 + $status = $this->getObject()->getActiveDiff()->getLintStatus(); 239 + if ($status < DifferentialLintStatus::LINT_WARN) { 240 + return array(); 241 + } 242 + 243 + $warnings = array(); 244 + if ($status == DifferentialLintStatus::LINT_SKIP) { 245 + $warnings[] = pht( 246 + 'Lint was skipped when generating these changes.'); 247 + } else if ($status == DifferentialLintStatus::LINT_POSTPONED) { 248 + $warnings[] = pht( 249 + 'Background linting has not finished executing on these changes.'); 250 + } else { 251 + $warnings[] = pht('These changes have lint problems.'); 252 + } 253 + 254 + return $warnings; 255 + } 256 + 236 257 }
+20
src/applications/differential/customfield/DifferentialUnitField.php
··· 203 203 return "Show Full Unit Results (".implode(', ', $show).")"; 204 204 } 205 205 206 + public function getWarningsForDetailView() { 207 + $status = $this->getObject()->getActiveDiff()->getUnitStatus(); 208 + 209 + $warnings = array(); 210 + if ($status < DifferentialUnitStatus::UNIT_WARN) { 211 + // Don't show any warnings. 212 + } else if ($status == DifferentialUnitStatus::UNIT_POSTPONED) { 213 + $warnings[] = pht( 214 + 'Background tests have not finished executing on these changes.'); 215 + } else if ($status == DifferentialUnitStatus::UNIT_SKIP) { 216 + $warnings[] = pht( 217 + 'Unit tests were skipped when generating these changes.'); 218 + } else { 219 + $warnings[] = pht('These changes have unit test problems.'); 220 + } 221 + 222 + return $warnings; 223 + } 224 + 225 + 206 226 }
-42
src/applications/differential/field/specification/DifferentialLintFieldSpecification.php
··· 1 - <?php 2 - 3 - final class DifferentialLintFieldSpecification { 4 - 5 - public function renderWarningBoxForRevisionAccept() { 6 - $status = $this->getDiff()->getLintStatus(); 7 - if ($status < DifferentialLintStatus::LINT_WARN) { 8 - return null; 9 - } 10 - 11 - $severity = AphrontErrorView::SEVERITY_ERROR; 12 - $titles = array( 13 - DifferentialLintStatus::LINT_WARN => 'Lint Warning', 14 - DifferentialLintStatus::LINT_FAIL => 'Lint Failure', 15 - DifferentialLintStatus::LINT_SKIP => 'Lint Skipped', 16 - DifferentialLintStatus::LINT_POSTPONED => 'Lint Postponed', 17 - ); 18 - 19 - if ($status == DifferentialLintStatus::LINT_SKIP) { 20 - $content = 21 - "This diff was created without running lint. Make sure you are ". 22 - "OK with that before you accept this diff."; 23 - 24 - } else if ($status == DifferentialLintStatus::LINT_POSTPONED) { 25 - $severity = AphrontErrorView::SEVERITY_WARNING; 26 - $content = 27 - "Postponed linters didn't finish yet. Make sure you are OK with ". 28 - "that before you accept this diff."; 29 - 30 - } else { 31 - $content = 32 - "This diff has Lint Problems. Make sure you are OK with them ". 33 - "before you accept this diff."; 34 - } 35 - 36 - return id(new AphrontErrorView()) 37 - ->setSeverity($severity) 38 - ->appendChild(phutil_tag('p', array(), $content)) 39 - ->setTitle(idx($titles, $status, 'Warning')); 40 - } 41 - 42 - }
-38
src/applications/differential/field/specification/DifferentialUnitFieldSpecification.php
··· 1 - <?php 2 - 3 - final class DifferentialUnitFieldSpecification { 4 - 5 - public function renderWarningBoxForRevisionAccept() { 6 - $diff = $this->getDiff(); 7 - $unit_warning = null; 8 - if ($diff->getUnitStatus() >= DifferentialUnitStatus::UNIT_WARN) { 9 - $titles = 10 - array( 11 - DifferentialUnitStatus::UNIT_WARN => 'Unit Tests Warning', 12 - DifferentialUnitStatus::UNIT_FAIL => 'Unit Tests Failure', 13 - DifferentialUnitStatus::UNIT_SKIP => 'Unit Tests Skipped', 14 - DifferentialUnitStatus::UNIT_POSTPONED => 'Unit Tests Postponed' 15 - ); 16 - if ($diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) { 17 - $content = 18 - "This diff has postponed unit tests. The results should be ". 19 - "coming in soon. You should probably wait for them before accepting ". 20 - "this diff."; 21 - } else if ($diff->getUnitStatus() == DifferentialUnitStatus::UNIT_SKIP) { 22 - $content = 23 - "Unit tests were skipped when this diff was created. Make sure ". 24 - "you are OK with that before you accept this diff."; 25 - } else { 26 - $content = 27 - "This diff has Unit Test Problems. Make sure you are OK with ". 28 - "them before you accept this diff."; 29 - } 30 - $unit_warning = id(new AphrontErrorView()) 31 - ->setSeverity(AphrontErrorView::SEVERITY_ERROR) 32 - ->appendChild(phutil_tag('p', array(), $content)) 33 - ->setTitle(idx($titles, $diff->getUnitStatus(), 'Warning')); 34 - } 35 - return $unit_warning; 36 - } 37 - 38 - }
+14 -19
src/applications/differential/view/DifferentialAddCommentView.php
··· 8 8 private $draft; 9 9 private $reviewers = array(); 10 10 private $ccs = array(); 11 + private $errorView; 12 + 13 + public function setErrorView(AphrontErrorView $error_view) { 14 + $this->errorView = $error_view; 15 + return $this; 16 + } 17 + 18 + public function getErrorView() { 19 + return $this->errorView; 20 + } 11 21 12 22 public function setRevision($revision) { 13 23 $this->revision = $revision; ··· 129 139 )); 130 140 131 141 $diff = $revision->loadActiveDiff(); 132 - $warnings = array(); 133 - 134 - Javelin::initBehavior( 135 - 'differential-accept-with-errors', 136 - array( 137 - 'select' => 'comment-action', 138 - 'warnings' => 'warnings', 139 - )); 140 - 141 142 $rev_id = $revision->getID(); 142 143 143 144 Javelin::initBehavior( ··· 156 157 'inline' => 'inline-comment-preview', 157 158 )); 158 159 159 - $warning_container = array(); 160 - foreach ($warnings as $warning) { 161 - if ($warning) { 162 - $warning_container[] = $warning->render(); 163 - } 164 - } 165 - 166 160 $header = id(new PHUIHeaderView()) 167 161 ->setHeader($is_serious ? pht('Add Comment') : pht('Leap Into Action')); 168 162 169 163 $anchor = id(new PhabricatorAnchorView()) 170 164 ->setAnchorName('comment') 171 165 ->setNavigationMarker(true); 172 - 173 - $warn = phutil_tag('div', array('id' => 'warnings'), $warning_container); 174 166 175 167 $loading = phutil_tag( 176 168 'span', ··· 188 180 $comment_box = id(new PHUIObjectBoxView()) 189 181 ->setHeader($header) 190 182 ->appendChild($anchor) 191 - ->appendChild($warn) 192 183 ->appendChild($form); 184 + 185 + if ($this->errorView) { 186 + $comment_box->setErrorView($this->errorView); 187 + } 193 188 194 189 return array($comment_box, $preview); 195 190 }
-25
webroot/rsrc/js/application/differential/behavior-accept-with-errors.js
··· 1 - /** 2 - * @provides javelin-behavior-differential-accept-with-errors 3 - * @requires javelin-behavior 4 - * javelin-dom 5 - */ 6 - 7 - JX.behavior('differential-accept-with-errors', function(config) { 8 - if (config.warnings) { 9 - toggleWarning(); 10 - JX.DOM.listen( 11 - JX.$(config.select), 12 - 'change', 13 - null, 14 - toggleWarning); 15 - } 16 - 17 - function toggleWarning() { 18 - if (JX.$(config.select).value == 'accept') { 19 - JX.DOM.show(JX.$(config.warnings)); 20 - } else { 21 - JX.DOM.hide(JX.$(config.warnings)); 22 - } 23 - } 24 - 25 - });