Skip to content

Commit

Permalink
changelog: allow flexible "cherry picked" format.
Browse files Browse the repository at this point in the history
It handles the following:
(cherry picked from commit c0c7270 (testsuite changes only))

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Use regex for cherry pick prefix.
	* gcc-changelog/test_email.py: Test it.
	* gcc-changelog/test_patches.txt: Likewise.
  • Loading branch information
marxin committed Nov 27, 2020
1 parent 0d7d69c commit b8ae081
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions contrib/gcc-changelog/git_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@
item_empty_regex = re.compile(r'\t(\* \S+ )?\(\S+\):\s*$')
item_parenthesis_regex = re.compile(r'\t(\*|\(\S+\):)')
revert_regex = re.compile(r'This reverts commit (?P<hash>\w+).$')
cherry_pick_regex = re.compile(r'cherry picked from commit (?P<hash>\w+)')

LINE_LIMIT = 100
TAB_WIDTH = 8
CO_AUTHORED_BY_PREFIX = 'co-authored-by: '
CHERRY_PICK_PREFIX = '(cherry picked from commit '

REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ',
'acked-by: ', 'tested-by: ', 'reported-by: ',
Expand Down Expand Up @@ -422,14 +422,16 @@ def parse_changelog(self):
continue
elif lowered_line.startswith(REVIEW_PREFIXES):
continue
elif line.startswith(CHERRY_PICK_PREFIX):
commit = line[len(CHERRY_PICK_PREFIX):].rstrip(')')
if self.cherry_pick_commit:
self.errors.append(Error('multiple cherry pick lines',
line))
else:
self.cherry_pick_commit = commit
continue
else:
m = cherry_pick_regex.search(line)
if m:
commit = m.group('hash')
if self.cherry_pick_commit:
msg = 'multiple cherry pick lines'
self.errors.append(Error(msg, line))
else:
self.cherry_pick_commit = commit
continue

# ChangeLog name will be deduced later
if not last_entry:
Expand Down
2 changes: 2 additions & 0 deletions contrib/gcc-changelog/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ def test_parse_git_name_status(self):
def test_backport(self):
email = self.from_patch_glob('0001-asan-fix-RTX-emission.patch')
assert not email.errors
expected_hash = '8cff672cb9a132d3d3158c2edfc9a64b55292b80'
assert email.cherry_pick_commit == expected_hash
assert len(email.changelog_entries) == 1
entry = list(email.to_changelog_entries())[0][1]
assert entry.startswith('2020-06-11 Martin Liska <[email protected]>')
Expand Down
2 changes: 1 addition & 1 deletion contrib/gcc-changelog/test_patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3145,7 +3145,7 @@ gcc/ChangeLog:
by using Pmode instead of ptr_mode.

Co-Authored-By: Jakub Jelinek <[email protected]>
(cherry picked from commit 8cff672cb9a132d3d3158c2edfc9a64b55292b80)
(cherry picked from commit 8cff672cb9a132d3d3158c2edfc9a64b55292b80 (only part))
---
gcc/asan.c | 1 +
1 file changed, 1 insertion(+)
Expand Down

0 comments on commit b8ae081

Please sign in to comment.