Repository navigation
fix(): stop gitrid deleting more than was named, and failing on legal input - #15
Merged
Merged
Conversation
… 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>
Merged
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.
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.batis run through cmd, which drops the caret, sogitrid '^fix/'matchedhotfix/too. PowerShell now getsgitrid.ps1, which it runs in preference to the batch file and which passes the pattern through unchanged. Both wrappers usewsl --exec, so$ ( ) |in a pattern are no longer read by a Linux shell on the way.setup_powershell.ps1installs both files.--nukewith a pattern is now an error. It used to drop the pattern and take every branch.mainormaster. The default branch is now found fromorigin/HEAD, then from amain/masterthat 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
-can go after--, or be written[-]...(the form that also works from PowerShell, which takes--for itself).xargsreplaced by an array).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>andgitrid <a> <b>exit 1 where they used to delete something.main/masterand noorigin/HEADexits 1 where it used to run.gitridresolves togitrid.ps1, so the execution policy must allow local scripts (the setup instructions already setRemoteSigned).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,
--helpandllms.txtare updated to match. The version stays 3.1.0, which is not released yet.🤖 Generated with Claude Code