Hello.


As Jakub correctly noticed, we can remove ChangeLog locations only based

on branch (master, a release branch). The patch removes 2 locations for the 
current

master (or any further release) based on the current master.



gccadmin/hooks-bin/commit_checker needs to be updated correspondingly with:


        commits = parse_git_revisions(os.environ['GIT_DIR'], commit_rev, 
ref_name)

Thoughts?
Martin

contrib/ChangeLog:

        * gcc-changelog/git_commit.py: Remove ChangeLog locations
        based on ref_name.
---
 contrib/gcc-changelog/git_commit.py     | 29 +++++++++++++++++--------
 contrib/gcc-changelog/git_repository.py |  5 +++--
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py 
b/contrib/gcc-changelog/git_commit.py
index b28f7deac23..89b12cda712 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -19,8 +19,9 @@
 import difflib
 import os
 import re
+import sys
-changelog_locations = {
+default_changelog_locations = {
     'c++tools',
     'config',
     'contrib',
@@ -287,7 +288,7 @@ class GitInfo:
class GitCommit:
-    def __init__(self, info, strict=True, commit_to_info_hook=None):
+    def __init__(self, info, strict=True, commit_to_info_hook=None, 
ref_name=None):
         self.original_info = info
         self.info = info
         self.message = None
@@ -300,6 +301,7 @@ class GitCommit:
         self.cherry_pick_commit = None
         self.revert_commit = None
         self.commit_to_info_hook = commit_to_info_hook
+        self.init_changelog_locations(ref_name)
# Skip Update copyright years commits
         if self.info.lines and self.info.lines[0] == 'Update copyright years.':
@@ -361,15 +363,14 @@ class GitCommit:
         else:
             return False
- @classmethod
-    def find_changelog_location(cls, name):
+    def find_changelog_location(self, name):
         if name.startswith('\t'):
             name = name[1:]
         if name.endswith(':'):
             name = name[:-1]
         if name.endswith('/'):
             name = name[:-1]
-        return name if name in changelog_locations else None
+        return name if name in self.changelog_locations else None
@classmethod
     def format_git_author(cls, author):
@@ -389,6 +390,17 @@ class GitCommit:
                 modified_files.append((parts[2], 'A'))
         return modified_files
+ def init_changelog_locations(self, ref_name):
+        self.changelog_locations = list(default_changelog_locations)
+        if ref_name:
+            version = sys.maxsize
+            if ref_name.startswith('refs/heads/releases/gcc-'):
+                version = int(ref_name.split('-')[-1])
+            if version >= 12:
+                # HSA and BRIG were removed in GCC 12
+                self.changelog_locations.remove('gcc/brig')
+                self.changelog_locations.remove('libhsail-rt')
+
     def parse_lines(self, all_are_ignored):
         body = self.info.lines
@@ -586,7 +598,7 @@ class GitCommit:
                 for file in entry.files:
                     location = self.get_file_changelog_location(file)
                     if (location == ''
-                       or (location and location in changelog_locations)):
+                       or (location and location in self.changelog_locations)):
                         if changelog and changelog != location:
                             msg = 'could not deduce ChangeLog file, ' \
                                   'not unique location'
@@ -606,11 +618,10 @@ class GitCommit:
                 return True
         return False
- @classmethod
-    def get_changelog_by_path(cls, path):
+    def get_changelog_by_path(self, path):
         components = path.split('/')
         while components:
-            if '/'.join(components) in changelog_locations:
+            if '/'.join(components) in self.changelog_locations:
                 break
             components = components[:-1]
         return '/'.join(components)
diff --git a/contrib/gcc-changelog/git_repository.py 
b/contrib/gcc-changelog/git_repository.py
index a0e293d756d..501c0d931f5 100755
--- a/contrib/gcc-changelog/git_repository.py
+++ b/contrib/gcc-changelog/git_repository.py
@@ -29,7 +29,7 @@ except ImportError:
 from git_commit import GitCommit, GitInfo, decode_path
-def parse_git_revisions(repo_path, revisions, strict=True):
+def parse_git_revisions(repo_path, revisions, strict=True, ref_name=None):
     repo = Repo(repo_path)
def commit_to_info(commit):
@@ -73,6 +73,7 @@ def parse_git_revisions(repo_path, revisions, strict=True):
for commit in commits:
         git_commit = GitCommit(commit_to_info(commit.hexsha), strict=strict,
-                               commit_to_info_hook=commit_to_info)
+                               commit_to_info_hook=commit_to_info,
+                               ref_name=ref_name)
         parsed_commits.append(git_commit)
     return parsed_commits
--
2.31.1

Reply via email to