Repository navigation
fix(node-management): detach to canonical remote ref so remote-only branches install - #2936
Closed
wangzhengzhuo05 wants to merge 1 commit into
Closed
wangzhengzhuo05 wants to merge 1 commit into
wangzhengzhuo05 wants to merge 1 commit into
Conversation
Contributor
Author
|
Closing this to keep the tracker clean \u2014 it has been sitting without review for several days. This is no reflection on the change itself: the fix and its local verification still stand. If the issue is still present and you would like the patch revisited, say the word and I will rebase it onto current main and re-open. Thanks for your time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2919.
install_custom_node(action:install, source:git) with arefthat names a branch existing only as a remote-tracking branch (i.e. it is not the clone's default HEAD, so no local branch of that name exists) fails because:git's DWIM "create a local branch from origin/" kicks in for the bare name and conflicts with
--detach. The install then errors and rolls back the clone.What
In
runGitCheckout(src/services/node-management.ts), aftergit fetch --all --tagsand before the detach, a bare branch/tag name on the non-version path is canonicalized when it does not exist locally:refs/heads/<name>orrefs/tags/<name>exists locally (viagitShowRefExists) → keep the bare name (no DWIM risk).refs/remotes/origin/<name>exists (viagitRemoteRefFor) → use that canonical fully-qualified ref path.git checkout --detach refs/remotes/origin/mainnever triggers DWIM.The
#1470version-derived-channel branch (refFromVersion === true && isGitHeadChannel) is untouched. A probe failure (GitRefProbeError) is now rethrown instead of being misreported as a checkout error.Why
The repository's clone default HEAD can differ from the requested branch (e.g. the repro repo in #2919 defaults to
h3-community-r01, somainis remote-only after clone). The user then gets nothing installed and has togit clone -b mainby hand.Tests
#2919test:ref: "main"with a remote-onlymainasserts the checkout uses["-C", <dir>, "checkout", "--detach", "refs/remotes/origin/main"].checkout --detach "v1.2.3") still passes unchanged, proving locally-present refs keep the bare name.show-refprobe call (checkout assertions preserved in intent).Verification
npx vitest run src/__tests__/services/node-management.test.ts→ 244 passed (243 baseline + 1 new).npm run build(tsc) → clean.#2919test fails (checkout uses the baremain); restoring the fix makes it pass — the regression test genuinely guards the remote-only-branch path.