Changeset View
Changeset View
Standalone View
Standalone View
src/repository/graph/view/ArcanistCommitGraphSetView.php
| Show First 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | if (count($commit_refs) === 1) { | ||||
| $min = head($commit_refs); | $min = head($commit_refs); | ||||
| $max = last($commit_refs); | $max = last($commit_refs); | ||||
| $commit_label = tsprintf( | $commit_label = tsprintf( | ||||
| '%s..%s', | '%s..%s', | ||||
| substr($min->getCommitHash(), 0, 7), | substr($min->getCommitHash(), 0, 7), | ||||
| substr($max->getCommitHash(), 0, 7)); | substr($max->getCommitHash(), 0, 7)); | ||||
| } | } | ||||
| // TODO: Make this a function of terminal width? | $terminal_width = phutil_console_get_terminal_width(); | ||||
| $max_depth = (int)floor(3 + (max(0, $terminal_width - 72) / 6)); | |||||
| $max_depth = 25; | |||||
| if ($depth <= $max_depth) { | if ($depth <= $max_depth) { | ||||
| $indent = str_repeat(' ', ($depth * 2)); | $indent = str_repeat(' ', ($depth * 2)); | ||||
| } else { | } else { | ||||
| $more = ' ... '; | $more = ' ... '; | ||||
| $indent = str_repeat(' ', ($max_depth * 2) - strlen($more)).$more; | $indent = str_repeat(' ', ($max_depth * 2) - strlen($more)).$more; | ||||
| } | } | ||||
| $indent .= '- '; | $indent .= '- '; | ||||
| $empty_indent = str_repeat(' ', strlen($indent)); | $empty_indent = str_repeat(' ', strlen($indent)); | ||||
| $max_width = ($max_depth * 2) + 16; | |||||
| $available_width = $max_width - (min($max_depth, $depth) * 2); | |||||
| $is_first = true; | $is_first = true; | ||||
| $cell = array(); | $cell = array(); | ||||
| foreach ($items as $item) { | foreach ($items as $item) { | ||||
| $marker_ref = idx($item, 'marker'); | $marker_ref = idx($item, 'marker'); | ||||
| if ($marker_ref) { | if ($marker_ref) { | ||||
| $marker_name = $marker_ref->getName(); | |||||
| $marker_name = id(new PhutilUTF8StringTruncator()) | |||||
| ->setMaximumGlyphs($available_width) | |||||
| ->truncateString($marker_name); | |||||
| if ($marker_ref->getIsActive()) { | if ($marker_ref->getIsActive()) { | ||||
| $label = tsprintf( | $label = tsprintf( | ||||
| '<bg:green>**%s**</bg>', | '<bg:green>**%s**</bg>', | ||||
| $marker_ref->getName()); | $marker_name); | ||||
| } else { | } else { | ||||
| $label = tsprintf( | $label = tsprintf( | ||||
| '**%s**', | '**%s**', | ||||
| $marker_ref->getName()); | $marker_name); | ||||
| } | } | ||||
| } else if ($is_first) { | } else if ($is_first) { | ||||
| $label = $commit_label; | $label = $commit_label; | ||||
| } else { | } else { | ||||
| $label = ''; | $label = ''; | ||||
| } | } | ||||
| if ($is_first) { | if ($is_first) { | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | foreach ($items as $item) { | ||||
| $cell[] = tsprintf("%s\n", $revision_label); | $cell[] = tsprintf("%s\n", $revision_label); | ||||
| } | } | ||||
| return $cell; | return $cell; | ||||
| } | } | ||||
| private function drawRevisionStatus(ArcanistRevisionRef $revision_ref) { | private function drawRevisionStatus(ArcanistRevisionRef $revision_ref) { | ||||
| if (phutil_console_get_terminal_width() < 120) { | |||||
| $status = $revision_ref->getStatusShortDisplayName(); | |||||
| } else { | |||||
| $status = $revision_ref->getStatusDisplayName(); | $status = $revision_ref->getStatusDisplayName(); | ||||
| } | |||||
| $ansi_color = $revision_ref->getStatusANSIColor(); | $ansi_color = $revision_ref->getStatusANSIColor(); | ||||
| if ($ansi_color) { | if ($ansi_color) { | ||||
| $status = tsprintf( | $status = tsprintf( | ||||
| sprintf('<fg:%s>%%s</fg>', $ansi_color), | sprintf('<fg:%s>%%s</fg>', $ansi_color), | ||||
| $status); | $status); | ||||
| } | } | ||||
| return tsprintf('%s', $status); | return tsprintf('%s', $status); | ||||
| } | } | ||||
| } | } | ||||