Skip to content

Commit acba1b5

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

27 files changed

Lines changed: 2956 additions & 1177 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 'Switched to: {{worktree_name}}'"
23+
]

CHANGELOG.md

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,64 @@
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 to search parent directories
18+
19+
### Added
20+
21+
- Edit hooks menu option (`λ`) for managing lifecycle hooks through the interface
22+
- Comprehensive Rustdoc documentation for all modules and functions
23+
- Parent directory configuration lookup for .git-workers.toml
24+
- Better error handling with mutex poison recovery in tests
25+
26+
### Fixed
27+
28+
- All clippy warnings resolved:
29+
- manual_div_ceil replaced with div_ceil() method
30+
- manual_unwrap_or patterns simplified
31+
- needless_borrows in format! macros removed
32+
- useless_vec replaced with arrays
33+
- Test failures related to parent directory configuration search
34+
- ESC cancellation pattern tests updated for new code style
35+
- Worktree rename test expectations aligned with Git limitations
36+
37+
### Documentation
38+
39+
- Updated README.md with current features and usage
40+
- Enhanced CLAUDE.md with architectural details
41+
- Added detailed inline documentation for all public APIs
42+
43+
## [0.1.0] - 2024-12-17
44+
45+
### Added
46+
47+
- Initial release of Git Workers
48+
- Interactive menu-driven interface for Git worktree management
49+
- List worktrees with detailed status information (branch, changes, ahead/behind)
50+
- Fuzzy search through worktrees with real-time filtering
51+
- Create new worktrees from branches or HEAD
52+
- Delete single or multiple worktrees with safety checks
53+
- Switch worktrees with automatic directory change via shell integration
54+
- Rename worktrees and optionally their branches
55+
- Cleanup old worktrees by age
56+
- Hook system for lifecycle events (post-create, pre-remove, post-switch)
57+
- Shell integration for Bash and Zsh
58+
- Configuration file support (.git-workers.toml)
59+
- Template variable support in hooks ({{worktree_name}}, {{worktree_path}})
60+
- Worktree pattern detection for organized directory structure
61+
- ESC key support for cancelling operations
62+
- Colored terminal output with theme support
63+
- Progress indicators for long operations
64+
- Homebrew installation support

CLAUDE.md

Lines changed: 5 additions & 2 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

@@ -135,7 +135,10 @@ Since Git lacks native rename functionality:
135135
1. Move directory with `fs::rename`
136136
2. Update `.git/worktrees/<name>` metadata directory
137137
3. Update gitdir files in both directions
138-
4. Optionally rename associated branch if it matches worktree name
138+
4. Run `git worktree repair` to update Git's tracking
139+
5. Optionally rename associated branch if it matches worktree name
140+
141+
Note: Due to Git limitations, the worktree will still be tracked with its original name internally, but the directory will be renamed.
139142

140143
### CI/CD Configuration
141144

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ chrono = "0.4"
3737
fuzzy-matcher = "0.3"
3838
indicatif = "0.17"
3939
rustyline = "14.0"
40+
unicode-width = "0.2.1"
4041

4142
[dev-dependencies]
4243
tempfile = "3.8"

README.md

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ https://github.com/user-attachments/assets/bb58444f-4936-411c-be51-62faf08fe9a0
99

1010
## Features
1111

12-
- 📋 List worktrees with status information
12+
- 📋 List worktrees with detailed status information (branch, changes, ahead/behind)
1313
- 🔍 Fuzzy search through worktrees
1414
- ➕ Create new worktrees from branches or HEAD
1515
- ➖ Delete single or multiple worktrees
1616
- 🔄 Switch worktrees with automatic directory change
1717
- ✏️ Rename worktrees and optionally their branches
1818
- 🧹 Cleanup old worktrees by age
1919
- 🪝 Execute hooks on worktree lifecycle events
20+
- 📝 Edit and manage hooks through the interface
2021

2122
## Installation
2223

@@ -26,6 +27,14 @@ https://github.com/user-attachments/assets/bb58444f-4936-411c-be51-62faf08fe9a0
2627
brew install wasabeef/gw-tap/gw
2728
```
2829

30+
### From Source
31+
32+
```bash
33+
git clone https://github.com/wasabeef/git-workers.git
34+
cd git-workers
35+
cargo install --path .
36+
```
37+
2938
### Shell Integration
3039

3140
To enable automatic directory switching when switching worktrees, add this to your shell config:
@@ -35,6 +44,12 @@ To enable automatic directory switching when switching worktrees, add this to yo
3544
source $(brew --prefix)/share/gw/shell/gw.sh
3645
```
3746

47+
For manual installation, use the path where git-workers is installed:
48+
49+
```bash
50+
source /path/to/git-workers/shell/gw.sh
51+
```
52+
3853
## Usage
3954

4055
Run `gw` in any Git repository:
@@ -43,18 +58,73 @@ Run `gw` in any Git repository:
4358
gw
4459
```
4560

46-
### Menu Options
61+
### Interactive Menu
62+
63+
Git Workers provides an interactive menu-driven interface. Simply run `gw` and navigate through the options:
4764

48-
- **List worktrees** (``): Display all worktrees with status information
49-
- **Search worktrees** (`?`): Fuzzy search through worktrees
50-
- **Create worktree** (`+`): Create a new worktree
51-
- **Delete worktree** (`-`): Delete a single worktree
52-
- **Batch delete** (`=`): Delete multiple worktrees at once
65+
- **List worktrees** (``): Display all worktrees with branch, changes, and sync status
66+
- **Search worktrees** (`?`): Fuzzy search through worktree names and branches
67+
- **Create worktree** (`+`): Create a new worktree from existing branch or create a new branch
68+
- **Delete worktree** (`-`): Delete a single worktree with safety checks
69+
- **Batch delete** (`=`): Select and delete multiple worktrees at once
5370
- **Cleanup old worktrees** (`~`): Remove worktrees older than specified days
54-
- **Switch worktree** (``): Switch to another worktree (changes directory)
55-
- **Rename worktree** (`*`): Rename an existing worktree
71+
- **Switch worktree** (``): Switch to another worktree (automatically changes directory)
72+
- **Rename worktree** (`*`): Rename worktree directory and optionally its branch
73+
- **Edit hooks** (`λ`): Configure lifecycle hooks in `.git-workers.toml`
5674
- **Exit** (`x`): Exit the application
5775

76+
### Configuration
77+
78+
Git Workers uses `.git-workers.toml` for configuration. Place this file in your repository root:
79+
80+
```toml
81+
[hooks]
82+
# Execute after creating a new worktree
83+
post-create = [
84+
"npm install",
85+
"cp .env.example .env",
86+
"echo 'Worktree {{worktree_name}} created at {{worktree_path}}'"
87+
]
88+
89+
# Execute before removing a worktree
90+
pre-remove = [
91+
"echo 'Cleaning up {{worktree_name}}'",
92+
"rm -rf node_modules"
93+
]
94+
95+
# Execute after switching to a worktree
96+
post-switch = [
97+
"echo 'Switched to {{worktree_name}}'"
98+
]
99+
```
100+
101+
### Hook Variables
102+
103+
- `{{worktree_name}}`: The name of the worktree
104+
- `{{worktree_path}}`: The absolute path to the worktree
105+
106+
### Worktree Patterns
107+
108+
When creating your first worktree, Git Workers offers two patterns:
109+
110+
1. **Same level as repository**: Creates worktrees as siblings to your main repository
111+
112+
```
113+
parent/
114+
├── my-repo/
115+
├── my-repo-feature-1/
116+
└── my-repo-feature-2/
117+
```
118+
119+
2. **In subdirectory** (recommended): Organizes worktrees in a dedicated directory
120+
```
121+
parent/
122+
└── my-repo/
123+
└── worktrees/
124+
├── feature-1/
125+
└── feature-2/
126+
```
127+
58128
### Keyboard Shortcuts
59129

60130
- **ESC**: Cancel current operation and return to menu

0 commit comments

Comments
 (0)