Created
January 8, 2014 01:43
-
-
Save globau/8310290 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use autodie; | |
use lib '/opt/bugzilla/bz'; | |
use BugzillaDev; | |
chdir('/opt/bugzilla/repo/bmo/4.2'); | |
info("updating repo"); | |
system 'bzr up'; | |
my $override = shift || 0; | |
$override = 0 if $override =~ /\D/; | |
my $from = $override ? $override : 'tag:current-production'; | |
my @log = `bzr log -r $from.. --include-merged --line`; | |
foreach my $line (@log) { | |
chomp($line); | |
$line =~ s/^\s+//; | |
} | |
my ($production_revno, $staging_revno) = ($override, 0); | |
foreach my $line (@log) { | |
my ($revno) = $line =~ /^([\d\.]+):/; | |
next unless $revno; | |
$staging_revno ||= $revno; | |
if ($line =~ /\bcurrent-production\b/ && !$override) { | |
$production_revno = $revno; | |
} | |
} | |
my @revisions; | |
foreach my $line (@log) { | |
print "$line\n"; | |
unless ($line =~ /^([\d\.]+): .+? \d\d\d\d-\d\d-\d\d.*? (.+)/) { | |
alert("skipping $line"); | |
next; | |
} | |
my ($revno, $message) = ($1, $2); | |
next if $revno eq $production_revno; | |
my $bug_id; | |
if ($message =~ /^Bug (\d+)/i) { | |
$bug_id = $1; | |
} else { | |
info("digging into $revno: $message"); | |
my @details = `bzr log -r $revno --long`; | |
foreach my $detail (@details) { | |
next unless $detail =~ /^\s*fixes bug: https:\/\/bugzilla\.mozilla\.org\/show_bug.cgi\?id=(\d+)/; | |
$bug_id = $1; | |
last; | |
} | |
} | |
if (!$bug_id) { | |
alert("skipping $line"); | |
next; | |
} | |
my $duplicate = 0; | |
foreach my $revisions (@revisions) { | |
if ($revisions->{id} == $bug_id) { | |
$duplicate = 1; | |
last; | |
} | |
} | |
next if $duplicate; | |
info("loading bug $bug_id"); | |
my $summary = getBugSummary($bug_id); | |
unshift @revisions, { | |
id => $bug_id, | |
summary => $summary, | |
}; | |
} | |
if (!@revisions) { | |
die "no new revisions. make sure you run this script before production is updated.\n"; | |
} | |
printf "revisions : %s - %s\n\n", $production_revno + 1, $staging_revno; | |
print "the following changes have been pushed to bugzilla.mozilla.org:\n<ul>\n"; | |
foreach my $revision (@revisions) { | |
printf '<li>[<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=%s" target="_blank">%s</a>] %s</li>%s', | |
$revision->{id}, $revision->{id}, html_escape($revision->{summary}), "\n"; | |
} | |
print "</ul>\n"; | |
print qq#discuss these changes on <a href="https://lists.mozilla.org/listinfo/tools-bmo" target="_blank">mozilla.tools.bmo</a>.\n#; | |
print "\n\n"; | |
print "the following changes have been pushed to bugzilla.mozilla.org:\n\n"; | |
foreach my $revision (@revisions) { | |
printf "https://bugzil.la/%s : %s\n", $revision->{id}, $revision->{summary}; | |
} | |
sub html_escape { | |
my ($s) = @_; | |
$s =~ s/&/&/g; | |
$s =~ s/</</g; | |
$s =~ s/>/>/g; | |
return $s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment