refactor: simplify worktree location options to two choices#11
Merged
refactor: simplify worktree location options to two choices#11
Conversation
Remove the "In subdirectory" option to avoid confusion with Git's internal worktrees/ metadata directory. This simplifies the user experience and prevents potential naming conflicts in bare repositories. Changes: - Remove subdirectory pattern from worktree creation flow - Update constants to reflect two options (same-level and custom) - Remove subdirectory-related tests - Update documentation to recommend .bare pattern for bare repositories - Simplify location validation logic The new two-option approach: 1. Same level as repository (../name) 2. Custom path (any relative path) This allows users to achieve any layout while avoiding the problematic "worktrees/" directory name that conflicts with Git's metadata storage.
After removing the subdirectory option, custom path is now at index 1 instead of 2. Update all test cases to use the correct selection index. This fixes CI test failures in custom_path_behavior_test.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Based on PR review feedback: 1. Improve default fallback in location selection - Change silent fallback to explicit error - Add clear error message for invalid selection - This makes debugging easier if menu options change 2. Remove unused code - Remove unused _repo_name variable - Remove DEFAULT_REPO_NAME from imports - Clean up code after subdirectory removal All tests pass with these improvements.
Code Metrics Report
Code coverage of files in pull request scope (70.5%)
Reported by octocov |
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.
Description
Simplifies worktree creation by reducing location options from 3 to 2 choices. This removes the "In subdirectory" pattern that could cause naming conflicts with Git's internal
worktrees/metadata directory in bare repositories.Type of Change
Changes
Code Changes
create_worktree_with_ui()validate_worktree_location()to accept only two patternsdetermine_worktree_path()WORKTREE_LOCATION_CUSTOM_PATHchanged from index 2 to 1STRING_SUBDIRECTORY,WORKTREE_LOCATION_SUBDIRECTORY,WORKTREES_SUBDIR,REPO_NAME_FALLBACKDocumentation Changes
.barepattern documentation for bare repositoriesTest Changes
New Two-Option Approach
../name) - Creates worktrees as siblings to the repositorymain,branches/feature, etc.This allows users to achieve any layout while avoiding the problematic
worktrees/directory name that conflicts with Git's metadata storage.Testing
cargo testcargo install --path .gw --versionshowing v0.7.0Checklist
cargo fmt)cargo clippy)Impact
Breaking Change: Users who previously selected "In subdirectory" option will now need to use "Custom path" and specify their desired path. The default behavior changes for first-time worktree creation.
Files Changed: 5 files (32 insertions, 90 deletions)
CLAUDE.mdREADME.mdsrc/commands/create.rssrc/constants.rstests/unit/core/constants.rs