Skip to content

Commit 5d403d8

Browse files
committed
topic: optionally add test markers.
1 parent a12a481 commit 5d403d8

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

git-topic.perl

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
my @mark = ('.', '?', '-', '+');
1313
my $all = 0;
1414
my $merges = 0;
15+
my $tests = 0;
1516

1617
my @custom_stage;
1718
my @custom_mark;
@@ -20,6 +21,7 @@
2021
"stage=s" => \@custom_stage,
2122
"mark=s" => \@custom_mark,
2223
"merges!" => \$merges,
24+
"tests!" => \$tests,
2325
"all!" => \$all)
2426
or die;
2527

@@ -75,6 +77,46 @@ sub rebase_marker {
7577
return '*';
7678
}
7779

80+
my %atlog_next = ();
81+
my %atlog_test = ();
82+
83+
sub next_marker {
84+
my ($topic) = @_;
85+
return '' if (!$tests);
86+
return '??' if (!exists $atlog_next{$topic});
87+
for ($atlog_next{$topic}) {
88+
my ($merge, $test) = ('*', '*');
89+
if (/rerere ok/) {
90+
$merge = 'R';
91+
} elsif (/conflict (\d+)/) {
92+
if ($1 < 10) {
93+
$merge = $1;
94+
} else {
95+
$merge = 'X';
96+
}
97+
}
98+
$test = 'X' if (/test error/);
99+
return "$merge$test";
100+
}
101+
}
102+
103+
sub test_marker {
104+
my ($commit) = @_;
105+
return '' if (!$tests);
106+
my $tree = `git rev-parse "$commit^{tree}"`;
107+
chomp($tree);
108+
return "?" if (!exists $atlog_test{$tree});
109+
for ($atlog_test{$tree}) {
110+
if (/build error/) {
111+
return 'B';
112+
} elsif (/test error/) {
113+
return 'X';
114+
} else {
115+
return ' ';
116+
}
117+
}
118+
}
119+
78120
sub describe_topic {
79121
my ($topic) = @_;
80122

@@ -90,20 +132,39 @@ sub describe_topic {
90132
}
91133

92134
my @in_next = read_revs_short('^master', $stage[0]);
135+
my @topic = ();
136+
137+
my @topic_pattern = map { "refs/heads/$_" } (@ARGV ? @ARGV : $topic_pattern);
93138

94139
open(TOPIC, '-|', qw(git for-each-ref),
95140
'--sort=-authordate',
96141
'--format=%(objectname) %(authordate) %(refname)',
97-
"refs/heads/$topic_pattern")
142+
@topic_pattern)
98143
or die;
99144

100-
my @topic = ();
101145
while (<TOPIC>) {
102146
chomp;
103147
my ($sha1, $date, $topic) = m|^([0-9a-f]{40})\s(.*?)\srefs/heads/(.+)$|
104148
or next;
105149
push @topic, [$sha1, $date, $topic];
106150
}
151+
close(TOPIC);
152+
153+
if (open(AT, "Meta/AT.log")) {
154+
my $next = `git rev-parse --verify refs/heads/next`;
155+
chomp $next;
156+
while (<AT>) {
157+
if (/^N (.{40}) (.{40}) (.*)$/ && $1 eq $next) {
158+
$atlog_next{$2} = $3;
159+
next;
160+
}
161+
if (/^A (.{40}) (.*)/) {
162+
$atlog_test{$1} = $2;
163+
next;
164+
}
165+
}
166+
close(AT);
167+
}
107168

108169
my @last_merge_to_next = ();
109170

@@ -121,7 +182,9 @@ sub describe_topic {
121182
}
122183
}
123184
124-
print '*' . rebase_marker($sha1, $stage[0], \@in_next);
185+
print '*' .
186+
next_marker($sha1) .
187+
rebase_marker($sha1, $stage[0], \@in_next);
125188
my $count = "";
126189
if (1 < @revs) {
127190
$count = " " . (scalar @revs) . " commits";
@@ -136,6 +199,9 @@ sub describe_topic {
136199
if ($mark < @mark) {
137200
$mark = $mark[$mark];
138201
}
202+
if ($tests) {
203+
$mark = test_marker($item->[0]) . $mark;
204+
}
139205
wrap_print("$mark $item->[1]");
140206
}
141207
}

0 commit comments

Comments
 (0)