[PATCH][pushed] gcc-changelog: allow ChangeLog deletion in a commit

Martin Liška mliska@suse.cz
Fri Mar 12 08:29:36 GMT 2021


That would be needed for removal of components which contain a ChangeLog.
Pushed to master.

Martin

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Allow deletion of ChangeLog
	files.
	* gcc-changelog/setup.cfg: Set line limit to 120 characters.
	* gcc-changelog/test_email.py: Add test.
	* gcc-changelog/test_patches.txt: Likewise.
	* gcc-changelog/git_email.py: Fix parsing of deleted files.
---
  contrib/gcc-changelog/git_commit.py    |  3 ++-
  contrib/gcc-changelog/git_email.py     |  2 +-
  contrib/gcc-changelog/setup.cfg        |  3 +++
  contrib/gcc-changelog/test_email.py    |  4 ++++
  contrib/gcc-changelog/test_patches.txt | 30 ++++++++++++++++++++++++++
  5 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index e9dae0a838d..43fa7f40e4e 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -314,8 +314,9 @@ class GitCommit:
          if self.revert_commit:
              self.info = self.commit_to_info_hook(self.revert_commit)
  
+        # 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)
+                         if (self.is_changelog_filename(f[0], allow_suffix=True) and f[1] != 'D')
                           or f[0] in misc_files]
          ignored_files = [f for f in self.info.modified_files
                           if self.in_ignored_location(f[0])]
diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index 00ad00458f4..b0547b363aa 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -66,7 +66,7 @@ class GitEmail(GitCommit):
                  t = 'A'
              else:
                  t = 'M'
-            modified_files.append((target, t))
+            modified_files.append((target if t != 'D' else source, t))
          git_info = GitInfo(None, date, author, body, modified_files)
          super().__init__(git_info, strict=strict,
                           commit_to_info_hook=lambda x: None)
diff --git a/contrib/gcc-changelog/setup.cfg b/contrib/gcc-changelog/setup.cfg
index 9e4a0f6479c..efc313f6d52 100644
--- a/contrib/gcc-changelog/setup.cfg
+++ b/contrib/gcc-changelog/setup.cfg
@@ -1,2 +1,5 @@
+[flake8]
+max-line-length = 120
+
  [tool:pytest]
  addopts = -vv --flake8
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index b81548f2033..9d052e06467 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -416,3 +416,7 @@ class TestGccChangelog(unittest.TestCase):
      def test_multiline_bad_parentheses(self):
          email = self.from_patch_glob('0002-Wrong-macro-changelog.patch')
          assert email.errors[0].message == 'bad parentheses wrapping'
+
+    def test_changelog_removal(self):
+        email = self.from_patch_glob('0001-ChangeLog-removal.patch', strict=True)
+        assert not email.errors
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 9de28972556..012573b4845 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -3481,3 +3481,33 @@ index ac63591b33f..ff4d61764e7 100644
  +
  --
  2.29.2
+
+=== 0001-ChangeLog-removal.patch ===
+From b39fadf9df1a9510afcab0a391182da7dc68de24 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Fri, 12 Mar 2021 09:10:55 +0100
+Subject: [PATCH] Test ChangeLog removal.
+
+gcc/ChangeLog:
+
+	* ipa-icf.c (make_pass_ipa_icf): Add line.
+---
+diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog
+deleted file mode 100644
+index 94e87f6bcde..00000000000
+--- a/gcc/analyzer/ChangeLog
++++ /dev/null
+@@ -1,1 +0,0 @@
+- foo
+diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
+index 5dd33a75c3a..c4ce432cb98 100644
+--- a/gcc/ipa-icf.c
++++ b/gcc/ipa-icf.c
+@@ -3655,3 +3655,4 @@ make_pass_ipa_icf (gcc::context *ctxt)
+ {
+   return new ipa_icf::pass_ipa_icf (ctxt);
+ }
++
+--
+2.30.1
+
-- 
2.30.1



More information about the Gcc-patches mailing list