From c150fe6f0d33b6157443a58411cbe827caab1f4d Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Mon, 25 Jul 2022 21:56:20 +0200 Subject: [PATCH] Fix possible wrong FROM_REF by using merge-base commit --- utils/changelog/changelog.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/changelog/changelog.py b/utils/changelog/changelog.py index 3981bce73a6..305899fe7e8 100755 --- a/utils/changelog/changelog.py +++ b/utils/changelog/changelog.py @@ -368,11 +368,13 @@ def main(): logging.info("Using %s..%s as changelog interval", FROM_REF, TO_REF) + # use merge-base commit as a starting point, if used ref in another branch + base_commit = runner.run(f"git merge-base '{FROM_REF}^{{}}' '{TO_REF}^{{}}'") # Get starting and ending dates for gathering PRs # Add one day after and before to mitigate TZ possible issues # `tag^{}` format gives commit ref when we have annotated tags # format %cs gives a committer date, works better for cherry-picked commits - from_date = runner.run(f"git log -1 --format=format:%cs '{FROM_REF}^{{}}'") + from_date = runner.run(f"git log -1 --format=format:%cs '{base_commit}'") to_date = runner.run(f"git log -1 --format=format:%cs '{TO_REF}^{{}}'") merged = ( date.fromisoformat(from_date) - timedelta(1),