Skip to content

feat!: default to current repository, add --all for all ghq repos#4

Merged
rokuosan merged 4 commits into
masterfrom
feat-current-repository
Jun 15, 2026
Merged

feat!: default to current repository, add --all for all ghq repos#4
rokuosan merged 4 commits into
masterfrom
feat-current-repository

Conversation

@rokuosan

@rokuosan rokuosan commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Breaking change. Until now git wtclean operated on every ghq repository by default, which is surprising for a git subcommand and makes -d/-D a footgun across unrelated repositories.

This PR flips the default:

  • Default → the repository containing the current directory.
  • --all → the previous behaviour (every repo from ghq list -p).

As a bonus, the default path no longer depends on ghq, so the tool now works in a standalone repository without ghq installed.

Behaviour

  • currentRepo() resolves the primary worktree via git worktree list --porcelain -z, so it works correctly even when invoked from inside a linked worktree.
  • Running outside a Git repository exits with code 127 and the message not inside a git repository (use --all to target all ghq repositories).

Changes

  • feat: default to current repository, add --all flag (with tests).
  • docs: update -h help text.
  • docs: update README.

Migration

Anyone relying on the old all-repositories behaviour must now pass --all (e.g. git wtclean --all -d). Worth calling out prominently in the release changelog.

Test

go test ./... and go vet ./... pass.

BREAKING CHANGE: git wtclean now targets only the current repository by default; use --all for the previous all-ghq behaviour.

rokuosan added 3 commits June 16, 2026 02:01
Operating on every ghq repository by default is surprising for a git
subcommand and makes -d/-D a footgun across unrelated repositories.
Default to the repository containing the current directory and gate the
previous all-repositories behaviour behind --all.
@rokuosan rokuosan changed the title feat: default to current repository, add --all for all ghq repos feat!: default to current repository, add --all for all ghq repos Jun 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d41bf5f91

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/wtclean/app.go
git worktree remove deletes a clean linked worktree even when it is the
current checkout, leaving the user inside a deleted directory. Resolve the
current worktree via git rev-parse --show-toplevel and exclude it from the
removal scan in both default and --all modes.
@rokuosan rokuosan self-assigned this Jun 15, 2026
@rokuosan rokuosan merged commit 211a316 into master Jun 15, 2026
2 checks passed
@rokuosan rokuosan deleted the feat-current-repository branch June 15, 2026 17:16
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