fix: scope git installer lockfile refresh

This commit is contained in:
Keshav's Bot
2026-05-15 00:24:06 +05:30
committed by Peter Steinberger
parent 36411cde8f
commit b26dcb3390
4 changed files with 86 additions and 9 deletions

View File

@@ -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)"

View File

@@ -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)"

View File

@@ -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", () => {

View File

@@ -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"',
);
});