It allows modifications to ChangeLog* files without need create
a ChangeLog entry for them.

Pushed.
Martin

contrib/ChangeLog:

        * gcc-changelog/git_commit.py: Allow modifications of older
        ChangeLog (or specific) files without need to make a ChangeLog
        entry.
        * gcc-changelog/test_email.py: Test it.
        * gcc-changelog/test_patches.txt: Add new patch.
---
 contrib/gcc-changelog/git_commit.py    | 12 +++++++++---
 contrib/gcc-changelog/test_email.py    |  4 ++++
 contrib/gcc-changelog/test_patches.txt | 20 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py 
b/contrib/gcc-changelog/git_commit.py
index ee1973371be..59f478670d7 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -308,7 +308,7 @@ class GitCommit:
             self.info = self.commit_to_info_hook(self.revert_commit)
project_files = [f for f in self.info.modified_files
-                         if self.is_changelog_filename(f[0])
+                         if self.is_changelog_filename(f[0], allow_suffix=True)
                          or f[0] in misc_files]
         ignored_files = [f for f in self.info.modified_files
                          if self.in_ignored_location(f[0])]
@@ -343,8 +343,14 @@ class GitCommit:
         return [x[0] for x in self.info.modified_files if x[1] == 'A']
@classmethod
-    def is_changelog_filename(cls, path):
-        return path.endswith('/ChangeLog') or path == 'ChangeLog'
+    def is_changelog_filename(cls, path, allow_suffix=False):
+        basename = os.path.basename(path)
+        if basename == 'ChangeLog':
+            return True
+        elif allow_suffix and basename.startswith('ChangeLog'):
+            return True
+        else:
+            return False
@classmethod
     def find_changelog_location(cls, name):
diff --git a/contrib/gcc-changelog/test_email.py 
b/contrib/gcc-changelog/test_email.py
index 5db56caef9e..532ed6a7983 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -404,3 +404,7 @@ class TestGccChangelog(unittest.TestCase):
         email = self.from_patch_glob('0001-Add-horse2.patch')
         assert not email.errors
         assert email.changelog_entries[0].files == ['koní�ek.txt']
+
+    def test_modification_of_old_changelog(self):
+        email = self.from_patch_glob('0001-fix-old-ChangeLog.patch')
+        assert not email.errors
diff --git a/contrib/gcc-changelog/test_patches.txt 
b/contrib/gcc-changelog/test_patches.txt
index ffd13682d5c..6b75e488903 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3398,4 +3398,24 @@ index 00000000000..56c67f58752
 --
 2.29.2
+=== 0001-fix-old-ChangeLog.patch ===
+From fd498465b2801203089616be9a0e3c1f4fc065a0 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mli...@suse.cz>
+Date: Wed, 13 Jan 2021 11:45:37 +0100
+Subject: [PATCH] Fix a changelog.
+
+---
+ gcc/ChangeLog-2020 | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gcc/ChangeLog-2020 b/gcc/ChangeLog-2020
+index 6553720acad..2c170ef014a 100644
+--- a/gcc/ChangeLog-2020
++++ b/gcc/ChangeLog-2020
+@@ -1 +1,2 @@
+
++
+
+--
+2.29.2
--
2.29.2

Reply via email to