fix: handle spaces in home directory paths on Windows#94
Merged
Conversation
- expandHome: support ~\ (backslash) prefix and expand $HOME/${HOME}/%USERPROFILE% via os.ExpandEnv
- remove: use porcelain worktree list to avoid strings.Fields splitting paths with spaces
- shellenv: shell-quote arguments in Linux script(1) invocation to preserve spaces
- config template: quote $WT_PATH/$WT_MAIN in hook examples
Closes #93
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #94 +/- ##
==========================================
+ Coverage 30.10% 30.58% +0.48%
==========================================
Files 27 27
Lines 2787 2805 +18
==========================================
+ Hits 839 858 +19
+ Misses 1863 1860 -3
- Partials 85 87 +2
🚀 New features to boost your workflow:
|
os.ExpandEnv only handles $VAR and ${VAR}. Add expandWindowsEnv for
%USERPROFILE% and similar Windows-style variables, called on Windows only.
Follow-up from Codex review of #94.
The tilde branch returned early, skipping os.ExpandEnv. Now env expansion runs on all paths including those starting with ~. Follow-up from Codex review round 2.
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 #93 — multiple code paths broke when the user's home folder contained spaces (e.g.
C:\Users\John Doe\).Bugs fixed:
expandHome: only recognized~/prefix, not~\(Windows backslash). Also addedos.ExpandEnvfallback so$HOME,${HOME}, and%USERPROFILE%are expanded in therootconfig value.remove.go: usedstrings.Fieldsto parsegit worktree listoutput, which splits paths on spaces. Switched to the porcelain parser (getWorktreeListPorcelain) which handles spaces correctly.shellenv.go: Linuxscript -c "command wt $*"broke when arguments contained spaces. Now shell-quotes each argument withprintf '%q'.$WT_PATH/$WT_MAIN; added quoting guidance and quoted the examples.Test plan
expandHomewith~\,$VAR,${VAR}, unset varsfindWorktreeByBranchwith spaces in pathsstrings.Fieldsapproach)go vet ./...clean