In terms of issues, it seems as if Ubuntu 20.04.1 LTS has a too
old unidiff – I copied the check from test_email.py and applied
it to git_email.py – otherwise, nearly all tests fail.

Still, I do see some fails – I have attached the fails I got.
(fails.log, second attachment)

Independent of that, I have now written a check for an empty
description.

OK for the patch and thoughts about the fails?

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
gcc-changelog/git_commit.py: Check for missing description

Especially when using mklog.py, it is simply to forget to fill in
the entries after the '\t* file.c (section):' or '\t(section):'.

contrib/ChangeLog:

	* gcc-changelog/git_commit.py (item_parenthesis_regex): Add.
	(parse_changelog): Detect missing descriptions.
	* gcc-changelog/git_email.py: Add unidiff_supports_renaming check.
	* gcc-changelog/test_email.py (test_emptry_entry_desc): Add.
	* gcc-changelog/test_patches.txt: Add testcase for it.

 contrib/gcc-changelog/git_commit.py    |  9 +++++++++
 contrib/gcc-changelog/git_email.py     |  5 +++--
 contrib/gcc-changelog/test_email.py    |  5 +++++
 contrib/gcc-changelog/test_patches.txt | 28 ++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 1d0860cddd8..6adea9124fd 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -155,6 +155,7 @@ pr_regex = re.compile(r'\tPR (?P<component>[a-z+-]+\/)?([0-9]+)$')
 dr_regex = re.compile(r'\tDR ([0-9]+)$')
 star_prefix_regex = re.compile(r'\t\*(?P<spaces>\ *)(?P<content>.*)')
 end_of_location_regex = re.compile(r'[\[<(:]')
+item_parenthesis_regex = re.compile(r'\t(\* \S+ )?\(\S+\):\s*$')
 
 LINE_LIMIT = 100
 TAB_WIDTH = 8
@@ -474,6 +475,14 @@ class GitCommit:
                             self.errors.append(Error(msg, line))
                         else:
                             last_entry.lines.append(line)
+        for entry in self.changelog_entries:
+            for idx, line in enumerate(entry.lines):
+                print (line)
+                if item_parenthesis_regex.match(line) and \
+                   (idx+1 not in entry.lines or \
+                    item_parenthesis_regex.match(entry.lines[idx+1])):
+                    msg = 'Missing description for item'
+                    self.errors.append(Error(msg, line))
 
     def parse_file_names(self):
         for entry in self.changelog_entries:
diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index 014fdd1004b..ef054d58d52 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -24,7 +24,7 @@ from dateutil.parser import parse
 
 from git_commit import GitCommit, GitInfo
 
-from unidiff import PatchSet
+from unidiff import PatchSet, PatchedFile
 
 DATE_PREFIX = 'Date: '
 FROM_PREFIX = 'From: '
@@ -49,6 +49,7 @@ class GitEmail(GitCommit):
         body = lines[len(header) + 1:]
 
         modified_files = []
+        unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')
         for f in diff:
             # Strip "a/" and "b/" prefixes
             source = f.source_file[2:]
@@ -58,7 +59,7 @@ class GitEmail(GitCommit):
                 t = 'A'
             elif f.is_removed_file:
                 t = 'D'
-            elif f.is_rename:
+            elif unidiff_supports_renaming and f.is_rename:
                 # Consider that renamed files are two operations: the deletion
                 # of the original name and the addition of the new one.
                 modified_files.append((source, 'D'))
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index 98f2ecd258d..3020f152192 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -370,3 +370,8 @@ class TestGccChangelog(unittest.TestCase):
         email = self.from_patch_glob('0001-tree-optimization-97633-fix')
         assert len(email.errors) == 1
         assert email.errors[0].message == 'empty group "()" found'
+
+    def test_emptry_entry_desc(self):
+        email = self.from_patch_glob('0001-c-Set-CALL_FROM_NEW_OR')
+        assert len(email.errors) == 1
+        assert email.errors[0].message == 'Missing description for item'
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 148d020f23b..b1b85a4abc4 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3235,4 +3235,32 @@ index 5d69a98c2a9..714e50697bd 100644
 -- 
 
 2.7.4
+=== 0001-c-Set-CALL_FROM_NEW_OR_DELETE_P-on-more-calls.patch ===
+From 4f4ced28826ece7b7b76649522ee2a9601a63b90 Mon Sep 17 00:00:00 2001
+From: Jason Merrill <ja...@redhat.com>
+Date: Fri, 2 Oct 2020 09:00:49 +0200
+Subject: [PATCH] c++: Set CALL_FROM_NEW_OR_DELETE_P on more calls.
+
+We were failing to set the flag on a delete call in a new expression, in a
+deleting destructor, and in a coroutine.  Fixed by setting it in the
+function that builds the call.
+
+2020-10-02  Jason Merril  <ja...@redhat.com>
+
+gcc/cp/ChangeLog:
+	* init.c (build_new_1, build_vec_delete_1, build_delete): Not here.
+	(build_delete):
+
+---
+ gcc/cp/init.c                  |  1 -
+ 1 files changed, 0 insertions(+), 1 deletions(-)
+
+diff --git a/gcc/cp/init.c b/gcc/cp/init.c
+index e84e985492d..00fff3f7327 100644
+--- a/gcc/cp/init.c
++++ b/gcc/cp/init.c
+@@ -3436,1 +3435,0 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
+-
+-- 
+2.25.1
 
============================= test session starts ==============================
platform linux -- Python 3.8.5, pytest-4.6.9, py-1.8.1, pluggy-0.13.0
rootdir: /lhome/tburnus/repos/gcc/contrib/gcc-changelog
collected 48 items

test_email.py ....F.................F...........s.............           [100%]

=================================== FAILURES ===================================
______________ TestGccChangelog.test_cannot_deduce_no_blank_line _______________

self = <test_email.TestGccChangelog testMethod=test_cannot_deduce_no_blank_line>

    def test_cannot_deduce_no_blank_line(self):
        email = self.from_patch_glob('0334')
>       assert len(email.errors) == 1
E       AssertionError: assert 2 == 1
E        +  where 2 = len([Missing description for item:"	* config/i386/i386-features.c (make_resolver_func):", could not deduce ChangeLog file, not unique location])
E        +    where [Missing description for item:"	* config/i386/i386-features.c (make_resolver_func):", could not deduce ChangeLog file, not unique location] = <git_email.GitEmail object at 0x7f534c8fa1f0>.errors

test_email.py:136: AssertionError
----------------------------- Captured stdout call -----------------------------
	* config/i386/i386-features.c (make_resolver_func):
	Align the code with ppc64 target implementation.
	Do not generate a unique name for resolver function.
	* gcc.target/i386/pr81213.c: Adjust to not expect
	a globally unique name.
_______________ TestGccChangelog.test_missing_change_description _______________

self = <test_email.TestGccChangelog testMethod=test_missing_change_description>

    def test_missing_change_description(self):
        email = self.from_patch_glob('0001-Missing-change-description.patch')
>       assert len(email.errors) == 2
E       AssertionError: assert 4 == 2
E        +  where 4 = len([Missing description for item:"	* ipa-icf-gimple.c (compare_gimple_asm):", Missing description for item:"	* ipa-icf-gi... ipa-icf-gimple.c (compare_gimple_asm):", missing description of a change:"	* ipa-icf-gimple3.c (compare_gimple_asm):"])
E        +    where [Missing description for item:"	* ipa-icf-gimple.c (compare_gimple_asm):", Missing description for item:"	* ipa-icf-gi... ipa-icf-gimple.c (compare_gimple_asm):", missing description of a change:"	* ipa-icf-gimple3.c (compare_gimple_asm):"] = <git_email.GitEmail object at 0x7f534c7d11c0>.errors

test_email.py:327: AssertionError
----------------------------- Captured stdout call -----------------------------
	* ipa-icf-gimple.c (compare_gimple_asm):
	* ipa-icf-gimple2.c (compare_gimple_asm): Good.
	* ipa-icf-gimple3.c (compare_gimple_asm):
================ 2 failed, 45 passed, 1 skipped in 0.11 seconds ================

Reply via email to