From b26dcb3390b66f2dcbcdc843dca2b2db92c21dc9 Mon Sep 17 00:00:00 2001 From: Keshav's Bot Date: Fri, 15 May 2026 00:24:06 +0530 Subject: [PATCH] fix: scope git installer lockfile refresh --- scripts/install-cli.sh | 23 +++++++++++++++++++---- scripts/install.sh | 16 +++++++++++++++- test/scripts/install-cli.test.ts | 29 +++++++++++++++++++++++++++-- test/scripts/install-sh.test.ts | 27 +++++++++++++++++++++++++-- 4 files changed, 86 insertions(+), 9 deletions(-) diff --git a/scripts/install-cli.sh b/scripts/install-cli.sh index b996f57b108..13b188ce871 100755 --- a/scripts/install-cli.sh +++ b/scripts/install-cli.sh @@ -414,16 +414,17 @@ checkout_git_openclaw_ref() { return 0 fi - git -C "$repo_dir" fetch --tags origin - if [[ "$ref" == "main" ]]; then + git -C "$repo_dir" fetch --no-tags origin main git -C "$repo_dir" checkout main if [[ "$GIT_UPDATE" == "1" ]]; then - git -C "$repo_dir" pull --rebase || true + git -C "$repo_dir" pull --rebase --no-tags || true fi return 0 fi + git -C "$repo_dir" fetch --tags origin + if git -C "$repo_dir" rev-parse --verify --quiet "refs/tags/${ref}^{commit}" >/dev/null; then git -C "$repo_dir" checkout --detach "$ref" return 0 @@ -445,6 +446,18 @@ checkout_git_openclaw_ref() { fail "Requested git version not found: ${ref}" } +git_install_lockfile_flag() { + local repo_dir="$1" + local ref="$2" + + if [[ "$ref" == "main" ]] || git -C "$repo_dir" ls-remote --exit-code --heads origin "$ref" >/dev/null 2>&1; then + echo "--no-frozen-lockfile" + return 0 + fi + + echo "--frozen-lockfile" +} + repo_pnpm_spec() { local repo_dir="$1" local package_json="${repo_dir}/package.json" @@ -723,7 +736,9 @@ install_openclaw_from_git() { ensure_pnpm_git_prepare_allowlist "$repo_dir" activate_repo_pnpm_version "$repo_dir" - SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" run_pnpm -C "$repo_dir" install --frozen-lockfile + local install_lockfile_flag + install_lockfile_flag="$(git_install_lockfile_flag "$repo_dir" "$git_ref")" + CI="${CI:-true}" SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" run_pnpm -C "$repo_dir" install "$install_lockfile_flag" if ! run_pnpm -C "$repo_dir" ui:build; then log "UI build failed; continuing (CLI may still work)" diff --git a/scripts/install.sh b/scripts/install.sh index 0b958ba9fab..8652cd008c5 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1993,6 +1993,18 @@ checkout_git_openclaw_ref() { return 1 } +git_install_lockfile_flag() { + local repo_dir="$1" + local ref="$2" + + if [[ "$ref" == "main" ]] || git -C "$repo_dir" ls-remote --exit-code --heads origin "$ref" >/dev/null 2>&1; then + echo "--no-frozen-lockfile" + return 0 + fi + + echo "--frozen-lockfile" +} + repo_pnpm_spec() { local repo_dir="$1" local package_json="${repo_dir}/package.json" @@ -2369,7 +2381,9 @@ install_openclaw_from_git() { cleanup_legacy_submodules "$repo_dir" activate_repo_pnpm_version "$repo_dir" - CI="${CI:-true}" SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" run_quiet_step "Installing dependencies" run_pnpm -C "$repo_dir" install --no-frozen-lockfile + local install_lockfile_flag + install_lockfile_flag="$(git_install_lockfile_flag "$repo_dir" "$git_ref")" + CI="${CI:-true}" SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" run_quiet_step "Installing dependencies" run_pnpm -C "$repo_dir" install "$install_lockfile_flag" if ! run_quiet_step "Building UI" run_pnpm -C "$repo_dir" ui:build; then ui_warn "UI build failed; continuing (CLI may still work)" diff --git a/test/scripts/install-cli.test.ts b/test/scripts/install-cli.test.ts index 0423bc366d3..5d62045b293 100644 --- a/test/scripts/install-cli.test.ts +++ b/test/scripts/install-cli.test.ts @@ -47,8 +47,33 @@ describe("install-cli.sh", () => { expect(result.stdout).toContain("main=main"); }); - it("uses frozen lockfile installs for git installs", () => { - expect(script).toContain('run_pnpm -C "$repo_dir" install --frozen-lockfile'); + it("fetches main without tags for git installs", () => { + expect(script).toContain('git -C "$repo_dir" fetch --no-tags origin main'); + expect(script).toContain('git -C "$repo_dir" pull --rebase --no-tags || true'); + }); + + it("uses non-frozen lockfile installs only for moving git refs", () => { + const result = runInstallCliShell(` + set -euo pipefail + source "${SCRIPT_PATH}" + git() { + if [[ "$1" == "-C" && "$3" == "ls-remote" && "\${7:-}" == "feature" ]]; then + return 0 + fi + return 1 + } + printf 'main=%s\\n' "$(git_install_lockfile_flag /repo main)" + printf 'branch=%s\\n' "$(git_install_lockfile_flag /repo feature)" + printf 'tag=%s\\n' "$(git_install_lockfile_flag /repo v2026.5.12)" + `); + + expect(result.status).toBe(0); + expect(result.stdout).toContain("main=--no-frozen-lockfile"); + expect(result.stdout).toContain("branch=--no-frozen-lockfile"); + expect(result.stdout).toContain("tag=--frozen-lockfile"); + expect(script).toContain( + 'CI="${CI:-true}" SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" run_pnpm -C "$repo_dir" install "$install_lockfile_flag"', + ); }); it("aligns pnpm to the checked-out repo packageManager before installing", () => { diff --git a/test/scripts/install-sh.test.ts b/test/scripts/install-sh.test.ts index ff7e193a769..eedabe1346d 100644 --- a/test/scripts/install-sh.test.ts +++ b/test/scripts/install-sh.test.ts @@ -381,9 +381,32 @@ describe("install.sh", () => { expect(result.stdout).toContain("main=main"); }); - it("uses frozen lockfile installs for git installs", () => { + it("fetches main without tags for git installs", () => { + expect(script).toContain('git -C "$repo_dir" fetch --no-tags origin main'); + expect(script).toContain('git -C "$repo_dir" pull --rebase --no-tags || true'); + }); + + it("uses non-frozen lockfile installs only for moving git refs", () => { + const result = runInstallShell(` + set -euo pipefail + source "${SCRIPT_PATH}" + git() { + if [[ "$1" == "-C" && "$3" == "ls-remote" && "\${7:-}" == "feature" ]]; then + return 0 + fi + return 1 + } + printf 'main=%s\\n' "$(git_install_lockfile_flag /repo main)" + printf 'branch=%s\\n' "$(git_install_lockfile_flag /repo feature)" + printf 'tag=%s\\n' "$(git_install_lockfile_flag /repo v2026.5.12)" + `); + + expect(result.status).toBe(0); + expect(result.stdout).toContain("main=--no-frozen-lockfile"); + expect(result.stdout).toContain("branch=--no-frozen-lockfile"); + expect(result.stdout).toContain("tag=--frozen-lockfile"); expect(script).toContain( - 'run_quiet_step "Installing dependencies" run_pnpm -C "$repo_dir" install --frozen-lockfile', + 'CI="${CI:-true}" SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" run_quiet_step "Installing dependencies" run_pnpm -C "$repo_dir" install "$install_lockfile_flag"', ); });