Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: default worktrees under .git/wtp/worktrees with legacy warning #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
satococoa wants to merge 3 commits into main
base: main
Choose a base branch
Loading
from feature/default-worktree-dir

Conversation

@satococoa
Copy link
Owner

@satococoa satococoa commented Dec 4, 2025
edited by coderabbitai bot
Loading

Summary

  • change default worktree base_dir to .git/wtp/worktrees
  • emit a warning when legacy ../worktrees exists and no config is present
  • update docs and tests for the new default

Testing

  • go test ./...

Summary by CodeRabbit

  • New Features

    • Automatic warnings now notify users if legacy worktree locations are present and suggest remediation.
  • Changes

    • Default worktree storage moved to .git/wtp/worktrees (replaces previous ../worktrees).
  • Documentation

    • Docs, examples, and architecture guides updated to reflect the new default worktree path.
  • Tests

    • Test expectations updated to align with the new worktree path and warning behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 4, 2025 14:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the default worktree directory structure by moving from ../worktrees to .git/wtp/worktrees, keeping all worktree-related files within the repository's .git directory. A backward-compatible warning system alerts users with existing legacy worktree directories.

Key Changes:

  • Default worktree base directory changed from ../worktrees to .git/wtp/worktrees
  • Added legacy directory detection with helpful migration warning
  • Comprehensive test suite and documentation updates across the codebase

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/config/config.go Updates default base directory constant and adds ConfigFileExists helper function
internal/config/config_test.go Updates tests to use new default path constant and adds ConfigFileExists test coverage
cmd/wtp/legacy_warning.go Implements warning logic to detect legacy ../worktrees directories when no config exists
cmd/wtp/legacy_warning_test.go Comprehensive test coverage for legacy warning scenarios
cmd/wtp/add.go Integrates legacy warning into the add command workflow
cmd/wtp/cd.go Integrates legacy warning into the cd command workflow
cmd/wtp/list.go Integrates legacy warning into the list command workflow
cmd/wtp/remove.go Integrates legacy warning into the remove command workflow
cmd/wtp/init.go Updates template configuration to use new default base directory
cmd/wtp/init_test.go Verifies init command generates config with new default path
test/e2e/worktree_test.go Updates end-to-end tests to use new default worktree paths
test/e2e/hook_streaming_test.go Updates hook streaming tests with new default path and comment
cmd/wtp/remove_test.go Updates all test fixtures with new default worktree path structure
cmd/wtp/cd_test.go Updates test fixtures to reflect new default path
cmd/wtp/list_test.go Updates all test cases to use new default base directory constant
internal/command/executor_test.go Updates command executor tests with new default paths
docs/architecture.md Updates architecture documentation with new default directory structure
README.md Updates user-facing documentation with new default paths and directory structure examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

coderabbitai bot commented Dec 4, 2025
edited
Loading

Walkthrough

Default worktree base directory changed from ../worktrees to .git/wtp/worktrees across code, docs, and tests. A new private helper emits a legacy-base-dir warning when old worktrees are present and no config exists; commands call this warning and error-writer handling was added.

Changes

Cohort / File(s) Summary
Configuration & Constants
internal/config/config.go, internal/config/config_test.go
DefaultBaseDir updated to .git/wtp/worktrees. Added public FileExists(repoRoot string) bool to check for config presence (absolute path normalization). Tests updated to use DefaultBaseDir and cover FileExists.
Legacy Warning Feature
cmd/wtp/legacy_warning.go, cmd/wtp/legacy_warning_test.go
New warnLegacyBaseDir(errWriter io.Writer, repoRoot string) helper that checks for legacy worktrees, config absence, and writes a two-line warning to the provided writer. Tests cover warning/no-warning scenarios.
Command Implementations
cmd/wtp/add.go, cmd/wtp/cd.go, cmd/wtp/remove.go, cmd/wtp/list.go
Commands now obtain an error writer from cmd.Root().ErrWriter (fallback os.Stderr), determine main repository path, and call warnLegacyBaseDir() prior to execution. Minor repo initialization adjustments to capture repo/mainRepoPath.
Init Command
cmd/wtp/init.go, cmd/wtp/init_test.go
Default generated .wtp.yml template now sets base_dir: .git/wtp/worktrees. Tests updated to expect the new template content.
Command Tests
cmd/wtp/cd_test.go, cmd/wtp/list_test.go, cmd/wtp/remove_test.go, other cmd/wtp/*_test.go
Numerous tests updated to use config.DefaultBaseDir or the new .git/wtp/worktrees path for expected worktree locations and command argument assertions. Some tests adjust special-case relative-base handling.
Command Executor Tests
internal/command/executor_test.go
Test fixtures and expected command args updated to reference .git/wtp/worktrees/... instead of ../worktrees/....
Documentation
README.md, docs/architecture.md
Examples, diagrams, and narrative updated to show .git/wtp/worktrees as the default base_dir and to use the new path in example outputs.
End-to-End Tests
test/e2e/worktree_test.go, test/e2e/hook_streaming_test.go
E2E assertions and test setup updated to validate worktrees under repo.Path() + "/.git/wtp/worktrees/..." and adjusted hook-related checks accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Files needing extra attention:
    • cmd/wtp/legacy_warning.go — correctness of filesystem checks and config-path construction
    • internal/config/config.goFileExists absolute-path behavior and interaction with LoadConfig defaults
    • Command changes in cmd/wtp/* — consistent error-writer retrieval and mainRepoPath fallback handling
    • Wide test updates — ensure all path string substitutions are consistent and no lingering hard-coded paths remain

Possibly related PRs

Suggested labels

codex

Poem

🐰 A nook beneath .git where small worktrees hide,
I hop and I whisper when old paths still bide.
A gentle two-line warning I gladly bestow,
So new bases flourish where quiet roots grow. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.45% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: defaulting worktrees to .git/wtp/worktrees and adding a legacy warning, matching the primary objectives of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/default-worktree-dir

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0f56d9 and ec732f8.

📒 Files selected for processing (4)
  • cmd/wtp/legacy_warning.go (1 hunks)
  • internal/config/config.go (3 hunks)
  • internal/config/config_test.go (6 hunks)
  • test/e2e/worktree_test.go (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • test/e2e/worktree_test.go
  • cmd/wtp/legacy_warning.go
  • internal/config/config.go
  • internal/config/config_test.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test (macos-latest, 1.24)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
internal/config/config.go (1)

45-189: Rename ConfigFileExists to satisfy lint and avoid stuttering package name

The new default DefaultBaseDir = ".git/wtp/worktrees" and the use of this constant in LoadConfig look consistent and correct.

The main issue is the exported helper:

// ConfigFileExists reports whether the config file exists in the given repository root.
func ConfigFileExists(repoRoot string) bool {
 ...
}

Static analysis correctly notes that config.ConfigFileExists stutters the package name; this will keep the lint job red.

Consider renaming it to avoid the stutter, e.g.:

-// ConfigFileExists reports whether the config file exists in the given repository root.
-func ConfigFileExists(repoRoot string) bool {
+// FileExists reports whether the config file exists in the given repository root.
+func FileExists(repoRoot string) bool {

and update call sites accordingly. Behavior (path cleaning, os.Stat, and conservative false on errors) is otherwise fine.

test/e2e/worktree_test.go (1)

145-160: Aligns e2e paths with new base_dir; split long git command line for linter

The e2e updates correctly move expectations from legacy ../worktrees to .git/wtp/worktrees, both for the remove‐outside‐base_dir case and for post‐create hooks.

There is one linter issue on the long env.RunInDir line in the RemoveOnlyWorksWithinBaseDir test; you can fix it by splitting arguments:

-		env.RunInDir(repo.Path(), "git", "worktree", "add", ".git/wtp/worktrees/feature/remove-test", "-b", "feature/remove-test")
+		env.RunInDir(
+			repo.Path(),
+			"git",
+			"worktree",
+			"add",
+			".git/wtp/worktrees/feature/remove-test",
+			"-b",
+			"feature/remove-test",
+		)

This keeps behavior identical while satisfying the lll (max line length) rule.

Also applies to: 275-292

🧹 Nitpick comments (1)
cmd/wtp/init.go (1)

65-102: Config template now matches new default base_dir

The generated .wtp.yml now uses base_dir: .git/wtp/worktrees, matching config.DefaultBaseDir and the rest of the PR. Looks good.

If you ever find this drifting again, you might consider building this string with config.DefaultBaseDir instead of a hard-coded literal, but that’s strictly optional.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7387d and a0f56d9.

📒 Files selected for processing (18)
  • README.md (5 hunks)
  • cmd/wtp/add.go (1 hunks)
  • cmd/wtp/cd.go (1 hunks)
  • cmd/wtp/cd_test.go (2 hunks)
  • cmd/wtp/init.go (1 hunks)
  • cmd/wtp/init_test.go (1 hunks)
  • cmd/wtp/legacy_warning.go (1 hunks)
  • cmd/wtp/legacy_warning_test.go (1 hunks)
  • cmd/wtp/list.go (1 hunks)
  • cmd/wtp/list_test.go (13 hunks)
  • cmd/wtp/remove.go (1 hunks)
  • cmd/wtp/remove_test.go (15 hunks)
  • docs/architecture.md (3 hunks)
  • internal/command/executor_test.go (4 hunks)
  • internal/config/config.go (3 hunks)
  • internal/config/config_test.go (6 hunks)
  • test/e2e/hook_streaming_test.go (1 hunks)
  • test/e2e/worktree_test.go (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Follow standard Go style with tabs and gofmt; package names must be short and lowercase
Keep import groups tidy; use goimports for organization with local prefix following module path github.com/satococoa/wtp/v2
Adhere to linting rules in .golangci.yml (vet, staticcheck, gosec, mnd, lll=120)
Wrap errors with context; avoid ignoring errors in Go code
Use snake_case for Go filenames (e.g., remove.go, shell_integration.go)
Document exported items in Go when non-trivial; follow godoc conventions

Files:

  • test/e2e/hook_streaming_test.go
  • cmd/wtp/add.go
  • cmd/wtp/cd_test.go
  • cmd/wtp/list.go
  • test/e2e/worktree_test.go
  • cmd/wtp/legacy_warning.go
  • internal/config/config.go
  • cmd/wtp/init_test.go
  • cmd/wtp/remove.go
  • cmd/wtp/legacy_warning_test.go
  • internal/command/executor_test.go
  • cmd/wtp/init.go
  • internal/config/config_test.go
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*_test.go: Unit tests must be placed alongside packages as *_test.go files in the same directory
Target 70% code coverage with unit tests focusing on fast feedback and mocked git interactions using table-driven test cases

Files:

  • test/e2e/hook_streaming_test.go
  • cmd/wtp/cd_test.go
  • test/e2e/worktree_test.go
  • cmd/wtp/init_test.go
  • cmd/wtp/legacy_warning_test.go
  • internal/command/executor_test.go
  • internal/config/config_test.go
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
test/e2e/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

End-to-end tests must be placed in test/e2e and exercise real git workflows using the built binary

Files:

  • test/e2e/hook_streaming_test.go
  • test/e2e/worktree_test.go
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Worktree naming convention: main worktree is rendered as `@`; non-main worktrees display path relative to `base_dir` (e.g., `.worktrees/feat/hoge` → `feat/hoge`)
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Run commands from inside a worktree to mimic real usage (e.g., `go run ../cmd/wtp add feature/new-feature`)
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Shell integration must separate completion and hooks for clarity; `wtp cd` outputs absolute worktree path with no side effects
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Worktree naming convention: main worktree is rendered as `@`; non-main worktrees display path relative to `base_dir` (e.g., `.worktrees/feat/hoge` → `feat/hoge`)

Applied to files:

  • README.md
  • cmd/wtp/cd_test.go
  • test/e2e/worktree_test.go
  • cmd/wtp/init.go
  • docs/architecture.md
  • internal/config/config_test.go
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Run commands from inside a worktree to mimic real usage (e.g., `go run ../cmd/wtp add feature/new-feature`)

Applied to files:

  • README.md
  • test/e2e/hook_streaming_test.go
  • cmd/wtp/add.go
  • cmd/wtp/cd_test.go
  • test/e2e/worktree_test.go
  • cmd/wtp/legacy_warning.go
  • cmd/wtp/init_test.go
  • cmd/wtp/remove.go
  • cmd/wtp/legacy_warning_test.go
  • internal/command/executor_test.go
  • cmd/wtp/init.go
  • docs/architecture.md
  • internal/config/config_test.go
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Shell integration must separate completion and hooks for clarity; `wtp cd` outputs absolute worktree path with no side effects

Applied to files:

  • README.md
  • test/e2e/hook_streaming_test.go
  • cmd/wtp/cd_test.go
  • test/e2e/worktree_test.go
  • cmd/wtp/init.go
  • docs/architecture.md
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Branch naming must follow conventions: `feature/...`, `fix/...`, `hotfix/...` to align with worktree paths

Applied to files:

  • README.md
  • cmd/wtp/cd_test.go
  • docs/architecture.md
  • cmd/wtp/remove_test.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Applies to .wtp.yml : Project hooks must be defined in `.wtp.yml`; keep commands deterministic and safe, avoiding destructive steps by default

Applied to files:

  • README.md
  • cmd/wtp/init.go
  • docs/architecture.md
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Toggle shell integration paths with `WTP_SHELL_INTEGRATION=1` when testing cd behavior

Applied to files:

  • README.md
  • docs/architecture.md
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Applies to test/e2e/**/*.go : End-to-end tests must be placed in `test/e2e` and exercise real git workflows using the built binary

Applied to files:

  • test/e2e/hook_streaming_test.go
  • cmd/wtp/cd_test.go
  • test/e2e/worktree_test.go
  • cmd/wtp/init_test.go
  • cmd/wtp/legacy_warning_test.go
  • internal/command/executor_test.go
  • internal/config/config_test.go
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Applies to **/*_test.go : Target 70% code coverage with unit tests focusing on fast feedback and mocked git interactions using table-driven test cases

Applied to files:

  • test/e2e/hook_streaming_test.go
  • cmd/wtp/cd_test.go
  • test/e2e/worktree_test.go
  • cmd/wtp/init_test.go
  • cmd/wtp/legacy_warning_test.go
  • internal/command/executor_test.go
  • internal/config/config_test.go
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: CLI entrypoint is located at `cmd/wtp`; new command implementations must integrate with the main CLI structure

Applied to files:

  • cmd/wtp/add.go
  • cmd/wtp/cd_test.go
  • cmd/wtp/list.go
  • cmd/wtp/legacy_warning.go
  • cmd/wtp/init_test.go
  • cmd/wtp/remove.go
  • cmd/wtp/legacy_warning_test.go
  • internal/command/executor_test.go
  • cmd/wtp/init.go
  • docs/architecture.md
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: The root module is `github.com/satococoa/wtp/v2` running on Go 1.24; maintain module path consistency

Applied to files:

  • cmd/wtp/add.go
  • cmd/wtp/cd_test.go
  • cmd/wtp/legacy_warning.go
  • cmd/wtp/init_test.go
  • cmd/wtp/remove.go
  • cmd/wtp/init.go
  • docs/architecture.md
  • cmd/wtp/list_test.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Applies to **/*.go : Keep import groups tidy; use goimports for organization with local prefix following module path `github.com/satococoa/wtp/v2`

Applied to files:

  • cmd/wtp/cd_test.go
  • cmd/wtp/legacy_warning.go
  • cmd/wtp/init_test.go
  • cmd/wtp/remove.go
  • cmd/wtp/init.go
  • cmd/wtp/remove_test.go
  • cmd/wtp/cd.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Applies to **/*_test.go : Unit tests must be placed alongside packages as `*_test.go` files in the same directory

Applied to files:

  • cmd/wtp/cd_test.go
  • cmd/wtp/legacy_warning_test.go
  • internal/config/config_test.go
  • cmd/wtp/remove_test.go
📚 Learning: 2025年12月02日T13:33:48.673Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025年12月02日T13:33:48.673Z
Learning: Use `go run ./cmd/wtp <args>` for rapid feedback during development instead of building binaries

Applied to files:

  • cmd/wtp/cd_test.go
  • cmd/wtp/init.go
  • docs/architecture.md
  • cmd/wtp/cd.go
🧬 Code graph analysis (9)
cmd/wtp/list.go (1)
internal/config/config.go (1)
  • LoadConfig (54-94)
cmd/wtp/legacy_warning.go (1)
internal/config/config.go (3)
  • ConfigFileExists (176-189)
  • DefaultBaseDir (45-45)
  • ConfigFileName (41-41)
cmd/wtp/remove.go (2)
internal/git/repository.go (1)
  • NewRepository (20-25)
internal/errors/errors.go (1)
  • NotInGitRepository (11-19)
cmd/wtp/legacy_warning_test.go (1)
internal/config/config.go (1)
  • ConfigFileName (41-41)
internal/command/executor_test.go (1)
internal/command/builders.go (2)
  • GitWorktreeAdd (13-46)
  • GitWorktreeAddOptions (5-10)
internal/config/config_test.go (1)
internal/config/config.go (4)
  • Defaults (20-22)
  • DefaultBaseDir (45-45)
  • ConfigFileExists (176-189)
  • ConfigFileName (41-41)
cmd/wtp/list_test.go (1)
internal/config/config.go (2)
  • Defaults (20-22)
  • DefaultBaseDir (45-45)
cmd/wtp/remove_test.go (1)
internal/command/types.go (1)
  • Command (4-8)
cmd/wtp/cd.go (2)
internal/git/repository.go (1)
  • NewRepository (20-25)
internal/errors/errors.go (1)
  • NotInGitRepository (11-19)
🪛 GitHub Actions: CI
cmd/wtp/legacy_warning.go

[error] 35-35: golangci-lint: Error return value of fmt.Fprintf is not checked (errcheck).

🪛 GitHub Check: Lint
test/e2e/worktree_test.go

[failure] 145-145:
The line is 124 characters long, which exceeds the maximum of 120 characters. (lll)

cmd/wtp/legacy_warning.go

[failure] 36-36:
Error return value of fmt.Fprintf is not checked (errcheck)


[failure] 35-35:
Error return value of fmt.Fprintf is not checked (errcheck)

internal/config/config.go

[failure] 176-176:
exported: func name will be used as config.ConfigFileExists by other packages, and that stutters; consider calling this FileExists (revive)

🔇 Additional comments (15)
test/e2e/hook_streaming_test.go (1)

49-51: E2E expectation aligned with new default worktree base_dir

The test now asserts the worktree under <repo>/.git/wtp/worktrees/test-branch, which matches the new DefaultBaseDir. The use of filepath.Join keeps it portable.

cmd/wtp/add.go (1)

68-73: Legacy base-dir warning wiring looks correct

Using cmd.Root().ErrWriter (falling back to os.Stderr) and calling warnLegacyBaseDir(errWriter, mainRepoPath) before command execution is a good pattern and keeps warnings off the normal output stream. This is consistent with the rest of the CLI.

cmd/wtp/list.go (1)

107-121: Consistent legacy-base-dir warning on list

The addition of errWriter (defaulting to os.Stderr) and warnLegacyBaseDir(errWriter, mainRepoPath) keeps legacy warnings consistent with other commands and correctly routes them to the error stream instead of stdout. No functional issues spotted here.

cmd/wtp/init_test.go (1)

133-157: Test expectation correctly updated for new base_dir

The success test now checks for base_dir: .git/wtp/worktrees, matching the updated init template and config default. This keeps the test aligned with the new behavior.

cmd/wtp/cd_test.go (1)

20-52: cd tests now track the new default worktree location

The worktree list fixture and both expected paths have been updated to /Users/dev/project/main/.git/wtp/worktrees/feature/auth, which matches the new default base_dir. This keeps the "absolute path" guarantees tested without changing test intent.

README.md (1)

15-341: Documentation correctly reflects new worktree base_dir

All updated references to the default worktree location (.git/wtp/worktrees/...) in the feature description, quick-start examples, config snippet, and Worktree Structure diagram now match the code’s DefaultBaseDir and the test expectations. The narrative and examples are consistent with the new layout.

docs/architecture.md (1)

103-116: Docs align with new .git/wtp/worktrees default and cd behavior

The configuration example, cd flow, and path-handling description all correctly reference .git/wtp/worktrees, matching the new DefaultBaseDir and shell integration behavior. No issues from an architecture/docs perspective.

Also applies to: 164-175, 213-216

internal/command/executor_test.go (1)

19-20: Executor/builder tests correctly updated to new base_dir

The updated expected paths under .git/wtp/worktrees/feature keep these tests aligned with the new default base_dir and the GitWorktreeAdd/GitWorktreeRemove builders. No further changes needed.

Also applies to: 38-39, 168-177, 182-183, 194-195

cmd/wtp/remove.go (1)

84-104: Legacy warning wiring in remove looks correct

Using git.NewRepository to derive mainRepoPath, then sending warnLegacyBaseDir output to cmd.Root().ErrWriter (with sensible fallbacks) integrates the legacy base_dir warning cleanly into remove without changing existing removal behavior.

cmd/wtp/cd.go (1)

59-81: cd now correctly emits legacy warnings using main repo path

Deriving mainRepoPath from the repository and routing warnLegacyBaseDir to the command’s error writer integrates the legacy base_dir warning into wtp cd without affecting its core behavior (absolute path output only). This is consistent with how other commands handle the warning.

internal/config/config_test.go (1)

21-23: Config tests now track DefaultBaseDir and cover config existence

Switching assertions to DefaultBaseDir removes hard‐coding of the old ../worktrees default, and the new TestConfigFileExists gives good coverage of the config presence helper. The updated ResolveWorktreePath expectations match the new .git/wtp/worktrees/... layout.

Also applies to: 98-113, 171-190, 356-384

cmd/wtp/list_test.go (1)

138-140: List tests correctly updated to use config.DefaultBaseDir where appropriate

Using config.DefaultBaseDir in list tests keeps them in sync with the new default base_dir while still overriding to .worktrees in scenarios that explicitly exercise non-default configurations. The overall coverage of formatting, path display, and quiet mode remains intact.

Also applies to: 215-217, 268-270, 298-300, 368-369, 795-803, 894-895, 945-952, 989-990, 1027-1028, 1145-1147, 1233-1235

cmd/wtp/legacy_warning_test.go (1)

12-83: Legacy warning tests cover all key branches cleanly

The three tests nicely exercise: (1) legacy ../worktrees present with no config (warning expected), (2) legacy dir plus config (no warning), and (3) no legacy dir (no warning). Using t.TempDir, concrete placeholder files, and substring assertions on both the legacy-directory wording and config.ConfigFileName should make regressions in warnLegacyBaseDir easy to catch while staying decoupled from the exact message format. This looks solid as-is.

cmd/wtp/remove_test.go (2)

45-52: Worktree path literals consistently updated to .git/wtp/worktrees

Across the remove-command tests (resolution, command construction, success/dirty flows, branch deletion, i18n/space-containing paths, and multiple-match selection), the mocked git worktree list output and expected remove targets now uniformly use the new .git/wtp/worktrees/... base. The scenarios still exercise the same behavioral surface area and edge cases as before, just with the updated layout, so this aligns well with the PR’s default-base-dir objective.

Also applies to: 54-60, 132-195, 233-297, 353-370, 394-442, 444-464, 466-552, 554-648, 652-704, 706-733, 735-791


353-370: Confirm intended main worktree path in TestRemoveCommand_WorktreeNotFound

Here the only listed worktree is mocked as worktree /path/to/main/.git/wtp/worktrees/main for the refs/heads/main entry. In many setups git worktree list reports the primary worktree at the repo root (e.g., /path/to/main) with additional worktrees under the configured base directory. If any of your parsing or display logic distinguishes the main worktree by comparing its path to the repo root, this mocked layout might diverge from actual output and slightly weaken the realism of the test.

If main is indeed represented under .git/wtp/worktrees/main in your flow, then this is fine; otherwise, consider switching this mock back to /path/to/main to preserve that invariant.

Copy link
Owner Author

Updating the direction for this PR: instead of changing the default worktree base dir to .git/wtp/worktrees, I’d like to switch the default to ../wtp/<repo>/.

Rationale:

  • Keeps worktrees out of the repo working tree (no git status noise, no need for .gitignore)
  • Avoids relying on .git internals / .git-file vs .git-dir edge cases
  • Reduces collisions across multiple repos (namespacing by <repo>), while keeping the location easy to discover (near the repo)

I still think the "legacy warning when ../worktrees exists and no config is present" approach in this PR is great for migration, so I’ll keep that mechanism and just adjust:

  • new default: ../wtp/<repo>/
  • legacy detection: ../worktrees + no config → emit a warning for a limited period

I’ll update docs and tests accordingly in the next commits.

adampoit reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Copilot code review Copilot Copilot left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /