From c1cee5b6df17c81941256b97c961e8b076f1a813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20V=C3=A1radi?= Date: Fri, 23 Aug 2024 19:48:38 +0200 Subject: [PATCH] Fix release kind detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: István Váradi --- admin/linux/debian/drone-build.sh | 2 +- admin/linux/debian/scripts/git2changelog.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/admin/linux/debian/drone-build.sh b/admin/linux/debian/drone-build.sh index 36aabc834..e178c30ca 100755 --- a/admin/linux/debian/drone-build.sh +++ b/admin/linux/debian/drone-build.sh @@ -59,7 +59,7 @@ for distribution in ${UBUNTU_DISTRIBUTIONS} ${DEBIAN_DISTRIBUTIONS}; do git merge ${DRONE_COMMIT} - read basever revdate kind <<<$(admin/linux/debian/scripts/git2changelog.py /tmp/tmpchangelog stable) + read basever revdate kind <<<$(admin/linux/debian/scripts/git2changelog.py /tmp/tmpchangelog stable "" "" ${DRONE_COMMIT}) break done diff --git a/admin/linux/debian/scripts/git2changelog.py b/admin/linux/debian/scripts/git2changelog.py index f5696511e..f5f991869 100755 --- a/admin/linux/debian/scripts/git2changelog.py +++ b/admin/linux/debian/scripts/git2changelog.py @@ -48,7 +48,8 @@ def getCommitVersion(commit): except: return None -def collectEntries(baseCommit, baseVersion, kind, finalBaseVersion, finalRevDate, config): +def collectEntries(baseCommit, baseVersion, kind, finalBaseVersion, + finalRevDate, config, finalCommit): newVersionCommit = None newVersionTag = None @@ -99,6 +100,7 @@ def collectEntries(baseCommit, baseVersion, kind, finalBaseVersion, finalRevDate lastCMAKEVersion = version (baseVersion, _kind) = result + commitTags = [] for tag in subprocess.check_output(["git", "tag", "--points-at", commit]).splitlines(): @@ -106,6 +108,7 @@ def collectEntries(baseCommit, baseVersion, kind, finalBaseVersion, finalRevDate result = processVersionTag(tag) if result: lastVersionTag = tag + commitTags.append(tag) (baseVersion, kind1) = result if kind1!=kind and kind!="release": kind = kind1 @@ -114,6 +117,9 @@ def collectEntries(baseCommit, baseVersion, kind, finalBaseVersion, finalRevDate entries.append((commit, name, email, date, revdate, subject, baseVersion, kind)) + if commit==finalCommit or finalCommit in commitTags: + break + if entries: (commit, name, email, date, revdate, subject, baseVersion, kind) = entries[-1] if finalRevDate is None: @@ -169,11 +175,13 @@ if __name__ == "__main__": baseVersion = config.get("base", "version") distribution = sys.argv[2] - finalRevDate = sys.argv[3] if len(sys.argv)>3 else None - finalBaseVersion = sys.argv[4] if len(sys.argv)>4 else None + finalRevDate = sys.argv[3] if len(sys.argv)>3 and sys.argv[3] else None + finalBaseVersion = sys.argv[4] if len(sys.argv)>4 and sys.argv[4] else None + finalCommit = sys.argv[5] if len(sys.argv)>5 and sys.argv[5] else None entries = collectEntries(baseCommit, baseVersion, "alpha", - finalBaseVersion, finalRevDate, config) + finalBaseVersion, finalRevDate, config, + finalCommit) with open(sys.argv[1], "wt") as f: (baseVersion, revdate, kind) = genChangeLogEntries(f, entries, distribution)