REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ',
'acked-by: ', 'tested-by: ', 'reported-by: ',
'suggested-by: ')
+DATE_FORMAT = '%Y-%m-%d'
class Error:
class GitCommit:
def __init__(self, hexsha, date, author, body, modified_files,
- strict=True):
+ strict=True, commit_to_date_hook=None):
self.hexsha = hexsha
self.lines = body
self.modified_files = modified_files
self.top_level_authors = []
self.co_authors = []
self.top_level_prs = []
+ self.cherry_pick_commit = None
+ self.commit_to_date_hook = commit_to_date_hook
project_files = [f for f in self.modified_files
if self.is_changelog_filename(f[0])
elif lowered_line.startswith(REVIEW_PREFIXES):
continue
elif line.startswith(CHERRY_PICK_PREFIX):
+ commit = line[len(CHERRY_PICK_PREFIX):].rstrip(')')
+ self.cherry_pick_commit = commit
continue
# ChangeLog name will be deduced later
err = Error(msg % (entry.folder, changelog_location), file)
self.errors.append(err)
+ @classmethod
+ def format_authors_in_changelog(cls, authors, timestamp, prefix=''):
+ output = ''
+ for i, author in enumerate(authors):
+ if i == 0:
+ output += '%s%s %s\n' % (prefix, timestamp, author)
+ else:
+ output += '%s\t %s\n' % (prefix, author)
+ output += '\n'
+ return output
+
def to_changelog_entries(self, use_commit_ts=False):
+ current_timestamp = self.date.strftime(DATE_FORMAT)
for entry in self.changelog_entries:
output = ''
timestamp = entry.datetime
+ if self.cherry_pick_commit:
+ timestamp = self.commit_to_date_hook(self.cherry_pick_commit)
+ if timestamp:
+ timestamp = timestamp.strftime(DATE_FORMAT)
if not timestamp or use_commit_ts:
- timestamp = self.date.strftime('%Y-%m-%d')
+ timestamp = current_timestamp
authors = entry.authors if entry.authors else [self.author]
# add Co-Authored-By authors to all ChangeLog entries
for author in self.co_authors:
if author not in authors:
authors.append(author)
- for i, author in enumerate(authors):
- if i == 0:
- output += '%s %s\n' % (timestamp, author)
- else:
- output += '\t %s\n' % author
- output += '\n'
+ if self.cherry_pick_commit:
+ output += self.format_authors_in_changelog([self.author],
+ current_timestamp)
+ output += '\tBackported from master:\n'
+ output += self.format_authors_in_changelog(authors,
+ timestamp, '\t')
+ else:
+ output += self.format_authors_in_changelog(authors, timestamp)
for pr in entry.prs:
output += '\t%s\n' % pr
for line in entry.lines:
def parse_git_revisions(repo_path, revisions, strict=False):
repo = Repo(repo_path)
+ def commit_to_date(commit):
+ try:
+ c = repo.commit(commit)
+ return datetime.utcfromtimestamp(c.committed_date)
+ except ValueError:
+ return None
+
parsed_commits = []
if '..' in revisions:
commits = list(repo.iter_commits(revisions))
author = '%s <%s>' % (commit.author.name, commit.author.email)
git_commit = GitCommit(commit.hexsha, date, author,
commit.message.split('\n'), modified_files,
- strict=strict)
+ strict=strict,
+ commit_to_date_hook=commit_to_date)
parsed_commits.append(git_commit)
return parsed_commits
assert len(modified_files) == 3
assert modified_files[1] == ('gcc/ada/libgnat/s-atopar.adb', 'D')
assert modified_files[2] == ('gcc/ada/libgnat/s-aoinar.adb', 'A')
+
+ def test_backport(self):
+ email = self.from_patch_glob('0001-asan-fix-RTX-emission.patch')
+ assert not email.errors
+ assert len(email.changelog_entries) == 1
+ entry = list(email.to_changelog_entries())[0][1]
+ assert entry.startswith('2020-06-11 Martin Liska <mliska@suse.cz>')
+ assert '\tBackported from master:' in entry
+ assert '\t2020-06-11 Martin Liska <mliska@suse.cz>' in entry
+ assert '\t\t Jakub Jelinek <jakub@redhat.com>' in entry
+
--
2.26.2
+
+=== 0001-asan-fix-RTX-emission.patch ===
+From e1d68582022cfa2b1dc76646724b397ba2739439 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Thu, 11 Jun 2020 09:34:41 +0200
+Subject: [PATCH] asan: fix RTX emission for ilp32
+
+gcc/ChangeLog:
+
+ PR sanitizer/95634
+ * asan.c (asan_emit_stack_protection): Fix emission for ilp32
+ by using Pmode instead of ptr_mode.
+
+Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
+(cherry picked from commit 8cff672cb9a132d3d3158c2edfc9a64b55292b80)
+---
+ gcc/asan.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gcc/asan.c b/gcc/asan.c
+index 823eb539993..4ec22162c12 100644
+--- a/gcc/asan.c
++++ b/gcc/asan.c
+@@ -1 +1,2 @@
+
++
+--
+2.27.0
+