Skip to content

fix(): stop gitrid deleting more than was named, and failing on legal input - #15

Merged
piyook merged 1 commit into
devfrom
fix/review-findings
Oct 9, 2026
Merged

piyook merged 1 commit into
devfrom
fix/review-findings

Conversation

@piyook

@piyook piyook commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Fixes the first seven findings from the code review of 3.1.0. Four of them could delete branches the user did not name; three made gitrid fail on legal input.

Could delete more than intended

  • ^ anchors lost in PowerShell. gitrid.bat is run through cmd, which drops the caret, so gitrid '^fix/' matched hotfix/ too. PowerShell now gets gitrid.ps1, which it runs in preference to the batch file and which passes the pattern through unchanged. Both wrappers use wsl --exec, so $ ( ) | in a pattern are no longer read by a Linux shell on the way. setup_powershell.ps1 installs both files.
  • --nuke with a pattern is now an error. It used to drop the pattern and take every branch.
  • A second pattern is now an error. It used to replace the first without a word.
  • No main or master. The default branch is now found from origin/HEAD, then from a main/master that is only on the remote. If there is none, gitrid stops with exit 1 and deletes nothing. Before, the real default branch was unprotected.

Failed when it should work

  • A pattern starting with - can go after --, or be written [-]... (the form that also works from PowerShell, which takes -- for itself).
  • A quote in a branch name no longer breaks the deletion (xargs replaced by an array).
  • A branch checked out in another worktree is skipped with a message, as the current branch is, so the list shown is what gets deleted.

Also: an answer piped in from PowerShell or cmd ends with a carriage return and was read as "no". It is now read as given.

Behaviour changes to note for the release

  • gitrid --nuke <pattern> and gitrid <a> <b> exit 1 where they used to delete something.
  • A repo with no main/master and no origin/HEAD exits 1 where it used to run.
  • In PowerShell, gitrid resolves to gitrid.ps1, so the execution policy must allow local scripts (the setup instructions already set RemoteSigned).

Tests

Nine new bats tests, one per fix plus the carriage return and the no-local-main case; all nine fail against the script on dev. The suite is 44 tests and passes locally on Git Bash, with ShellCheck clean. The PowerShell and cmd wrappers can't run in CI (no WSL on the runners); they were checked by hand on Windows against a scratch repo.

README, --help and llms.txt are updated to match. The version stays 3.1.0, which is not released yet.

🤖 Generated with Claude Code

… input

- keep the ^ of a pattern from PowerShell: add gitrid.ps1, run with wsl --exec
- --nuke with a pattern, and a second pattern, are errors
- find the default branch from origin/HEAD when there is no main or master
- take a pattern that starts with '-' after '--'
- delete branches with a quote in their name
- skip branches checked out in another worktree
- read a piped answer that ends with a carriage return

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@piyook
piyook merged commit 51e0ade into dev Oct 9, 2026
3 checks passed
@piyook
piyook deleted the fix/review-findings branch October 9, 2026 10:18
@piyook piyook mentioned this pull request Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant