diff --git a/src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php index 41f5f3477..bfa82893b 100644 --- a/src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php +++ b/src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php @@ -1,168 +1,161 @@ <?php final class DifferentialCreateDiffConduitAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.creatediff'; } public function getMethodDescription() { return pht('Create a new Differential diff.'); } protected function defineParamTypes() { $vcs_const = $this->formatStringConstants( array( 'svn', 'git', 'hg', )); $status_const = $this->formatStringConstants( array( 'none', 'skip', 'okay', 'warn', 'fail', - 'postponed', )); return array( 'changes' => 'required list<dict>', 'sourceMachine' => 'required string', 'sourcePath' => 'required string', 'branch' => 'required string', 'bookmark' => 'optional string', 'sourceControlSystem' => 'required '.$vcs_const, 'sourceControlPath' => 'required string', 'sourceControlBaseRevision' => 'required string', 'creationMethod' => 'optional string', 'lintStatus' => 'required '.$status_const, 'unitStatus' => 'required '.$status_const, 'repositoryPHID' => 'optional phid', 'parentRevisionID' => 'deprecated', 'authorPHID' => 'deprecated', 'repositoryUUID' => 'deprecated', ); } protected function defineReturnType() { return 'nonempty dict'; } protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $change_data = $request->getValue('changes'); $changes = array(); foreach ($change_data as $dict) { $changes[] = ArcanistDiffChange::newFromDictionary($dict); } $diff = DifferentialDiff::newFromRawChanges($viewer, $changes); // TODO: Remove repository UUID eventually; for now continue writing // the UUID. Note that we'll overwrite it below if we identify a // repository, and `arc` no longer sends it. This stuff is retained for // backward compatibility. $repository_uuid = $request->getValue('repositoryUUID'); $repository_phid = $request->getValue('repositoryPHID'); if ($repository_phid) { $repository = id(new PhabricatorRepositoryQuery()) ->setViewer($viewer) ->withPHIDs(array($repository_phid)) ->executeOne(); if ($repository) { $repository_phid = $repository->getPHID(); $repository_uuid = $repository->getUUID(); } } switch ($request->getValue('lintStatus')) { case 'skip': $lint_status = DifferentialLintStatus::LINT_SKIP; break; case 'okay': $lint_status = DifferentialLintStatus::LINT_OKAY; break; case 'warn': $lint_status = DifferentialLintStatus::LINT_WARN; break; case 'fail': $lint_status = DifferentialLintStatus::LINT_FAIL; break; - case 'postponed': - $lint_status = DifferentialLintStatus::LINT_POSTPONED; - break; case 'none': default: $lint_status = DifferentialLintStatus::LINT_NONE; break; } switch ($request->getValue('unitStatus')) { case 'skip': $unit_status = DifferentialUnitStatus::UNIT_SKIP; break; case 'okay': $unit_status = DifferentialUnitStatus::UNIT_OKAY; break; case 'warn': $unit_status = DifferentialUnitStatus::UNIT_WARN; break; case 'fail': $unit_status = DifferentialUnitStatus::UNIT_FAIL; break; - case 'postponed': - $unit_status = DifferentialUnitStatus::UNIT_POSTPONED; - break; case 'none': default: $unit_status = DifferentialUnitStatus::UNIT_NONE; break; } $diff_data_dict = array( 'sourcePath' => $request->getValue('sourcePath'), 'sourceMachine' => $request->getValue('sourceMachine'), 'branch' => $request->getValue('branch'), 'creationMethod' => $request->getValue('creationMethod'), 'authorPHID' => $viewer->getPHID(), 'bookmark' => $request->getValue('bookmark'), 'repositoryUUID' => $repository_uuid, 'repositoryPHID' => $repository_phid, 'sourceControlSystem' => $request->getValue('sourceControlSystem'), 'sourceControlPath' => $request->getValue('sourceControlPath'), 'sourceControlBaseRevision' => $request->getValue('sourceControlBaseRevision'), 'lintStatus' => $lint_status, 'unitStatus' => $unit_status, ); $xactions = array( id(new DifferentialTransaction()) ->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE) ->setNewValue($diff_data_dict), ); id(new DifferentialDiffEditor()) ->setActor($viewer) ->setContentSourceFromConduitRequest($request) ->setContinueOnNoEffect(true) ->applyTransactions($diff, $xactions); $path = '/differential/diff/'.$diff->getID().'/'; $uri = PhabricatorEnv::getURI($path); return array( 'diffid' => $diff->getID(), 'phid' => $diff->getPHID(), 'uri' => $uri, ); } } diff --git a/src/applications/differential/constants/DifferentialLintStatus.php b/src/applications/differential/constants/DifferentialLintStatus.php index 4b491db9c..72709b8ee 100644 --- a/src/applications/differential/constants/DifferentialLintStatus.php +++ b/src/applications/differential/constants/DifferentialLintStatus.php @@ -1,13 +1,12 @@ <?php final class DifferentialLintStatus extends Phobject { - const LINT_NONE = 0; - const LINT_OKAY = 1; - const LINT_WARN = 2; - const LINT_FAIL = 3; - const LINT_SKIP = 4; - const LINT_POSTPONED = 5; - const LINT_AUTO_SKIP = 6; + const LINT_NONE = 0; + const LINT_OKAY = 1; + const LINT_WARN = 2; + const LINT_FAIL = 3; + const LINT_SKIP = 4; + const LINT_AUTO_SKIP = 6; } diff --git a/src/applications/differential/constants/DifferentialUnitStatus.php b/src/applications/differential/constants/DifferentialUnitStatus.php index 65275b82b..2b69853df 100644 --- a/src/applications/differential/constants/DifferentialUnitStatus.php +++ b/src/applications/differential/constants/DifferentialUnitStatus.php @@ -1,13 +1,12 @@ <?php final class DifferentialUnitStatus extends Phobject { - const UNIT_NONE = 0; - const UNIT_OKAY = 1; - const UNIT_WARN = 2; - const UNIT_FAIL = 3; - const UNIT_SKIP = 4; - const UNIT_POSTPONED = 5; - const UNIT_AUTO_SKIP = 6; + const UNIT_NONE = 0; + const UNIT_OKAY = 1; + const UNIT_WARN = 2; + const UNIT_FAIL = 3; + const UNIT_SKIP = 4; + const UNIT_AUTO_SKIP = 6; } diff --git a/src/applications/differential/constants/DifferentialUnitTestResult.php b/src/applications/differential/constants/DifferentialUnitTestResult.php index 6ae919cf2..293544a0a 100644 --- a/src/applications/differential/constants/DifferentialUnitTestResult.php +++ b/src/applications/differential/constants/DifferentialUnitTestResult.php @@ -1,12 +1,11 @@ <?php final class DifferentialUnitTestResult extends Phobject { - const RESULT_PASS = 'pass'; - const RESULT_FAIL = 'fail'; - const RESULT_SKIP = 'skip'; - const RESULT_BROKEN = 'broken'; - const RESULT_UNSOUND = 'unsound'; - const RESULT_POSTPONED = 'postponed'; + const RESULT_PASS = 'pass'; + const RESULT_FAIL = 'fail'; + const RESULT_SKIP = 'skip'; + const RESULT_BROKEN = 'broken'; + const RESULT_UNSOUND = 'unsound'; } diff --git a/src/applications/differential/customfield/DifferentialLintField.php b/src/applications/differential/customfield/DifferentialLintField.php index 52be0e393..62b94c51e 100644 --- a/src/applications/differential/customfield/DifferentialLintField.php +++ b/src/applications/differential/customfield/DifferentialLintField.php @@ -1,135 +1,131 @@ <?php final class DifferentialLintField extends DifferentialHarbormasterField { public function getFieldKey() { return 'differential:lint'; } public function getFieldName() { return pht('Lint'); } public function getFieldDescription() { return pht('Shows lint results.'); } public function shouldAppearInPropertyView() { return true; } public function renderPropertyViewValue(array $handles) { return null; } public function shouldAppearInDiffPropertyView() { return true; } public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { return $this->getFieldName(); } protected function getLegacyProperty() { return 'arc:lint'; } protected function getDiffPropertyKeys() { return array( 'arc:lint', 'arc:lint-excuse', ); } protected function loadHarbormasterTargetMessages(array $target_phids) { return id(new HarbormasterBuildLintMessage())->loadAllWhere( 'buildTargetPHID IN (%Ls) LIMIT 25', $target_phids); } protected function newHarbormasterMessageView(array $messages) { return id(new HarbormasterLintPropertyView()) ->setLimit(25) ->setLintMessages($messages); } protected function newModernMessage(array $message) { return HarbormasterBuildLintMessage::newFromDictionary( new HarbormasterBuildTarget(), $this->getModernLintMessageDictionary($message)); } public function getWarningsForDetailView() { $status = $this->getObject()->getActiveDiff()->getLintStatus(); if ($status < DifferentialLintStatus::LINT_WARN) { return array(); } if ($status == DifferentialLintStatus::LINT_AUTO_SKIP) { return array(); } $warnings = array(); if ($status == DifferentialLintStatus::LINT_SKIP) { $warnings[] = pht( 'Lint was skipped when generating these changes.'); - } else if ($status == DifferentialLintStatus::LINT_POSTPONED) { - $warnings[] = pht( - 'Background linting has not finished executing on these changes.'); } else { $warnings[] = pht('These changes have lint problems.'); } return $warnings; } protected function renderHarbormasterStatus( DifferentialDiff $diff, array $messages) { $colors = array( DifferentialLintStatus::LINT_NONE => 'grey', DifferentialLintStatus::LINT_OKAY => 'green', DifferentialLintStatus::LINT_WARN => 'yellow', DifferentialLintStatus::LINT_FAIL => 'red', DifferentialLintStatus::LINT_SKIP => 'blue', DifferentialLintStatus::LINT_AUTO_SKIP => 'blue', - DifferentialLintStatus::LINT_POSTPONED => 'blue', ); $icon_color = idx($colors, $diff->getLintStatus(), 'grey'); $message = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff); $excuse = $diff->getProperty('arc:lint-excuse'); if (strlen($excuse)) { $excuse = array( phutil_tag('strong', array(), pht('Excuse:')), ' ', phutil_escape_html_newlines($excuse), ); } $status = id(new PHUIStatusListView()) ->addItem( id(new PHUIStatusItemView()) ->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color) ->setTarget($message) ->setNote($excuse)); return $status; } private function getModernLintMessageDictionary(array $map) { // Strip out `null` values to satisfy stricter typechecks. foreach ($map as $key => $value) { if ($value === null) { unset($map[$key]); } } // TODO: We might need to remap some stuff here? return $map; } } diff --git a/src/applications/differential/customfield/DifferentialUnitField.php b/src/applications/differential/customfield/DifferentialUnitField.php index b5de9fce5..3883baba8 100644 --- a/src/applications/differential/customfield/DifferentialUnitField.php +++ b/src/applications/differential/customfield/DifferentialUnitField.php @@ -1,202 +1,198 @@ <?php final class DifferentialUnitField extends DifferentialHarbormasterField { public function getFieldKey() { return 'differential:unit'; } public function getFieldName() { return pht('Unit'); } public function getFieldDescription() { return pht('Shows unit test results.'); } public function shouldAppearInPropertyView() { return true; } public function renderPropertyViewValue(array $handles) { return null; } public function shouldAppearInDiffPropertyView() { return true; } public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { return $this->getFieldName(); } protected function getLegacyProperty() { return 'arc:unit'; } protected function getDiffPropertyKeys() { return array( 'arc:unit', 'arc:unit-excuse', ); } protected function loadHarbormasterTargetMessages(array $target_phids) { return id(new HarbormasterBuildUnitMessage())->loadAllWhere( 'buildTargetPHID IN (%Ls)', $target_phids); } protected function newModernMessage(array $message) { return HarbormasterBuildUnitMessage::newFromDictionary( new HarbormasterBuildTarget(), $this->getModernUnitMessageDictionary($message)); } protected function newHarbormasterMessageView(array $messages) { foreach ($messages as $key => $message) { switch ($message->getResult()) { case ArcanistUnitTestResult::RESULT_PASS: case ArcanistUnitTestResult::RESULT_SKIP: // Don't show "Pass" or "Skip" in the UI since they aren't very // interesting. The user can click through to the full results if // they want details. unset($messages[$key]); break; } } if (!$messages) { return null; } return id(new HarbormasterUnitPropertyView()) ->setLimit(10) ->setUnitMessages($messages); } public function getWarningsForDetailView() { $status = $this->getObject()->getActiveDiff()->getUnitStatus(); $warnings = array(); if ($status < DifferentialUnitStatus::UNIT_WARN) { // Don't show any warnings. } else if ($status == DifferentialUnitStatus::UNIT_AUTO_SKIP) { // Don't show any warnings. - } else if ($status == DifferentialUnitStatus::UNIT_POSTPONED) { - $warnings[] = pht( - 'Background tests have not finished executing on these changes.'); } else if ($status == DifferentialUnitStatus::UNIT_SKIP) { $warnings[] = pht( 'Unit tests were skipped when generating these changes.'); } else { $warnings[] = pht('These changes have unit test problems.'); } return $warnings; } protected function renderHarbormasterStatus( DifferentialDiff $diff, array $messages) { $colors = array( DifferentialUnitStatus::UNIT_NONE => 'grey', DifferentialUnitStatus::UNIT_OKAY => 'green', DifferentialUnitStatus::UNIT_WARN => 'yellow', DifferentialUnitStatus::UNIT_FAIL => 'red', DifferentialUnitStatus::UNIT_SKIP => 'blue', DifferentialUnitStatus::UNIT_AUTO_SKIP => 'blue', - DifferentialUnitStatus::UNIT_POSTPONED => 'blue', ); $icon_color = idx($colors, $diff->getUnitStatus(), 'grey'); $message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff); $note = array(); $groups = mgroup($messages, 'getResult'); $groups = array_select_keys( $groups, array( ArcanistUnitTestResult::RESULT_FAIL, ArcanistUnitTestResult::RESULT_BROKEN, ArcanistUnitTestResult::RESULT_UNSOUND, ArcanistUnitTestResult::RESULT_SKIP, ArcanistUnitTestResult::RESULT_PASS, )) + $groups; foreach ($groups as $result => $group) { $count = new PhutilNumber(count($group)); switch ($result) { case ArcanistUnitTestResult::RESULT_PASS: $note[] = pht('%s Passed Test(s)', $count); break; case ArcanistUnitTestResult::RESULT_FAIL: $note[] = pht('%s Failed Test(s)', $count); break; case ArcanistUnitTestResult::RESULT_SKIP: $note[] = pht('%s Skipped Test(s)', $count); break; case ArcanistUnitTestResult::RESULT_BROKEN: $note[] = pht('%s Broken Test(s)', $count); break; case ArcanistUnitTestResult::RESULT_UNSOUND: $note[] = pht('%s Unsound Test(s)', $count); break; default: $note[] = pht('%s Other Test(s)', $count); break; } } $buildable = $diff->getBuildable(); if ($buildable) { $full_results = '/harbormaster/unit/'.$buildable->getID().'/'; $note[] = phutil_tag( 'a', array( 'href' => $full_results, ), pht('View Full Results')); } $excuse = $diff->getProperty('arc:unit-excuse'); if (strlen($excuse)) { $excuse = array( phutil_tag('strong', array(), pht('Excuse:')), ' ', phutil_escape_html_newlines($excuse), ); $note[] = $excuse; } $note = phutil_implode_html(" \xC2\xB7 ", $note); $status = id(new PHUIStatusListView()) ->addItem( id(new PHUIStatusItemView()) ->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color) ->setTarget($message) ->setNote($note)); return $status; } private function getModernUnitMessageDictionary(array $map) { // Strip out `null` values to satisfy stricter typechecks. foreach ($map as $key => $value) { if ($value === null) { unset($map[$key]); } } // TODO: Remap more stuff here? return $map; } } diff --git a/src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php index 27d071aa6..082344a49 100644 --- a/src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php @@ -1,438 +1,432 @@ <?php final class DifferentialRevisionUpdateHistoryView extends AphrontView { private $diffs = array(); private $selectedVersusDiffID; private $selectedDiffID; private $selectedWhitespace; private $commitsForLinks = array(); public function setDiffs(array $diffs) { assert_instances_of($diffs, 'DifferentialDiff'); $this->diffs = $diffs; return $this; } public function setSelectedVersusDiffID($id) { $this->selectedVersusDiffID = $id; return $this; } public function setSelectedDiffID($id) { $this->selectedDiffID = $id; return $this; } public function setSelectedWhitespace($whitespace) { $this->selectedWhitespace = $whitespace; return $this; } public function setCommitsForLinks(array $commits) { assert_instances_of($commits, 'PhabricatorRepositoryCommit'); $this->commitsForLinks = $commits; return $this; } public function render() { $this->requireResource('differential-core-view-css'); $this->requireResource('differential-revision-history-css'); $data = array( array( 'name' => pht('Base'), 'id' => null, 'desc' => pht('Base'), 'age' => null, 'obj' => null, ), ); $seq = 0; foreach ($this->diffs as $diff) { $data[] = array( 'name' => pht('Diff %d', ++$seq), 'id' => $diff->getID(), 'desc' => $diff->getDescription(), 'age' => $diff->getDateCreated(), 'obj' => $diff, ); } $max_id = $diff->getID(); $revision_id = $diff->getRevisionID(); $idx = 0; $rows = array(); $disable = false; $radios = array(); $last_base = null; $rowc = array(); foreach ($data as $row) { $diff = $row['obj']; $name = $row['name']; $id = $row['id']; $old_class = false; $new_class = false; if ($id) { $new_checked = ($this->selectedDiffID == $id); $new = javelin_tag( 'input', array( 'type' => 'radio', 'name' => 'id', 'value' => $id, 'checked' => $new_checked ? 'checked' : null, 'sigil' => 'differential-new-radio', )); if ($new_checked) { $new_class = true; $disable = true; } $new = phutil_tag( 'div', array( 'class' => 'differential-update-history-radio', ), $new); } else { $new = null; } if ($max_id != $id) { $uniq = celerity_generate_unique_node_id(); $old_checked = ($this->selectedVersusDiffID == $id); $old = phutil_tag( 'input', array( 'type' => 'radio', 'name' => 'vs', 'value' => $id, 'id' => $uniq, 'checked' => $old_checked ? 'checked' : null, 'disabled' => $disable ? 'disabled' : null, )); $radios[] = $uniq; if ($old_checked) { $old_class = true; } $old = phutil_tag( 'div', array( 'class' => 'differential-update-history-radio', ), $old); } else { $old = null; } $desc = $row['desc']; if ($row['age']) { $age = phabricator_datetime($row['age'], $this->getUser()); } else { $age = null; } if ($diff) { $lint = self::renderDiffLintStar($row['obj']); $lint = phutil_tag( 'div', array( 'class' => 'lintunit-star', 'title' => self::getDiffLintMessage($diff), ), $lint); $unit = self::renderDiffUnitStar($row['obj']); $unit = phutil_tag( 'div', array( 'class' => 'lintunit-star', 'title' => self::getDiffUnitMessage($diff), ), $unit); $base = $this->renderBaseRevision($diff); } else { $lint = null; $unit = null; $base = null; } if ($last_base !== null && $base !== $last_base) { // TODO: Render some kind of notice about rebases. } $last_base = $base; if ($revision_id) { $id_link = phutil_tag( 'a', array( 'href' => '/D'.$revision_id.'?id='.$id, ), $id); } else { $id_link = phutil_tag( 'a', array( 'href' => '/differential/diff/'.$id.'/', ), $id); } $rows[] = array( $name, $id_link, $base, $desc, $age, $lint, $unit, $old, $new, ); $classes = array(); if ($old_class) { $classes[] = 'differential-update-history-old-now'; } if ($new_class) { $classes[] = 'differential-update-history-new-now'; } $rowc[] = nonempty(implode(' ', $classes), null); } Javelin::initBehavior( 'differential-diff-radios', array( 'radios' => $radios, )); $options = array( DifferentialChangesetParser::WHITESPACE_IGNORE_ALL => pht('Ignore All'), DifferentialChangesetParser::WHITESPACE_IGNORE_MOST => pht('Ignore Most'), DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING => pht('Ignore Trailing'), DifferentialChangesetParser::WHITESPACE_SHOW_ALL => pht('Show All'), ); foreach ($options as $value => $label) { $options[$value] = phutil_tag( 'option', array( 'value' => $value, 'selected' => ($value == $this->selectedWhitespace) ? 'selected' : null, ), $label); } $select = phutil_tag('select', array('name' => 'whitespace'), $options); $table = id(new AphrontTableView($rows)); $table->setHeaders( array( pht('Diff'), pht('ID'), pht('Base'), pht('Description'), pht('Created'), pht('Lint'), pht('Unit'), '', '', )); $table->setColumnClasses( array( 'pri', '', '', 'wide', 'date', 'center', 'center', 'center differential-update-history-old', 'center differential-update-history-new', )); $table->setRowClasses($rowc); $table->setDeviceVisibility( array( true, true, false, true, false, false, false, true, true, )); $show_diff = phutil_tag( 'div', array( 'class' => 'differential-update-history-footer', ), array( phutil_tag( 'label', array(), array( pht('Whitespace Changes:'), $select, )), phutil_tag( 'button', array(), pht('Show Diff')), )); $content = phabricator_form( $this->getUser(), array( 'action' => '#toc', ), array( $table, $show_diff, )); return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Revision Update History')) ->setFlush(true) ->setTable($content); } const STAR_NONE = 'none'; const STAR_OKAY = 'okay'; const STAR_WARN = 'warn'; const STAR_FAIL = 'fail'; const STAR_SKIP = 'skip'; public static function renderDiffLintStar(DifferentialDiff $diff) { static $map = array( DifferentialLintStatus::LINT_NONE => self::STAR_NONE, DifferentialLintStatus::LINT_OKAY => self::STAR_OKAY, DifferentialLintStatus::LINT_WARN => self::STAR_WARN, DifferentialLintStatus::LINT_FAIL => self::STAR_FAIL, DifferentialLintStatus::LINT_SKIP => self::STAR_SKIP, DifferentialLintStatus::LINT_AUTO_SKIP => self::STAR_SKIP, - DifferentialLintStatus::LINT_POSTPONED => self::STAR_SKIP, ); $star = idx($map, $diff->getLintStatus(), self::STAR_FAIL); return self::renderDiffStar($star); } public static function renderDiffUnitStar(DifferentialDiff $diff) { static $map = array( DifferentialUnitStatus::UNIT_NONE => self::STAR_NONE, DifferentialUnitStatus::UNIT_OKAY => self::STAR_OKAY, DifferentialUnitStatus::UNIT_WARN => self::STAR_WARN, DifferentialUnitStatus::UNIT_FAIL => self::STAR_FAIL, DifferentialUnitStatus::UNIT_SKIP => self::STAR_SKIP, DifferentialUnitStatus::UNIT_AUTO_SKIP => self::STAR_SKIP, - DifferentialUnitStatus::UNIT_POSTPONED => self::STAR_SKIP, ); $star = idx($map, $diff->getUnitStatus(), self::STAR_FAIL); return self::renderDiffStar($star); } public static function getDiffLintMessage(DifferentialDiff $diff) { switch ($diff->getLintStatus()) { case DifferentialLintStatus::LINT_NONE: return pht('No Linters Available'); case DifferentialLintStatus::LINT_OKAY: return pht('Lint OK'); case DifferentialLintStatus::LINT_WARN: return pht('Lint Warnings'); case DifferentialLintStatus::LINT_FAIL: return pht('Lint Errors'); case DifferentialLintStatus::LINT_SKIP: return pht('Lint Skipped'); case DifferentialLintStatus::LINT_AUTO_SKIP: return pht('Automatic diff as part of commit; lint not applicable.'); - case DifferentialLintStatus::LINT_POSTPONED: - return pht('Lint Postponed'); } return pht('Unknown'); } public static function getDiffUnitMessage(DifferentialDiff $diff) { switch ($diff->getUnitStatus()) { case DifferentialUnitStatus::UNIT_NONE: return pht('No Unit Test Coverage'); case DifferentialUnitStatus::UNIT_OKAY: return pht('Unit Tests OK'); case DifferentialUnitStatus::UNIT_WARN: return pht('Unit Test Warnings'); case DifferentialUnitStatus::UNIT_FAIL: return pht('Unit Test Errors'); case DifferentialUnitStatus::UNIT_SKIP: return pht('Unit Tests Skipped'); case DifferentialUnitStatus::UNIT_AUTO_SKIP: return pht( 'Automatic diff as part of commit; unit tests not applicable.'); - case DifferentialUnitStatus::UNIT_POSTPONED: - return pht('Unit Tests Postponed'); } return pht('Unknown'); } private static function renderDiffStar($star) { $class = 'diff-star-'.$star; return phutil_tag( 'span', array('class' => $class), "\xE2\x98\x85"); } private function renderBaseRevision(DifferentialDiff $diff) { switch ($diff->getSourceControlSystem()) { case 'git': $base = $diff->getSourceControlBaseRevision(); if (strpos($base, '@') === false) { $label = substr($base, 0, 7); } else { // The diff is from git-svn $base = explode('@', $base); $base = last($base); $label = $base; } break; case 'svn': $base = $diff->getSourceControlBaseRevision(); $base = explode('@', $base); $base = last($base); $label = $base; break; default: $label = null; break; } $link = null; if ($label) { $commit_for_link = idx( $this->commitsForLinks, $diff->getSourceControlBaseRevision()); if ($commit_for_link) { $link = phutil_tag( 'a', array('href' => $commit_for_link->getURI()), $label); } else { $link = $label; } } return $link; } } diff --git a/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php b/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php index 107272246..2614c2574 100644 --- a/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php +++ b/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php @@ -1,101 +1,100 @@ <?php final class HarbormasterUnitPropertyView extends AphrontView { private $pathURIMap = array(); private $unitMessages = array(); private $limit; public function setPathURIMap(array $map) { $this->pathURIMap = $map; return $this; } public function setUnitMessages(array $messages) { assert_instances_of($messages, 'HarbormasterBuildUnitMessage'); $this->unitMessages = $messages; return $this; } public function setLimit($limit) { $this->limit = $limit; return $this; } public function render() { $messages = $this->unitMessages; $messages = msort($messages, 'getSortKey'); if ($this->limit) { $messages = array_slice($messages, 0, $this->limit); } $rows = array(); $any_duration = false; foreach ($messages as $message) { $result = $this->renderResult($message->getResult()); $duration = $message->getDuration(); if ($duration !== null) { $any_duration = true; $duration = pht('%s ms', new PhutilNumber((int)(1000 * $duration))); } $name = $message->getName(); $namespace = $message->getNamespace(); if (strlen($namespace)) { $name = $namespace.'::'.$name; } $engine = $message->getEngine(); if (strlen($engine)) { $name = $engine.' > '.$name; } $rows[] = array( $result, $duration, $name, ); } $table = id(new AphrontTableView($rows)) ->setHeaders( array( pht('Result'), pht('Time'), pht('Test'), )) ->setColumnClasses( array( null, null, 'pri wide', )) ->setColumnVisibility( array( true, $any_duration, )); return $table; } private function renderResult($result) { $names = array( ArcanistUnitTestResult::RESULT_BROKEN => pht('Broken'), ArcanistUnitTestResult::RESULT_FAIL => pht('Failed'), ArcanistUnitTestResult::RESULT_UNSOUND => pht('Unsound'), ArcanistUnitTestResult::RESULT_SKIP => pht('Skipped'), - ArcanistUnitTestResult::RESULT_POSTPONED => pht('Postponed'), ArcanistUnitTestResult::RESULT_PASS => pht('Passed'), ); $result = idx($names, $result, $result); // TODO: Add some color. return $result; } }