On 03.11.20 17:28, Martin Liška wrote:

I really think the check should support situations where a description
is provided on the next line (first after '\t', so not '\t*') as
you see in the failing test:
That was supposed to happen, but obviously didn't (first condition wrong).
Now done more properly, also because I did find an existing check, which
I missed before.

Successfully tested with --flake8 removed and running flake8 *.py.

Better?

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_empty_regex,
	item_parenthesis_regex): Add.
	(check_for_empty_description): Use them.
	* gcc-changelog/test_email.py (test_emptry_entry_desc,
	test_emptry_entry_desc_2): Add.
	* gcc-changelog/test_patches.txt: Add two testcases for it.

 contrib/gcc-changelog/git_commit.py    |  7 +++--
 contrib/gcc-changelog/test_email.py    | 10 +++++++
 contrib/gcc-changelog/test_patches.txt | 55 ++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 1d0860cddd8..0008865338b 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -155,6 +155,8 @@ 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_empty_regex = re.compile(r'\t(\* \S+ )?\(\S+\):\s*$')
+item_parenthesis_regex = re.compile(r'\t(\*|\(\S+\):)')
 
 LINE_LIMIT = 100
 TAB_WIDTH = 8
@@ -490,9 +492,10 @@ class GitCommit:
     def check_for_empty_description(self):
         for entry in self.changelog_entries:
             for i, line in enumerate(entry.lines):
-                if (star_prefix_regex.match(line) and line.endswith(':') and
+                if (item_empty_regex.match(line) and
                     (i == len(entry.lines) - 1
-                     or star_prefix_regex.match(entry.lines[i + 1]))):
+                     or not entry.lines[i+1].strip()
+                     or item_parenthesis_regex.match(entry.lines[i+1]))):
                     msg = 'missing description of a change'
                     self.errors.append(Error(msg, line))
 
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index 98f2ecd258d..df350a41228 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -370,3 +370,13 @@ 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 of a change'
+
+    def test_emptry_entry_desc_2(self):
+        email = self.from_patch_glob('0001-lto-fix-LTO-debug')
+        assert not email.errors
+        assert len(email.changelog_entries) == 1
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 148d020f23b..bc9cc2e078e 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3235,4 +3235,59 @@ 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
+
+=== 0001-lto-fix-LTO-debug-sections-copying.patch ===
+From 190c04ba36d9c6c3dce41f12012aa97c6d7f22f5 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mli...@suse.cz>
+Date: Mon, 5 Oct 2020 18:03:08 +0200
+Subject: [PATCH] lto: fix LTO debug sections copying.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+libiberty/ChangeLog:
+
+	PR lto/97290
+	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+	Use sh_link of a .symtab_shndx section.
+---
+ libiberty/simple-object-elf.c | 1 -
+ 1 file changed, 0 insertions(+), 1 deletions(-)
+
+diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
+index 7c9d492f6a4..37e73348cb7 100644
+--- a/libiberty/simple-object-elf.c
++++ b/libiberty/simple-object-elf.c
+@@ -1191,1 +1191,0 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
+- 
+-- 
+2.25.1
 

Reply via email to