]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
contrib/gcc-changelog: Check whether revert-commit exists
authorTobias Burnus <tobias@codesourcery.com>
Thu, 7 Sep 2023 10:52:37 +0000 (12:52 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 7 Sep 2023 10:52:37 +0000 (12:52 +0200)
This is the identical (except for a ChangeLog typo) to
  commit r14-3777-gff20bce9f5879878f352f1fcd6ade023a2067598

It reverts the test revert in commit
  r14-3778-gfbbd9001e9b6f2c59b542cc53a8f9183514091ce
which has a bogus commit hash and should have been rejected,
but we missed that - before testing - the script had to be
manually copied to the right place on sourceware to be
affective as pre-commit hook.

Thus, the r14-3777 commit had to be reinstate by this commit ...

contrib/ChangeLog:

* gcc-changelog/git_commit.py (GitCommit.__init__):
Handle commit_to_info_hook = None; otherwise, if None,
regard it as error.
(to_changelog_entries): Handle commit_to_info_hook = None;
if info is None, create a warning for it.
* gcc-changelog/git_email.py (GitEmail.__init__):
call super() with commit_to_info_hook=None instead
of a lambda function.

contrib/gcc-changelog/git_commit.py
contrib/gcc-changelog/git_email.py

index 4f3131021f214f86b3a5211b43968879cf027d16..4f1bd4d72930a55c77fe8fcc1be8f021bf2eba70 100755 (executable)
@@ -329,11 +329,15 @@ class GitCommit:
                 self.revert_commit = m.group('hash')
                 break
         if self.revert_commit:
+            # The following happens for get_email.py:
+            if not self.commit_to_info_hook:
+                self.warnings.append(f"Invoked script can technically not obtain info about "
+                                     f"reverted commits such as '{self.revert_commit}'")
+                return
             self.info = self.commit_to_info_hook(self.revert_commit)
-
-        # The following happens for get_email.py:
-        if not self.info:
-            return
+            if not self.info:
+                self.errors.append(Error('Cannot find to-be-reverted commit', self.revert_commit))
+                return
 
         self.check_commit_email()
 
@@ -796,12 +800,18 @@ class GitCommit:
                 orig_date = self.original_info.date
                 current_timestamp = orig_date.strftime(DATE_FORMAT)
             elif self.cherry_pick_commit:
-                info = self.commit_to_info_hook(self.cherry_pick_commit)
+                info = (self.commit_to_info_hook
+                        and self.commit_to_info_hook(self.cherry_pick_commit))
                 # it can happen that it is a cherry-pick for a different
                 # repository
                 if info:
                     timestamp = info.date.strftime(DATE_FORMAT)
                 else:
+                    if self.commit_to_info_hook:
+                        self.warnings.append(f"Cherry-picked commit not found: '{self.cherry_pick_commit}'")
+                    else:
+                        self.warnings.append(f"Invoked script can technically not obtain info about "
+                                             f"cherry-picked commits such as '{self.revert_commit}'")
                     timestamp = current_timestamp
             elif not timestamp or use_commit_ts:
                 timestamp = current_timestamp
index 49f41f2ec9959b059a9ec78eed6733aeb2fe5b0b..93808dfabb6e993a2049d78e8618cf78dc42cc3f 100755 (executable)
@@ -89,8 +89,7 @@ class GitEmail(GitCommit):
                 t = 'M'
             modified_files.append((target if t != 'D' else source, t))
         git_info = GitInfo(None, date, author, message, modified_files)
-        super().__init__(git_info,
-                         commit_to_info_hook=lambda x: None)
+        super().__init__(git_info, commit_to_info_hook=None)
 
 
 def show_help():