On Thu, Sep 07, 2023 at 11:30:53AM +0200, Tobias Burnus wrote:
> contrib/gcc-changelog: Check whether revert-commit exists
>
> 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 lamda function.
>
> contrib/gcc-changelog/git_commit.py | 20 +++++++++++++++-----
> contrib/gcc-changelog/git_email.py | 3 +--
> 2 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/gcc-changelog/git_commit.py
> b/contrib/gcc-changelog/git_commit.py
> index 4f3131021f2..4f1bd4d7293 100755
> --- a/contrib/gcc-changelog/git_commit.py
> +++ b/contrib/gcc-changelog/git_commit.py
> @@ -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}'")
I think not should precede technically (or should we just drop technically)?
> + self.warnings.append(f"Invoked script can
> technically not obtain info about "
> + f"cherry-picked commits such as
> '{self.revert_commit}'")
Likewise.
> timestamp = current_timestamp
> elif not timestamp or use_commit_ts:
> timestamp = current_timestamp
> diff --git a/contrib/gcc-changelog/git_email.py
> b/contrib/gcc-changelog/git_email.py
> index 49f41f2ec99..93808dfabb6 100755
> --- a/contrib/gcc-changelog/git_email.py
> +++ b/contrib/gcc-changelog/git_email.py
> @@ -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():
Otherwise LGTM, but it would be good after committing it try to commit
reversion commit of some non-existent hash (willing to handle ChangeLog
manually again if it makes it through).
Jakub