Skip to content

Commit 874d57c

Browse files
committed
refactor: simplify to menu-only interface with comprehensive docs and fixes
1 parent 71b83f1 commit 874d57c

31 files changed

Lines changed: 3937 additions & 1500 deletions

.git-workers.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Git Workers configuration file
2+
3+
[repository]
4+
# Repository URL for identification (optional)
5+
# This ensures hooks only run in the intended repository
6+
url = "https://github.com/wasabeef/git-workers.git"
7+
8+
[hooks]
9+
# Run after creating a new worktree
10+
post-create = [
11+
"echo '🤖 Created worktree: {{worktree_name}}'",
12+
"echo '🤖 Path: {{worktree_path}}'"
13+
]
14+
15+
# Run before removing a worktree
16+
pre-remove = [
17+
"echo '🤖 Removing worktree: {{worktree_name}}'"
18+
]
19+
20+
# Run after switching to a worktree
21+
post-switch = [
22+
"echo 'S🤖 witched to: {{worktree_name}}'"
23+
]

CHANGELOG.md

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,86 @@
11
# Changelog
22

3-
Please see [GitHub Releases](https://github.com/wasabeef/git-workers/releases) for the complete changelog.
3+
All notable changes to Git Workers will be documented in this file.
44

5-
Each release includes:
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

7-
- Detailed release notes generated from commit history
8-
- Binary downloads for all supported platforms
9-
- Installation instructions
8+
For detailed release notes and binary downloads, see [GitHub Releases](https://github.com/wasabeef/git-workers/releases).
109

11-
The release notes are automatically generated using conventional commits, categorizing changes into:
10+
## [Unreleased]
1211

13-
- Features
14-
- Bug Fixes
15-
- Documentation
16-
- Performance improvements
17-
- And more
12+
### Changed
13+
14+
- **BREAKING**: Removed command-line argument options (--list, --create, etc.) in favor of interactive menu-only interface
15+
- Simplified main.rs to focus solely on interactive menu operations
16+
- Improved worktree rename functionality with `git worktree repair` integration
17+
- Enhanced configuration lookup strategy:
18+
- Now checks current directory first (useful for bare repo worktrees)
19+
- Then checks parent directory's main/master worktree
20+
- Finally falls back to repository root
21+
- Improved path handling for worktree creation:
22+
- Paths are now canonicalized to eliminate "../" in display
23+
- "In subdirectory" option now correctly creates worktrees in subdirectories
24+
25+
### Added
26+
27+
- Edit hooks menu option (`λ`) for managing lifecycle hooks through the interface
28+
- Comprehensive Rustdoc documentation for all modules and functions
29+
- Current directory configuration lookup priority for .git-workers.toml
30+
- Parent directory configuration lookup for .git-workers.toml
31+
- Better error handling with mutex poison recovery in tests
32+
- Branch deletion functionality in batch delete operations
33+
- Orphaned branch detection when deleting worktrees
34+
- Repository URL validation in configuration files
35+
- New test files for batch delete and edit hooks functionality
36+
37+
### Fixed
38+
39+
- All clippy warnings resolved:
40+
- manual_div_ceil replaced with div_ceil() method
41+
- manual_unwrap_or patterns simplified
42+
- needless_borrows in format! macros removed
43+
- useless_vec replaced with arrays
44+
- manual_flatten replaced with .flatten() method
45+
- Test failures related to parent directory configuration search
46+
- ESC cancellation pattern tests updated for new code style
47+
- Worktree rename test expectations aligned with Git limitations
48+
- "In subdirectory" option now correctly creates worktrees in worktrees/ folder
49+
- Path display now shows clean canonical paths without "../"
50+
- Batch delete now properly deletes orphaned branches
51+
- Edit hooks no longer incorrectly identifies regular repos as bare
52+
53+
### Documentation
54+
55+
- Updated README.md with current features and usage:
56+
- Added configuration file lookup priority documentation
57+
- Updated worktree pattern examples
58+
- Added custom path creation examples
59+
- Added repository URL configuration example
60+
- Clarified batch delete branch deletion functionality
61+
- Enhanced CLAUDE.md with architectural details and development commands
62+
- Added detailed inline documentation for all public APIs
63+
- Updated all Rustdoc comments to reflect recent changes
64+
65+
## [0.1.0] - 2024-12-17
66+
67+
### Added
68+
69+
- Initial release of Git Workers
70+
- Interactive menu-driven interface for Git worktree management
71+
- List worktrees with detailed status information (branch, changes, ahead/behind)
72+
- Fuzzy search through worktrees with real-time filtering
73+
- Create new worktrees from branches or HEAD
74+
- Delete single or multiple worktrees with safety checks
75+
- Switch worktrees with automatic directory change via shell integration
76+
- Rename worktrees and optionally their branches
77+
- Cleanup old worktrees by age
78+
- Hook system for lifecycle events (post-create, pre-remove, post-switch)
79+
- Shell integration for Bash and Zsh
80+
- Configuration file support (.git-workers.toml)
81+
- Template variable support in hooks ({{worktree_name}}, {{worktree_path}})
82+
- Worktree pattern detection for organized directory structure
83+
- ESC key support for cancelling operations
84+
- Colored terminal output with theme support
85+
- Progress indicators for long operations
86+
- Homebrew installation support

CLAUDE.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
Git Workers is an interactive CLI tool for managing Git worktrees, written in Rust. It provides a menu-driven interface for creating, deleting, switching, and renaming worktrees, with shell integration for automatic directory switching.
7+
Git Workers is an interactive CLI tool for managing Git worktrees, written in Rust. It provides a menu-driven interface for creating, deleting, switching, and renaming worktrees, with shell integration for automatic directory switching. The tool focuses on simplicity and user experience, offering only interactive menu-based operations without command-line arguments (except for --version and --help).
88

99
## Development Commands
1010

@@ -100,6 +100,10 @@ Automatic directory switching on worktree change requires special implementation
100100
Define lifecycle hooks in `.git-workers.toml`:
101101

102102
```toml
103+
[repository]
104+
# Optional: Repository URL validation
105+
url = "https://github.com/owner/repo.git"
106+
103107
[hooks]
104108
post-create = ["npm install", "cp .env.example .env"]
105109
pre-remove = ["rm -rf node_modules"]
@@ -111,15 +115,32 @@ Template variables:
111115
- `{{worktree_name}}`: The worktree name
112116
- `{{worktree_path}}`: Absolute path to worktree
113117

118+
### Configuration File Loading
119+
120+
Configuration is loaded in priority order:
121+
122+
1. Current directory (useful for bare repo worktrees)
123+
2. Parent directory's main/master worktree
124+
3. Repository root
125+
126+
This flexible strategy ensures hooks work in both regular and bare repositories.
127+
114128
### Worktree Patterns
115129

116130
First worktree creation offers two options:
117131

118132
1. Same level as repository: `../worktree-name`
119-
2. In subdirectory (recommended): `../repo/worktrees/worktree-name`
133+
2. In subdirectory (recommended): `repo/worktrees/worktree-name`
120134

121135
Subsequent worktrees follow the established pattern automatically.
122136

137+
### Path Handling
138+
139+
- Paths starting with `../` create worktrees at repository parent level
140+
- Paths containing `/` (e.g., `worktrees/feature`) create within repository
141+
- Simple names use pattern detection from existing worktrees
142+
- All paths are canonicalized to eliminate `../` in display
143+
123144
### ESC Key Handling
124145

125146
All interactive prompts support ESC cancellation through custom `input_esc_raw` module:
@@ -135,7 +156,18 @@ Since Git lacks native rename functionality:
135156
1. Move directory with `fs::rename`
136157
2. Update `.git/worktrees/<name>` metadata directory
137158
3. Update gitdir files in both directions
138-
4. Optionally rename associated branch if it matches worktree name
159+
4. Run `git worktree repair` to update Git's tracking
160+
5. Optionally rename associated branch if it matches worktree name
161+
162+
Note: Due to Git limitations, the worktree will still be tracked with its original name internally, but the directory will be renamed.
163+
164+
### Batch Delete Features
165+
166+
- Multi-select interface for choosing multiple worktrees
167+
- Automatic detection of orphaned branches (using `is_branch_unique_to_worktree`)
168+
- Separate confirmations for worktree and branch deletion
169+
- Executes pre-remove hooks for each worktree
170+
- Reports success/failure counts separately for worktrees and branches
139171

140172
### CI/CD Configuration
141173

0 commit comments

Comments
 (0)