Fix parsing in normalize_and_ref()

This commit is contained in:
2025-07-28 23:29:46 -04:00
parent d22d21148c
commit a5b559c59c
2 changed files with 9 additions and 16 deletions

View File

@@ -319,16 +319,12 @@ install_dependencies() {
fi fi
} }
# @description Normalize userinput release and compute the worktree/ref key # @description Normalize release and set worktree reference
# @arg $1 user release (eg "v24.10.2", "snapshot", "24.10.2-rc1", or a commitish) # @arg $1 string Raw release input
# @arg $2 build mode ("imagebuilder" or "source") # @arg $2 string Build mode ("source" or "imagebuilder")
# @stdout prints two words: <normalized_release> <ref> # @returns string Normalized release and reference
normalize_and_ref() { normalize_and_ref() {
local input="$1" mode="$2" local input="$1" mode="$2"
# interpret “source” mode as “from_src”
local from_src=0
[[ "$mode" == "source" ]] && from_src=1
local rel ref branch tag local rel ref branch tag
case "$input" in case "$input" in
@@ -336,9 +332,10 @@ normalize_and_ref() {
rel="snapshot" rel="snapshot"
ref="main" ref="main"
;; ;;
v[0-9][0-9].[0-9][0-9].*) v[0-9][0-9].[0-9][0-9].*|[0-9][0-9].[0-9][0-9].*)
# strip optional leading “v”
rel="${input#v}" rel="${input#v}"
if (( from_src )); then if [[ "$mode" == "source" ]]; then
branch="openwrt-${rel%.*}" branch="openwrt-${rel%.*}"
tag="v$rel" tag="v$rel"
if ask_ok "Use branch $branch HEAD (y) or tag $tag (n)?"; then if ask_ok "Use branch $branch HEAD (y) or tag $tag (n)?"; then
@@ -350,12 +347,8 @@ normalize_and_ref() {
ref="$rel" ref="$rel"
fi fi
;; ;;
[0-9][0-9].[0-9][0-9].*)
rel="$input"
ref="$rel"
;;
*) *)
if (( from_src )); then if [[ "$mode" == "source" ]]; then
# arbitrary commit-ish allowed # arbitrary commit-ish allowed
rel="$input" rel="$input"
ref="$input" ref="$input"