fix: pick single-file targets in interactive mode - #77
Open
Dhirenderchoudhary wants to merge 1 commit into
Open
Conversation
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.
The bug
gitpick <file-url> -idied before copying anything:Fixes #75
Interactive mode scopes its walk to
config.pathandreaddirs it unconditionally, so a pick that resolves to a file gets read as a directory.It isn't only
blob:URLsA
tree:pick crashes identically when the path names a file and that's the normal shape on Bitbucket and Codeberg, whosesrc/<ref>/<path>URLs look the same for files and folders (transform-url.tstypes both astree). Reproduced oncodeberg.org/Codeberg/avatars/src/branch/main/README.mdandnrjdalal/picksuite/tree/main/file.txt. So the decision is made on the checkout, not on the URL type — one check covers every host.What changed
bin/index.ts: when the picked root isn't a directory there is nothing to browse, so gitpick says so and copies the file the way the plain pick does.--dry-run, the file overwrite guard,--init/--commit,--tree,-qand temp-dir cleanup all behave exactly as they do without-i.renderTreehoisted above the interactive block so both paths share it instead of duplicating the file-target rendering.-fnever worked in remote interactive mode (only-odid, though the warning names both), and the spinner ignored-q/--tree.README.md: one line under Interactive Mode.Result:
Tests
Six cases in
tests/cli.test.ts: blob URL picks the file,tree:URL that resolves to a file,--dry-runcopies nothing, refuse-then-overwrite (-o,-f),--tree,-q. All six fail on the unfixedbin/index.tsand pass with it.-irefuses to start outside a TTY, so the cases run through a small shim that marks stdout as a TTY and hands over to the built CLI. A single-file pick never opens the picker, so nothing reads keys that keeps the tests portable to the Linux/macOS/Windows matrix, unlike allocating a real pty.bun run test: 284 pass, 0 failoxfmt --checkandoxlintclean