Hi.

The patch is about FORBIDDEN_FILES that we don't want to be commited.
So far we have $root/Makefile.am and $root/build.log.

Do you have any other candidates?

Cheers,
Martin

contrib/ChangeLog:

        * gcc-changelog/git_commit.py: Add FORBIDDEN_FILES.
        * gcc-changelog/test_email.py: Test it.
        * gcc-changelog/test_patches.txt: Add test for it.
---
 contrib/gcc-changelog/git_commit.py    | 10 ++++++++++
 contrib/gcc-changelog/test_email.py    |  4 ++++
 contrib/gcc-changelog/test_patches.txt | 21 +++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/contrib/gcc-changelog/git_commit.py 
b/contrib/gcc-changelog/git_commit.py
index 27a1d59b211..d7aec93f44b 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -153,6 +153,11 @@ misc_files = {
     'gcc/DEV-PHASE'
     }
+FORBIDDEN_FILES = {
+    'Makefile.am',
+    'build.log'
+}
+
 author_line_regex = \
         re.compile(r'^(?P<datetime>\d{4}-\d{2}-\d{2})\ {2}(?P<name>.*  <.*>)')
 additional_author_regex = re.compile(r'^\t(?P<spaces>\ *)?(?P<name>.*  <.*>)')
@@ -339,6 +344,11 @@ class GitCommit:
                     self.errors.append(Error('invalid PR component in 
subject', info.lines[0]))
                 self.subject_prs.add(m.group('pr'))
+ for f in self.info.modified_files:
+            if f[1] != 'D':
+                if f[0] in FORBIDDEN_FILES:
+                    self.errors.append(Error('forbidden file name', f[0]))
+
         # Allow complete deletion of ChangeLog files in a commit
         project_files = [f for f in self.info.modified_files
                          if (self.is_changelog_filename(f[0], 
allow_suffix=True) and f[1] != 'D')
diff --git a/contrib/gcc-changelog/test_email.py 
b/contrib/gcc-changelog/test_email.py
index a4796dbbe94..28ad6552a93 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -446,3 +446,7 @@ class TestGccChangelog(unittest.TestCase):
         email = self.from_patch_glob('non-ascii-email.patch')
         assert (email.errors[0].message ==
                 'non-ASCII characters in git commit email address 
(jbglaw@ług-owl.de)')
+
+    def test_forbidden_file(self):
+        email = self.from_patch_glob('Makefile.am.patch')
+        assert (email.errors[0].message == 'forbidden file name')
diff --git a/contrib/gcc-changelog/test_patches.txt 
b/contrib/gcc-changelog/test_patches.txt
index 98a0d3f1ee0..b59afe16bd3 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3489,3 +3489,24 @@ index 2a9917cde62..0033b0004b3 100644
 @@ -0,0 +1,1 @@
 +
 --
+
+=== Makefile.am.patch ===
+From 80c9d63af350b280bfccb82adb3867c25a25e6d0 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mli...@suse.cz>
+Date: Mon, 24 Jan 2022 12:17:09 +0100
+Subject: [PATCH] Add Makefile.am file.
+
+---
+ Makefile.am | 0
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+ create mode 100644 Makefile.am
+
+diff --git a/Makefile.am b/Makefile.am
+new file mode 100644
+index 00000000000..d6459e00543
+--- /dev/null
++++ b/Makefile.am
+@@ -0,0 +1 @@
++xxx
+--
+2.34.1
--
2.34.1

Reply via email to