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 <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/90502 Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
9f6e297399
commit
71b79018da
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue