fix: fetch git installer branch refs without tags · openclaw/openclaw@a9aafc8
steipete
·
2026-05-15
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -423,21 +423,22 @@ checkout_git_openclaw_ref() {
|
423 | 423 | return 0 |
424 | 424 | fi |
425 | 425 | |
426 | | - git -C "$repo_dir" fetch --tags origin |
427 | | - |
428 | | -if git -C "$repo_dir" rev-parse --verify --quiet "refs/tags/${ref}^{commit}" >/dev/null; then |
429 | | - git -C "$repo_dir" checkout --detach "$ref" |
430 | | -return 0 |
431 | | -fi |
432 | | - |
433 | 426 | if git -C "$repo_dir" ls-remote --exit-code --heads origin "$ref" >/dev/null 2>&1; then |
| 427 | + git -C "$repo_dir" fetch --no-tags origin "refs/heads/${ref}:refs/remotes/origin/${ref}" |
434 | 428 | git -C "$repo_dir" checkout -B "$ref" "origin/$ref" |
435 | 429 | if [[ "$GIT_UPDATE" == "1" ]]; then |
436 | | - git -C "$repo_dir" pull --rebase || true |
| 430 | + git -C "$repo_dir" pull --rebase --no-tags || true |
437 | 431 | fi |
438 | 432 | return 0 |
439 | 433 | fi |
440 | 434 | |
| 435 | + git -C "$repo_dir" fetch --tags origin |
| 436 | + |
| 437 | +if git -C "$repo_dir" rev-parse --verify --quiet "refs/tags/${ref}^{commit}" >/dev/null; then |
| 438 | + git -C "$repo_dir" checkout --detach "$ref" |
| 439 | +return 0 |
| 440 | +fi |
| 441 | + |
441 | 442 | if git -C "$repo_dir" rev-parse --verify --quiet "${ref}^{commit}" >/dev/null; then |
442 | 443 | git -C "$repo_dir" checkout --detach "$ref" |
443 | 444 | return 0 |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1969,21 +1969,22 @@ checkout_git_openclaw_ref() {
|
1969 | 1969 | return 0 |
1970 | 1970 | fi |
1971 | 1971 | |
1972 | | - run_quiet_step "Fetching requested version" git -C "$repo_dir" fetch --tags origin |
1973 | | - |
1974 | | -if git -C "$repo_dir" rev-parse --verify --quiet "refs/tags/${ref}^{commit}" >/dev/null; then |
1975 | | - run_quiet_step "Checking out ${ref}" git -C "$repo_dir" checkout --detach "$ref" |
1976 | | -return 0 |
1977 | | -fi |
1978 | | - |
1979 | 1972 | if git -C "$repo_dir" ls-remote --exit-code --heads origin "$ref" >/dev/null 2>&1; then |
| 1973 | + run_quiet_step "Fetching requested version" git -C "$repo_dir" fetch --no-tags origin "refs/heads/${ref}:refs/remotes/origin/${ref}" |
1980 | 1974 | run_quiet_step "Checking out ${ref}" git -C "$repo_dir" checkout -B "$ref" "origin/$ref" |
1981 | 1975 | if [[ "$GIT_UPDATE" == "1" ]]; then |
1982 | | - run_quiet_step "Updating repository" git -C "$repo_dir" pull --rebase || true |
| 1976 | + run_quiet_step "Updating repository" git -C "$repo_dir" pull --rebase --no-tags || true |
1983 | 1977 | fi |
1984 | 1978 | return 0 |
1985 | 1979 | fi |
1986 | 1980 | |
| 1981 | + run_quiet_step "Fetching requested version" git -C "$repo_dir" fetch --tags origin |
| 1982 | + |
| 1983 | +if git -C "$repo_dir" rev-parse --verify --quiet "refs/tags/${ref}^{commit}" >/dev/null; then |
| 1984 | + run_quiet_step "Checking out ${ref}" git -C "$repo_dir" checkout --detach "$ref" |
| 1985 | +return 0 |
| 1986 | +fi |
| 1987 | + |
1987 | 1988 | if git -C "$repo_dir" rev-parse --verify --quiet "${ref}^{commit}" >/dev/null; then |
1988 | 1989 | run_quiet_step "Checking out ${ref}" git -C "$repo_dir" checkout --detach "$ref" |
1989 | 1990 | return 0 |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -47,9 +47,18 @@ describe("install-cli.sh", () => {
|
47 | 47 | expect(result.stdout).toContain("main=main"); |
48 | 48 | }); |
49 | 49 | |
50 | | -it("fetches main without tags for git installs", () => { |
| 50 | +it("fetches moving git refs without tags for git installs", () => { |
51 | 51 | expect(script).toContain('git -C "$repo_dir" fetch --no-tags origin main'); |
| 52 | +expect(script).toContain( |
| 53 | +'git -C "$repo_dir" fetch --no-tags origin "refs/heads/${ref}:refs/remotes/origin/${ref}"', |
| 54 | +); |
52 | 55 | expect(script).toContain('git -C "$repo_dir" pull --rebase --no-tags || true'); |
| 56 | + |
| 57 | +const branchCheckIndex = script.indexOf('ls-remote --exit-code --heads origin "$ref"'); |
| 58 | +const tagFetchIndex = script.indexOf("fetch --tags origin"); |
| 59 | +expect(branchCheckIndex).toBeGreaterThan(-1); |
| 60 | +expect(tagFetchIndex).toBeGreaterThan(-1); |
| 61 | +expect(branchCheckIndex).toBeLessThan(tagFetchIndex); |
53 | 62 | }); |
54 | 63 | |
55 | 64 | it("uses non-frozen lockfile installs only for moving git refs", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -381,9 +381,18 @@ describe("install.sh", () => {
|
381 | 381 | expect(result.stdout).toContain("main=main"); |
382 | 382 | }); |
383 | 383 | |
384 | | -it("fetches main without tags for git installs", () => { |
| 384 | +it("fetches moving git refs without tags for git installs", () => { |
385 | 385 | expect(script).toContain('git -C "$repo_dir" fetch --no-tags origin main'); |
| 386 | +expect(script).toContain( |
| 387 | +'git -C "$repo_dir" fetch --no-tags origin "refs/heads/${ref}:refs/remotes/origin/${ref}"', |
| 388 | +); |
386 | 389 | expect(script).toContain('git -C "$repo_dir" pull --rebase --no-tags || true'); |
| 390 | + |
| 391 | +const branchCheckIndex = script.indexOf('ls-remote --exit-code --heads origin "$ref"'); |
| 392 | +const tagFetchIndex = script.indexOf("fetch --tags origin"); |
| 393 | +expect(branchCheckIndex).toBeGreaterThan(-1); |
| 394 | +expect(tagFetchIndex).toBeGreaterThan(-1); |
| 395 | +expect(branchCheckIndex).toBeLessThan(tagFetchIndex); |
387 | 396 | }); |
388 | 397 | |
389 | 398 | it("uses non-frozen lockfile installs only for moving git refs", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。