Error for missing change description in git_commit.py.

Message ID 014b383e-e421-8cdf-acb0-878b8ee1b9b3@suse.cz
State New
Headers show
Series
  • Error for missing change description in git_commit.py.
Related show

Commit Message

Martin Liška May 29, 2020, 11:57 a.m.
Hello.

The change finds situations where somebody missing description of a change
in a ChangeLog entry.

I tested:
git gcc-verify 51e10276d6792f67f1d88d90f299e7ac1b1f1f24..HEAD -n
and it's fine for ~250 last commits.

I'll install it if there are no objections.
Thanks,
Martin

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Find empty change descriptions.
	* gcc-changelog/test_email.py: New test.
	* gcc-changelog/test_patches.txt: New patch that tests that.
---
  contrib/gcc-changelog/git_commit.py    | 10 +++++++++
  contrib/gcc-changelog/test_email.py    |  6 ++++++
  contrib/gcc-changelog/test_patches.txt | 28 ++++++++++++++++++++++++++
  3 files changed, 44 insertions(+)

-- 
2.26.2

Comments

Martin Liška May 29, 2020, 3:26 p.m. | #1
I've just pushed that to master.

Jakub: Can you please rsync the script to the server hook?

Thanks,
Martin

Patch

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 084e83c18cc..4f82b58f64b 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -274,6 +274,7 @@  class GitCommit:
          self.parse_lines(all_are_ignored)
          if self.changes:
              self.parse_changelog()
+            self.check_for_empty_description()
              self.deduce_changelog_locations()
              if not self.errors:
                  self.check_mentioned_files()
@@ -440,6 +441,15 @@  class GitCommit:
                          else:
                              last_entry.lines.append(line)
  
+    def check_for_empty_description(self):
+        for entry in self.changelog_entries:
+            for i, line in enumerate(entry.lines):
+                if (star_prefix_regex.match(line) and line.endswith(':') and
+                    (i == len(entry.lines) - 1
+                     or star_prefix_regex.match(entry.lines[i + 1]))):
+                    msg = 'missing description of a change'
+                    self.errors.append(Error(msg, line))
+
      def get_file_changelog_location(self, changelog_file):
          for file in self.modified_files:
              if file[0] == changelog_file:
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index e73b3626473..158eb651367 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -312,3 +312,9 @@  class TestGccChangelog(unittest.TestCase):
                  == 'Steven G. Kargl  <kargl@gcc.gnu.org>')
          assert (email.changelog_entries[0].author_lines[1][0]
                  == 'Mark Eggleston  <markeggleston@gcc.gnu.org>')
+
+    def test_missing_change_description(self):
+        email = self.from_patch_glob('0001-Missing-change-description.patch')
+        assert len(email.errors) == 2
+        assert email.errors[0].message == 'missing description of a change'
+        assert email.errors[1].message == 'missing description of a change'
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 76037c33f93..25311fbf300 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -2945,3 +2945,31 @@  index 00000000000..fda10c1a88b
  +
  --
  2.26.2
+
+=== 0001-Missing-change-description.patch ===
+From 8ec655bd94615ba45adabae9b50df299edb74eda Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Fri, 29 May 2020 13:42:57 +0200
+Subject: [PATCH] Test me.
+
+gcc/ChangeLog:
+
+	* ipa-icf-gimple.c (compare_gimple_asm):
+	* ipa-icf-gimple2.c (compare_gimple_asm): Good.
+	* ipa-icf-gimple3.c (compare_gimple_asm):
+---
+ contrib/gcc-changelog/git_commit.py | 10 ++++++++++
+ gcc/ipa-icf-gimple.c                |  1 +
+ 2 files changed, 11 insertions(+)
+
+diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
+index 1cd5872c03d..6f95aedb3d3 100644
+--- a/gcc/ipa-icf-gimple.c
++++ b/gcc/ipa-icf-gimple.c
+@@ -850,3 +850,4 @@
+ }
+
+ } // ipa_icf_gimple namespace
++
+--
+2.26.2