-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_gerrit_releases.sh
executable file
·41 lines (33 loc) · 1.12 KB
/
get_gerrit_releases.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
releases="$1"
gerrit_releases="https://gerrit-releases.storage.googleapis.com/"
die () {
printf "%s\n" "$@"
exit 1
}
if test -z "$releases"
then
tmpdir=$(mktemp -d) || die "Failed to create temp dir using mktemp."
releases="$tmpdir/gerrit_releases.html"
wget "$gerrit_releases" -O "$releases" ||
die "Failed to wget '$gerrit_releases'."
fi
perl -ne '@a = m/<Key>gerrit-((\d+)\.(\d+)(\.\d+)?)\.war<\/Key><Generation>\d+<\/Generation><MetaGeneration>\d+<\/MetaGeneration><LastModified>([^<]*)<\/LastModified>/gsm;
print "+ Gerrit Code Review ";
my %times;
while (my ($h, $u, $v, $w, $t) = splice (@a, 0, 5)) {
$w = substr $w, 1;
$times{$t} = [$h, $u, $v, $w];
}
my $count = 20;
for my $t (reverse sort keys %times) {
my ($h, $u, $v, $w) = @{$times{$t}};
#print "h: $h, u: $u, v: $v, w: $w, t: $t\n";
my $l = "";
$l = "#$u$v$w" if ($w > 0);
my $c = "";
$c = "," if ($count > 1);
print "[$h](https://www.gerritcodereview.com/$u.$v.html$l)$c\n";
$count--;
last unless ($count > 0);
}' "$releases"