You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LGTM with a few changes requested. The approach is minimal and backward-compatible.
What I checked:
deno task check ✅
deno task fmt:check ✅
deno test --allow-all src/cmd/tests/authless_help_test.ts ✅
I did not run the full live integration tests because the VAL_TOWN_API_KEY available in this session is for the local dev stack and api.val.town returns 401; deno task check covers the new test code.
Requested changes:
src/cmd/lib/clone.ts ignores the branchName argument. The README and .arguments line both promise vt clone [valUri] [targetDir] [branchName], but the value is never passed to VTClient.clone. This PR makes that bug more visible because any non-default branch passed to clone will still be persisted as main. Since VTClient.clone already accepts branchName, the fix is one line:
src/cmd/lib/checkout.ts has a stale comment at lines 147-151 that says "we store the branch ID, not the branch name." That is no longer true after this PR. Please remove or update that comment. The current logic using currentBranchData.name is still correct; the comment is just misleading.
Add a branch-name assertion to src/cmd/tests/clone_test.ts. checkout_test.ts covers it indirectly, but the PR description says clone is a state-writing path. A good place is the clone a newly created val or clone command output test:
import{DEFAULT_BRANCH_NAME}from"~/consts.ts";import{readPersistedBranchName}from"~/cmd/tests/utils.ts";assertEquals(awaitreadPersistedBranchName(targetDir),DEFAULT_BRANCH_NAME,"clone should persist the checked-out branch name",);
If you fix (1), please also add a test cloning a non-default branch.
Branch rename edge case (the question you asked):
state.json stores the branch name as a cache. If a branch is renamed on Val Town, the file stays stale until the next clone, create, remix, or checkout. push, pull, status, branch, and checkout all use branch.id and live API names, so they keep working. status prints the live name. Only shell prompts that read state.json directly would show the old name. Since we don't need to sync, that's the expected behavior.
Optional nit: readPersistedBranchName in tests reads raw JSON. That's fine, but using VTMeta.loadVtState would keep the test aligned with the schema. Not a blocker.
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
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
.vt/state.json.checkout -b.Why
Local tooling, including shell prompts, can determine the active Val Town branch without an API call.
Validation
deno task checkcheckout -b.vt/state.jsonafter clone and checkout