From 71b79018daeb757a9d1c7d5600dfad96ed95d2ec Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Fri, 12 Dec 2025 21:12:53 -0600 Subject: [PATCH] util/release/genrelnotes: Restore to saved HEAD instead of origin/main The script was failing when origin/main doesn't exist. Instead of trying to detect or use a main branch, simply save the current HEAD hash and restore it when done. This works regardless of branch names or remote configuration. Also improve the clean check to use git diff-files instead of comparing to a specific branch. Change-Id: I237de4b1e8a06fd4e1e3ef08286208c130e7a6bd Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/90502 Reviewed-by: Martin L Roth Tested-by: build bot (Jenkins) --- util/release/genrelnotes | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/util/release/genrelnotes b/util/release/genrelnotes index 5ac8abffbf..2b6619b836 100755 --- a/util/release/genrelnotes +++ b/util/release/genrelnotes @@ -26,9 +26,12 @@ then exit 1 fi +# Save the original HEAD hash to restore later +ORIGINAL_HEAD=$(git rev-parse HEAD) + # Try to verify that the repo is clean before losing state. if ! git diff-index --quiet --cached HEAD 2>/dev/null || \ - [ "$(git diff origin/main --shortstat 2>/dev/null | tail -n1)" != "" ]; then + ! git diff-files --quiet 2>/dev/null; then echo "ERROR: repo is not clean. Exiting." >&2 exit 1 fi @@ -185,7 +188,7 @@ find_areas() { # up manually. version_ctrl_c() { printf "\n Cleaning up and exiting.\n" >&2 - git checkout origin/main > /dev/null 2>&1 + git checkout "$ORIGINAL_HEAD" > /dev/null 2>&1 git submodule update --init --checkout > /dev/null 2>&1 rm "$LOGFILE" exit 1; @@ -290,7 +293,8 @@ southbridge_list_new=$(find_areas "src/southbridge" "Kconfig" "") printf "Calculating new SLOC\n" NEW_SLOC=$(get_sloc) -git checkout origin/main > /dev/null 2>&1 +# Restore to original HEAD +git checkout "$ORIGINAL_HEAD" > /dev/null 2>&1 git submodule update --init --checkout > /dev/null 2>&1 trap "" SIGINT