Commit 22bc9b9b authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Tim Gardner

UBUNTU: [Debian] git-ubuntu-log -- switch to bug order

Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
parent 4f6ea34b
...@@ -99,7 +99,7 @@ printchanges: ...@@ -99,7 +99,7 @@ printchanges:
@baseCommit=$$(git log --pretty=format:'%H %s' | \ @baseCommit=$$(git log --pretty=format:'%H %s' | \
gawk '/UBUNTU: '".*Ubuntu-`echo $(prev_fullver) | sed 's/+/\\\\+/'`"'$$/ { print $$1; exit }'); \ gawk '/UBUNTU: '".*Ubuntu-`echo $(prev_fullver) | sed 's/+/\\\\+/'`"'$$/ { print $$1; exit }'); \
git log "$$baseCommit"..HEAD | \ git log "$$baseCommit"..HEAD | \
perl -w -f $(DROOT)/scripts/misc/git-ubuntu-log $(ubuntu_log_opts) $(DROOT)/scripts/misc/git-ubuntu-log $(ubuntu_log_opts)
insertchanges: insertchanges:
@perl -w -f $(DROOT)/scripts/misc/insert-changes.pl $(DROOT) $(DEBIAN) @perl -w -f $(DROOT)/scripts/misc/insert-changes.pl $(DROOT) $(DEBIAN)
......
#!/usr/bin/perl -w #!/usr/bin/python3
use strict; import os
use Text::Wrap; import sys
my $kernel_auth = "Upstream Kernel Changes"; import urllib.request
import json
my (%map, @reverts);
my $pstate = 1; # Suck up the git log output and extract the information we need.
my $no_kern_log = 0; bugs = []
my $print_shas = 0; entries = []
my $first_print = 1; entry = None
subject_wait = False
while (@ARGV) { for line in sys.stdin:
my $opt = $ARGV[0]; if line.startswith('commit '):
shift; if entry and 'ignore' not in entry:
if ($opt eq "--no-kern-log") { entries.append(entry)
$no_kern_log = 1; entry = {}
} elsif ($opt eq "--print-shas") { subject_wait = True
$print_shas = 1;
} else { elif line.startswith('Author: '):
print STDERR "Unknown options: $opt\n"; bits = line.strip().split(maxsplit=1)
exit(1); entry['author'] = bits[1]
}
} elif subject_wait and line.startswith(' '):
subject_wait = False
sub check_reverts($) { entry['subject'] = line.strip()
my ($entry) = @_;
my ($check); elif line.startswith(' BugLink: ') and 'launchpad.net' in line:
bits = line.strip().split(maxsplit=1)
foreach $check (reverse @reverts) { bits = bits[1].split('/')
my $desc = "Revert \"" . $entry->{'desc'} . "\""; entry.setdefault('bugs', []).append(bits[-1])
if ($check->{'desc'} eq $desc) {
@reverts = grep($_->{'desc'} ne $desc, @reverts); # Accumulate bug numbers.
return 1; if bits[-1] not in bugs:
} bugs.append(bits[-1])
}
elif line.startswith(' Ignore:'):
return 0; entry['ignore'] = True
}
sub add_entry($) { entries.reverse()
my ($entry) = @_;
my $key = $entry->{'author'}; # Go through the entries and clear out authors for upstream commits.
for entry in entries:
# store description in array, in email->{desc list} map if entry['subject'].startswith('UBUNTU:'):
if (exists $map{$key}) { entry['subject'] = entry['subject'][7:].strip()
# grab ref else:
my $obj = $map{$key}; del entry['author']
# add desc to array # Lump everything without a bug at the bottom.
push(@$obj, $entry); bugs.append('__packaging__')
} else { bugs.append('__mainline__')
# create new array, containing 1 item
my @arr = ($entry); first = True
for bug in bugs:
# store ref to array if not first:
$map{$key} = \@arr; print('')
} first = False
}
if bug == '__packaging__':
sub shortlog_entry($$$$$) { title = 'Miscellaneous Ubuntu changes'
my ($name, $desc, $bug, $cve, $commit) = @_; elif bug == '__mainline__':
my $entry; title = 'Miscellaneous upstream changes'
else:
$desc =~ s#/pub/scm/linux/kernel/git/#/.../#g; bug_info = None
$desc =~ s#\[PATCH\] ##g;
#urllib.request.urlcleanup()
$desc =~ s#^\s*##g; request = urllib.request.Request('https://api.launchpad.net/devel/bugs/' + bug)
$desc =~ s# *UBUNTU: ##g; request.add_header('Cache-Control', 'max-age=0')
with urllib.request.urlopen(request) as response:
$entry->{'desc'} = $desc; data = response.read()
if ($bug ne '') { bug_info = json.loads(data.decode('utf-8'))
$entry->{'bugno'} = $bug;
} title = bug_info['title']
$entry->{'cve'} = $cve; if 'description' in bug_info:
$entry->{'commit'} = $commit; for line in bug_info['description'].split('\n'):
$entry->{'author'} = $name; if line.startswith('Kernel-Description:'):
title = line.split(' ', 1)[1]
if ($desc =~ /^Revert "/) {
push(@reverts, $entry); title += ' (LP: #' + bug + ')'
return;
} print(' * ' + title)
return if check_reverts($entry); for entry in entries:
if (bug == '__packaging__' and 'bugs' not in entry and 'author' in entry) or \
add_entry($entry); (bug == '__mainline__' and 'bugs' not in entry and 'author' not in entry) or \
} ('bugs' in entry and bug in entry['bugs']):
print(' - ' + entry['subject'])
# sort comparison function
sub by_name($$) {
my ($a, $b) = @_;
uc($a) cmp uc($b);
}
sub shortlog_output {
my ($obj, $key, $entry);
foreach $key (sort by_name keys %map) {
next if $key eq $kernel_auth and $no_kern_log;
print "\n" unless $first_print;
$first_print = 0;
# output author
printf " [ %s ]\n\n", $key;
# output author's 1-line summaries
$obj = $map{$key};
foreach $entry (reverse @$obj) {
print wrap(" * ", " ", $entry->{'desc'}) . "\n";
# For non upstream changes, add other info.
if ($key ne $kernel_auth) {
if ($print_shas) {
print " - GIT-SHA " . $entry->{'commit'} .
"\n";
}
}
if (defined($entry->{'bugno'})) {
print " - LP: #" . $entry->{'bugno'} . "\n";
}
if (defined($entry->{'cve'})) {
print " - " . $entry->{'cve'} . "\n";
}
}
}
}
sub changelog_input {
my ($author, $desc, $commit, $entry, $cve);
while (<STDIN>) {
# get commit
if ($pstate == 1) {
next unless /^commit (.*)/;
$commit = $1;
$pstate++;
}
# get author and email
elsif ($pstate == 2) {
my ($email);
next unless /^[Aa]uthor:?\s*(.*?)\s*<(.*)>/;
$author = $1;
$email = $2;
$desc = undef;
$cve = undef;
# cset author fixups
if (!$author) {
$author = $email;
}
$pstate++;
}
# skip to blank line
elsif ($pstate == 3) {
next unless /^\s*$/;
$pstate++;
}
# skip to non-blank line
elsif ($pstate == 4) {
next unless /^\s*?(.*)/;
my $ignore = 0;
my $do_ignore = 0;
my $bug = undef;
my %bugz = ();
my $k;
# skip lines that are obviously not
# a 1-line cset description
next if /^\s*From: /;
chomp;
$desc = $1;
if ($desc =~ /^ *(Revert "|)UBUNTU:/) {
$do_ignore = 1;
} else {
$do_ignore = 0;
$author = $kernel_auth;
$ignore = 1 if $desc =~ /Merge /;
}
while (<STDIN>) {
$ignore = 1 if ($do_ignore && /^ *Ignore: yes/i);
if (/^ *Bug: *(#|)([0-9#,\s]*)\s*$/i) {
foreach $k (split('(,|\s)\s*(#|)', $2)) {
$bugz{$k} = 1 if (($k ne '') and ($k =~ /[0-9]+/));
}
}
elsif (/^ *BugLink: *http.*:\/\/.*\/([0-9]+)/i) {
$bugz{$1} = 1;
}
elsif (/^ *(CVE-.*)/) {
$cve = $1
}
last if /^commit /;
}
$bug = join(", #", sort keys(%bugz));
if (!$ignore) {
&shortlog_entry($author, $desc, $bug,
$cve, $commit, 0);
}
$pstate = 1;
if ($_ && /^commit (.*)/) {
$commit = $1;
$pstate++;
}
}
else {
die "invalid parse state $pstate";
}
}
foreach $entry (@reverts) {
add_entry($entry);
}
}
&changelog_input;
&shortlog_output;
exit(0);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment