shmuelie / shmuelie/powershell-modules
The worktree predictor emits invalid PowerShell for valid branch names containing apostrophes
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 0
- Forks
- 0
- Avg merge
- 21m
- Merged PRs (30d)
- 124
Description
Finding
Severity: low. Confidence: 10/10.
Reviewed snapshot: 5c38677469756c69f86678c0b907d82e15d0a539.
Git branch names can contain characters meaningful to PowerShell; suggestions never encode the completed branch as a literal PowerShell argument.
Accepting a suggestion for a valid existing branch such as feature/quote'branch creates a syntactically invalid command. Other shell-sensitive names need equivalent literal preservation. The newer argument completer's quoting does not protect this independent C# suggestion path.
Source
GetSuggestion interpolates the raw branch into a command string: new PredictiveSuggestion($"{prefix}{branch}").
Safe reproduction
- Compile the exact current predictor source with equivalent project settings in a fresh pwsh process.
- Create a predictor instance and seed its cached worktree branch array with the legal name feature/quote'branch.
- Call GetSuggestion for 'Remove-Worktree -BranchName feature/q'.
- Parse, but do not execute, the emitted suggestion.
Observed:
{
"suggestion": "Remove-Worktree -BranchName feature/quote'branch",
"parseError": "TerminatorExpectedAtEndOfString",
"message": "The string is missing the terminator: '."
}
Expected: A suggestion retains the command and user flags while completing the branch as one unchanged literal argument that parses successfully.
The reviewer and parent independently replayed the controlled reproduction.
Only owned fixtures, isolated event subscribers or parser-only suggestions were
used; no user repository was updated or real command suggestion executed.
Acceptance criteria
- Emit literal PowerShell syntax for branch names containing apostrophes or other legal shell-sensitive characters.
- Test both worktree-branch and checkoutable-branch suggestions through the PowerShell parser.
- Preserve the typed command, flags, casing, substring matching, and normal simple-branch suggestions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/Shmuelie.Git/Predictor/WorktreePredictor.cs, especially lines 119-133 and the GetSuggestion path. Reproduce the apostrophe case with the PowerShell parser, then cover both worktree-branch and checkoutable-branch suggestions. Done means shell-sensitive names parse as one unchanged literal argument while preserving the typed command, flags, casing, matching, and simple-branch behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100