public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4776] gcc-changelog: Add warning for auto-added files
@ 2022-12-19 11:13 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2022-12-19 11:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2b2cec58ff502966004f79d1c9a2862c756b8509

commit r13-4776-g2b2cec58ff502966004f79d1c9a2862c756b8509
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Dec 19 12:12:16 2022 +0100

    gcc-changelog: Add warning for auto-added files
    
    git_email.py prints now a warning for files added automatically.
    git_check_commit.py does likewise but only with --verbose.
    It prints one line per ChangeLog file, either stating the file
    or if more than one the number of files.
    
    contrib/ChangeLog:
    
            * gcc-changelog/git_check_commit.py (__main__): With -v print a
            warning for the auto-added files.
            * gcc-changelog/git_commit.py (GitCommit.__init__): Add self.warnings.
            (GitCommit.check_mentioned_files): Add warning for auto-added files.
            (GitCommit.print_warnings): New function.
            * gcc-changelog/git_email.py (__main__): Remove bogus argument to
            GitEmail constructor; print auto-added-files warning.
            * gcc-changelog/test_email.py (test_auto_add_file_1,
            test_auto_add_file_2): New tests.
            * gcc-changelog/test_patches.txt: Add two test cases.

Diff:
---
 contrib/gcc-changelog/git_check_commit.py |  6 ++
 contrib/gcc-changelog/git_commit.py       | 15 +++++
 contrib/gcc-changelog/git_email.py        |  5 +-
 contrib/gcc-changelog/test_email.py       | 14 +++++
 contrib/gcc-changelog/test_patches.txt    | 96 +++++++++++++++++++++++++++++++
 5 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py
index 2e3e8cbeb77..2b9f2381f20 100755
--- a/contrib/gcc-changelog/git_check_commit.py
+++ b/contrib/gcc-changelog/git_check_commit.py
@@ -42,7 +42,13 @@ for git_commit in parse_git_revisions(args.git_path, args.revisions):
     if git_commit.success:
         if args.print_changelog:
             git_commit.print_output()
+        if args.verbose and git_commit.warnings:
+            for warning in git_commit.warnings:
+                print('WARN: %s' % warning)
     else:
+        if args.verbose and git_commit.warnings:
+            for warning in git_commit.warnings:
+                print('WARN: %s' % warning)
         for error in git_commit.errors:
             print('ERR: %s' % error)
             if args.verbose and error.details:
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 66d68de03a5..e82fbcacd3e 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -22,6 +22,7 @@ import difflib
 import os
 import re
 import sys
+from collections import defaultdict
 
 default_changelog_locations = {
     'c++tools',
@@ -304,6 +305,7 @@ class GitCommit:
         self.changes = None
         self.changelog_entries = []
         self.errors = []
+        self.warnings = []
         self.top_level_authors = []
         self.co_authors = []
         self.top_level_prs = []
@@ -706,6 +708,7 @@ class GitCommit:
                 msg += f' (did you mean "{candidates[0]}"?)'
                 details = '\n'.join(difflib.Differ().compare([file], [candidates[0]])).rstrip()
             self.errors.append(Error(msg, file, details))
+        auto_add_warnings = defaultdict(list)
         for file in sorted(changed_files - mentioned_files):
             if not self.in_ignored_location(file):
                 if file in self.new_files:
@@ -738,6 +741,7 @@ class GitCommit:
                         file = file[len(entry.folder):].lstrip('/')
                         entry.lines.append('\t* %s: New file.' % file)
                         entry.files.append(file)
+                        auto_add_warnings[entry.folder].append(file)
                     else:
                         msg = 'new file in the top-level folder not mentioned in a ChangeLog'
                         self.errors.append(Error(msg, file))
@@ -755,6 +759,11 @@ class GitCommit:
             if pattern not in used_patterns:
                 error = "pattern doesn't match any changed files"
                 self.errors.append(Error(error, pattern))
+        for entry, val in auto_add_warnings.items():
+            if len(val) == 1:
+                self.warnings.append(f"Auto-added new file '{entry}/{val[0]}'")
+            else:
+                self.warnings.append(f"Auto-added {len(val)} new files in '{entry}'")
 
     def check_for_correct_changelog(self):
         for entry in self.changelog_entries:
@@ -830,6 +839,12 @@ class GitCommit:
         for error in self.errors:
             print(error)
 
+    def print_warnings(self):
+        if self.warnings:
+            print('Warnings:')
+            for warning in self.warnings:
+                print(warning)
+
     def check_commit_email(self):
         # Parse 'Martin Liska  <mliska@suse.cz>'
         email = self.info.author.split(' ')[-1].strip('<>')
diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index f3773f178ea..5468efcd0d5 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -119,11 +119,13 @@ if __name__ == '__main__':
 
         success = 0
         for full in sorted(allfiles):
-            email = GitEmail(full, False)
+            email = GitEmail(full)
             print(email.filename)
             if email.success:
                 success += 1
                 print('  OK')
+                for warning in email.warnings:
+                    print('  WARN: %s' % warning)
             else:
                 for error in email.errors:
                     print('  ERR: %s' % error)
@@ -135,6 +137,7 @@ if __name__ == '__main__':
         if email.success:
             print('OK')
             email.print_output()
+            email.print_warnings()
         else:
             if not email.info.lines:
                 print('Error: patch contains no parsed lines', file=sys.stderr)
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index 89960d307c9..79f8e0b8604 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -461,3 +461,17 @@ class TestGccChangelog(unittest.TestCase):
     def test_CR_in_patch(self):
         email = self.from_patch_glob('0001-Add-M-character.patch')
         assert (email.errors[0].message == 'cannot find a ChangeLog location in message')
+
+    def test_auto_add_file_1(self):
+        email = self.from_patch_glob('0001-Auto-Add-File.patch')
+        assert not email.errors
+        assert (len(email.warnings) == 1)
+        assert (email.warnings[0]
+                == "Auto-added new file 'libgomp/testsuite/libgomp.fortran/allocate-4.f90'")
+
+    def test_auto_add_file_2(self):
+        email = self.from_patch_glob('0002-Auto-Add-File.patch')
+        assert not email.errors
+        assert (len(email.warnings) == 2)
+        assert (email.warnings[0] == "Auto-added new file 'gcc/doc/gm2.texi'")
+        assert (email.warnings[1] == "Auto-added 2 new files in 'gcc/m2'")
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index c378c32423a..6004608a8f9 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3636,3 +3636,99 @@ index 0000000..d75da75
 -- 
 2.38.1
 
+=== 0001-Auto-Add-File.patch ====
+From e205ec03f0794aeac3e8a89e947c12624d5a274e Mon Sep 17 00:00:00 2001
+From: Tobias Burnus <tobias@codesourcery.com>
+Date: Thu, 15 Dec 2022 12:25:07 +0100
+Subject: [PATCH] libgfortran's ISO_Fortran_binding.c: Use GCC11 version for
+ backward-only code [PR108056]
+
+libgfortran/ChangeLog:
+
+	PR libfortran/108056
+	* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc,
+	gfc_desc_to_cfi_desc): Mostly revert to GCC 11 version for
+	those backward-compatiblity-only functions.
+---
+ libgfortran/runtime/ISO_Fortran_binding.c     | 151 +++---------------
+ .../testsuite/libgomp.fortran/allocate-4.f90  |  42 +++++
+ 2 files changed, 64 insertions(+), 129 deletions(-)
+ create mode 100644 libgomp/testsuite/libgomp.fortran/allocate-4.f90
+
+diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
+index 342df4275b9..e63a717a69b 100644
+--- a/libgfortran/runtime/ISO_Fortran_binding.c
++++ b/libgfortran/runtime/ISO_Fortran_binding.c
+@@ -41,1 +41,1 @@ export_proto(cfi_desc_to_gfc_desc);
+-  signed char type;
++  size_t type;
+diff --git a/libgomp/testsuite/libgomp.fortran/allocate-4.f90 b/libgomp/testsuite/libgomp.fortran/allocate-4.f90
+new file mode 100644
+index 00000000000..ddb507ba8e4
+--- /dev/null
++++ b/libgomp/testsuite/libgomp.fortran/allocate-4.f90
+@@ -0,0 +1,1 @@
++end
+-- 
+2.25.1
+
+=== 0002-Auto-Add-File.patch ====
+From 1eee94d351774cdc2efc8ee508b82d065184c6ee Mon Sep 17 00:00:00 2001
+From: Gaius Mulley <gaiusmod2@gmail.com>
+Date: Wed, 14 Dec 2022 17:43:08 +0000
+Subject: [PATCH 363/400] Merge modula-2 front end onto gcc.
+
+This commit merges the devel/modula2 into master.
+The libraries reside in libgm2, the compiler in gcc/m2
+and the testsuite in gcc/testsuite/gm2.
+
+gcc/ChangeLog:
+
+	* configure.ac (HAVE_PYTHON): Test for Python3 added.
+	* doc/install.texi: Add m2 as a language.  (--disable-libgm2)
+
+Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
+---
+ gcc/configure.ac                              |    15 +-
+ gcc/doc/gm2.texi                              |  2838 ++
+ gcc/doc/install.texi                          |    53 +-
+ gcc/m2/COPYING.FDL                            |   397 +
+ gcc/m2/COPYING.RUNTIME                        |    73 +
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 7ca08726efa..5efbf11793c 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -7651,3 +7665,2 @@ done
+ [subdirs='$subdirs'])
+ AC_OUTPUT
+-
+diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
+new file mode 100644
+index 00000000000..513fdd3ec7f
+--- /dev/null
++++ b/gcc/doc/gm2.texi
+@@ -0,0 +1,1 @@
++\input texinfo
+diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
+index 89ff6a6734b..6884a74936b 100644
+--- a/gcc/doc/install.texi
++++ b/gcc/doc/install.texi
+@@ -308,1 +308,2 @@ On some targets, @samp{libphobos} isn't enabled by default, but compiles
+ 
++@item @anchor{GM2-prerequisite}GM2
+diff --git a/gcc/m2/COPYING.FDL b/gcc/m2/COPYING.FDL
+new file mode 100644
+index 00000000000..9854856fa81
+--- /dev/null
++++ b/gcc/m2/COPYING.FDL
+@@ -0,0 +1,1 @@
++		GNU Free Documentation License
+diff --git a/gcc/m2/COPYING.RUNTIME b/gcc/m2/COPYING.RUNTIME
+new file mode 100644
+index 00000000000..649af5e573a
+--- /dev/null
++++ b/gcc/m2/COPYING.RUNTIME
+@@ -0,0 +1,1 @@
++GCC RUNTIME LIBRARY EXCEPTION
+-- 
+2.25.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-19 11:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 11:13 [gcc r13-4776] gcc-changelog: Add warning for auto-added files Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).