Commit 0962b7cb authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Kleber Sacilotto de Souza

UBUNTU: [Packaging] git-ubuntu-log -- handle multiple bugs/cves better

BugLink: http://bugs.launchpad.net/bugs/1743383Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 6f13941a
...@@ -15,14 +15,28 @@ sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) ...@@ -15,14 +15,28 @@ sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
entries = [] entries = []
def add_entry(entry): def add_entry(entry):
if entry and 'ignore' not in entry: if entry and 'ignore' not in entry:
if 'bugs' not in entry and 'cves' in entry: combo = []
for cve in entry['cves']: for bug in entry.get('bugs', []):
if cve not in bugs: combo.append(bug)
bugs.append(cve) for cve in entry.get('cves', []):
combo.append(cve)
combo = sorted(combo)
if len(combo) == 0:
if entry.get('title', "").startswith('UBUNTU'):
combo = '__packaging__'
else:
combo = '__mainline__'
else:
if combo not in keys:
keys.append(combo)
entry['key'] = combo
entries.append(entry) entries.append(entry)
# Suck up the git log output and extract the information we need. # Suck up the git log output and extract the information we need.
bugs = [] keys = []
entry = None entry = None
subject_wait = False subject_wait = False
for line in sys.stdin: for line in sys.stdin:
...@@ -44,10 +58,6 @@ for line in sys.stdin: ...@@ -44,10 +58,6 @@ for line in sys.stdin:
bits = bits[1].split('/') bits = bits[1].split('/')
entry.setdefault('bugs', []).append(bits[-1]) entry.setdefault('bugs', []).append(bits[-1])
# Accumulate bug numbers.
if bits[-1] not in bugs:
bugs.append(bits[-1])
elif line.startswith(' CVE-'): elif line.startswith(' CVE-'):
entry.setdefault('cves', []).append(line.strip()) entry.setdefault('cves', []).append(line.strip())
...@@ -66,17 +76,20 @@ for entry in entries: ...@@ -66,17 +76,20 @@ for entry in entries:
del entry['author'] del entry['author']
# Lump everything without a bug at the bottom. # Lump everything without a bug at the bottom.
bugs.append('__packaging__') keys.append('__packaging__')
bugs.append('__mainline__') keys.append('__mainline__')
emit_nl = False emit_nl = False
for bug in bugs: for key in keys:
if bug == '__packaging__': if key == '__packaging__':
title = 'Miscellaneous Ubuntu changes' title_set = [ 'Miscellaneous Ubuntu changes' ]
elif bug == '__mainline__': elif key == '__mainline__':
title = 'Miscellaneous upstream changes' title_set = [ 'Miscellaneous upstream changes' ]
elif bug.startswith('CVE-'): else:
title = bug title_set = []
for bug in key:
if bug.startswith('CVE-'):
title_set.append(bug)
else: else:
bug_info = None bug_info = None
...@@ -98,28 +111,29 @@ for bug in bugs: ...@@ -98,28 +111,29 @@ for bug in bugs:
title = 'INVALID or PRIVATE BUG' title = 'INVALID or PRIVATE BUG'
title += ' (LP###' + bug + ')' title += ' (LP###' + bug + ')'
title_set.append(title)
emit_title = True emit_title = True
for entry in entries: for entry in entries:
if (bug == '__packaging__' and 'bugs' not in entry and 'cves' not in entry and 'author' in entry) or \ if entry['key'] != key:
(bug == '__mainline__' and 'bugs' not in entry and 'cves' not in entry and 'author' not in entry) or \ continue
('bugs' in entry and bug in entry['bugs']) or \
('cves' in entry and bug in entry['cves']):
if emit_title: if emit_title:
if emit_nl: if emit_nl:
print('') print('')
emit_nl = True emit_nl = True
title_lines = textwrap.wrap(title, 76) title_lines = textwrap.wrap('#// '.join(title_set), 76)
print(' * ' + title_lines[0].replace('LP###', 'LP: #')) print(' * ' + title_lines[0].replace('LP###', 'LP: #').replace('#//', ' //'))
for line in title_lines[1:]: for line in title_lines[1:]:
line = line.replace('LP###', 'LP: #') line = line.replace('LP###', 'LP: #').replace('#//', ' //')
print(' ' + line) print(' ' + line)
emit_title = False emit_title = False
title_lines = textwrap.wrap(entry['subject'], 76) title_lines = textwrap.wrap(entry['subject'], 76)
print(' - ' + title_lines[0]) print(' - ' + title_lines[0])
for line in title_lines[1:]: for line in title_lines[1:]:
line = line.replace('LP###', 'LP: #') line = line.replace('LP###', 'LP: #')
print(' ' + line) print(' ' + line)
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