diff mbox series

[+,RFC,contrib] gcc-changelog/git_commit.py: Check for missing description

Message ID 7ac9cc26-f5d6-4825-6253-3c92ec3b2cb5@codesourcery.com
State New
Headers show
Series [+,RFC,contrib] gcc-changelog/git_commit.py: Check for missing description | expand

Commit Message

Tobias Burnus Oct. 30, 2020, 1:16 p.m. UTC
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

Comments

Martin Liška Nov. 3, 2020, 4:28 p.m. UTC | #1
On 10/30/20 2:16 PM, Tobias Burnus wrote:
> 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.

Hello.

Please apply this hunk separately, it's fine.

> 
> 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.

Thanks for it.

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:

     libiberty/ChangeLog:
     
             PR lto/97290
             * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
             Use sh_link of a .symtab_shndx section.

Martin

> 
> 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
Martin Liška Nov. 3, 2020, 4:29 p.m. UTC | #2
On 10/30/20 2:16 PM, Tobias Burnus wrote:
> 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

... and please move

+        unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')

to the toplevel of the file.

Thanks,
Martin
Tobias Burnus Nov. 3, 2020, 6:46 p.m. UTC | #3
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
Martin Liška Nov. 4, 2020, 9:08 a.m. UTC | #4
On 11/3/20 7:46 PM, Tobias Burnus wrote:
> 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.

Yes, it works nice! I've just verified that for git gcc-verify  misc/first-auto-changelog..HEAD
it found 6 errors that are all valid.

Thanks for working on that. Please install the patch.
Martin

> 
> 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
diff mbox series

Patch

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 <jason@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  <jason@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