From 54d3ff83fd14af51e2d857d78d2f76fb03aa1792 Mon Sep 17 00:00:00 2001 From: bbrzyski Date: Thu, 28 Nov 2024 11:47:48 +0100 Subject: [PATCH] Fix changelog script to not fail on main branch Signed-off-by: bbrzyski --- noxfile.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 04e0982a..84ab3468 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 import json +import logging import os import shutil import sys @@ -296,17 +297,24 @@ def package_cores(session: nox.Session) -> None: @nox.session def changed_changelog(session: nox.Session) -> None: changelog_file_name = "CHANGELOG.md" + main_branch = "main" + current_branch = session.run("git", "branch", "--show-current", external=True, silent=True) + assert current_branch is not None + # Check if the script is run on the main branch + if current_branch.strip("\n") == main_branch: + return changelog_changed = session.run( "git", "diff", "--name-only", - "origin/main", + "origin/" + main_branch, "--", changelog_file_name, external=True, silent=True, ) if not changelog_changed: + logging.error("Changelog was not updated!") raise CommandFailed()