summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-06-02 15:13:22 +0200
committerMartin Liska <mliska@suse.cz>2020-06-02 16:05:38 +0200
commit4b6dcfd542aed2d14a0bcd2bee116d0779cc1d48 (patch)
tree8b5dc478a86ea87833879bc1cb0d3c2c6dc1892f /contrib
parenta04b7410d305800b747963ab940d2b1a602b5ddf (diff)
gcc-changelog: support patterns
contrib/ChangeLog: * gcc-changelog/git_commit.py: Support foo/bar/*: patterns in wildcard_prefixes locations. * gcc-changelog/test_email.py: Test it. * gcc-changelog/test_patches.txt: Add 3 new patches.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gcc-changelog/git_commit.py52
-rwxr-xr-xcontrib/gcc-changelog/test_email.py13
-rw-r--r--contrib/gcc-changelog/test_patches.txt86
3 files changed, 143 insertions, 8 deletions
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index e2ef6c61ed0..069900d7cbf 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -136,6 +136,11 @@ ignored_prefixes = [
'libsanitizer/',
]
+wildcard_prefixes = [
+ 'gcc/testsuite/',
+ 'libstdc++-v3/doc/html/'
+ ]
+
misc_files = [
'gcc/DATESTAMP',
'gcc/BASE-VER',
@@ -182,11 +187,10 @@ class ChangeLogEntry:
self.initial_prs = list(prs)
self.prs = list(prs)
self.lines = []
+ self.files = []
+ self.file_patterns = []
- @property
- def files(self):
- files = []
-
+ def parse_file_names(self):
# Whether the content currently processed is between a star prefix the
# end of the file list: a colon or an open paren.
in_location = False
@@ -215,8 +219,10 @@ class ChangeLogEntry:
for file in line.split(','):
file = file.strip()
if file:
- files.append(file)
- return files
+ if file.endswith('*'):
+ self.file_patterns.append(file[:-1])
+ else:
+ self.files.append(file)
@property
def datetime(self):
@@ -275,8 +281,10 @@ class GitCommit:
self.parse_lines(all_are_ignored)
if self.changes:
self.parse_changelog()
+ self.parse_file_names()
self.check_for_empty_description()
self.deduce_changelog_locations()
+ self.check_file_patterns()
if not self.errors:
self.check_mentioned_files()
self.check_for_correct_changelog()
@@ -442,6 +450,18 @@ class GitCommit:
else:
last_entry.lines.append(line)
+ def parse_file_names(self):
+ for entry in self.changelog_entries:
+ entry.parse_file_names()
+
+ def check_file_patterns(self):
+ for entry in self.changelog_entries:
+ for pattern in entry.file_patterns:
+ name = os.path.join(entry.folder, pattern)
+ if name not in wildcard_prefixes:
+ msg = 'unsupported wildcard prefix'
+ self.errors.append(Error(msg, name))
+
def check_for_empty_description(self):
for entry in self.changelog_entries:
for i, line in enumerate(entry.lines):
@@ -502,6 +522,8 @@ class GitCommit:
assert folder_count == len(self.changelog_entries)
mentioned_files = set()
+ mentioned_patterns = []
+ used_patterns = set()
for entry in self.changelog_entries:
if not entry.files:
msg = 'ChangeLog must contain at least one file entry'
@@ -510,6 +532,8 @@ class GitCommit:
for file in entry.files:
if not self.is_changelog_filename(file):
mentioned_files.add(os.path.join(entry.folder, file))
+ for pattern in entry.file_patterns:
+ mentioned_patterns.append(os.path.join(entry.folder, pattern))
cand = [x[0] for x in self.modified_files
if not self.is_changelog_filename(x[0])]
@@ -543,9 +567,21 @@ class GitCommit:
assert file.startswith(entry.folder)
file = file[len(entry.folder):].lstrip('/')
entry.lines.append('\t* %s: New file.' % file)
+ entry.files.append(file)
else:
- msg = 'changed file not mentioned in a ChangeLog'
- self.errors.append(Error(msg, file))
+ used_pattern = [p for p in mentioned_patterns
+ if file.startswith(p)]
+ used_pattern = used_pattern[0] if used_pattern else None
+ if used_pattern:
+ used_patterns.add(used_pattern)
+ else:
+ msg = 'changed file not mentioned in a ChangeLog'
+ self.errors.append(Error(msg, file))
+
+ for pattern in mentioned_patterns:
+ if pattern not in used_patterns:
+ error = 'pattern doesn''t match any changed files'
+ self.errors.append(Error(error, pattern))
def check_for_correct_changelog(self):
for entry in self.changelog_entries:
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index 2465669786e..7e8140c915f 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -318,3 +318,16 @@ class TestGccChangelog(unittest.TestCase):
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'
+
+ def test_libstdcxx_html_regenerated(self):
+ email = self.from_patch_glob('0001-Fix-text-of-hyperlink')
+ assert not email.errors
+ email = self.from_patch_glob('0002-libstdc-Fake-test-change-1.patch')
+ assert len(email.errors) == 1
+ msg = 'pattern doesn''t match any changed files'
+ assert email.errors[0].message == msg
+ assert email.errors[0].line == 'libstdc++-v3/doc/html/'
+ email = self.from_patch_glob('0003-libstdc-Fake-test-change-2.patch')
+ assert len(email.errors) == 1
+ msg = 'changed file not mentioned in a ChangeLog'
+ assert email.errors[0].message == msg
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 25311fbf300..5d9b62d2637 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -2973,3 +2973,89 @@ index 1cd5872c03d..6f95aedb3d3 100644
+
--
2.26.2
+
+=== 0001-Fix-text-of-hyperlink-in-manual.patch ===
+From c7904d9e08a0ca3f733be3c2e8a3b912fa851fc5 Mon Sep 17 00:00:00 2001
+From: Jonathan Wakely <jwakely@redhat.com>
+Date: Fri, 8 Mar 2019 13:56:53 +0000
+Subject: [PATCH] Fix text of hyperlink in manual
+
+ * doc/xml/manual/using.xml: Use link element instead of xref.
+ * doc/html/*: Regenerate.
+
+---
+ libstdc++-v3/ChangeLog | 3 +++
+ libstdc++-v3/doc/html/manual/using_macros.html | 3 ++-
+ libstdc++-v3/doc/xml/manual/using.xml | 4 ++--
+ 3 files changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/libstdc++-v3/doc/html/manual/using_macros.html b/libstdc++-v3/doc/html/manual/using_macros.html
+index 7030bd2d0fd..dad6564a97d 100644
+--- a/libstdc++-v3/doc/html/manual/using_macros.html
++++ b/libstdc++-v3/doc/html/manual/using_macros.html
+@@ -1 +1,2 @@
+
++
+diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml
+index 2d44a739406..7647e9b8dad 100644
+--- a/libstdc++-v3/doc/xml/manual/using.xml
++++ b/libstdc++-v3/doc/xml/manual/using.xml
+@@ -1 +1,2 @@
+
++
+--
+2.25.4
+
+=== 0002-libstdc-Fake-test-change-1.patch ===
+From fe4ade6778d1d97214db12bf2c40d0f40e7f953a Mon Sep 17 00:00:00 2001
+From: Jonathan Wakely <jwakely@redhat.com>
+Date: Tue, 2 Jun 2020 11:52:34 +0100
+Subject: [PATCH] libstdc++: Fake change for testing git_commit.py
+
+libstdc++-v3/ChangeLog:
+
+ * doc/xml/faq.xml: Fake change.
+ * doc/html/*: Regenerated.
+---
+ libstdc++-v3/doc/xml/faq.xml | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libstdc++-v3/doc/xml/faq.xml b/libstdc++-v3/doc/xml/faq.xml
+index e419d3c22a0..bcc14dd6d90 100644
+--- a/libstdc++-v3/doc/xml/faq.xml
++++ b/libstdc++-v3/doc/xml/faq.xml
+@@ -1 +1,2 @@
+
++
+--
+2.25.4
+
+=== 0003-libstdc-Fake-test-change-2.patch ===
+From e460effb3a42c1c046b682fe266da418f2693ef3 Mon Sep 17 00:00:00 2001
+From: Jonathan Wakely <jwakely@redhat.com>
+Date: Tue, 2 Jun 2020 11:52:34 +0100
+Subject: [PATCH] libstdc++: Fake change for testing 2
+
+libstdc++-v3/ChangeLog:
+
+ * doc/xml/faq.xml: Fake change.
+---
+ libstdc++-v3/doc/html/faq.html | 2 +-
+ libstdc++-v3/doc/xml/faq.xml | 1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/libstdc++-v3/doc/html/faq.html b/libstdc++-v3/doc/html/faq.html
+index 967e5f5f348..95d21b5bf9f 100644
+--- a/libstdc++-v3/doc/html/faq.html
++++ b/libstdc++-v3/doc/html/faq.html
+@@ -1 +1,2 @@
+
++
+--- a/libstdc++-v3/doc/xml/faq.xml
++++ b/libstdc++-v3/doc/xml/faq.xml
+@@ -1 +1,2 @@
+
++
+--
+2.25.4
+