easy-worktree 0.0.5__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ def get_default_branch(base_dir: Path) -> str:
2
+ """Detect default branch (main/master)"""
3
+ # 1. Try origin/HEAD
4
+ result = run_command(["git", "rev-parse", "--abbrev-ref", "origin/HEAD"], cwd=base_dir, check=False)
5
+ if result.returncode == 0:
6
+ return result.stdout.strip().replace("origin/", "")
7
+
8
+ # 2. Try common names
9
+ for b in ["main", "master"]:
10
+ if run_command(["git", "rev-parse", "--verify", b], cwd=base_dir, check=False).returncode == 0:
11
+ return b
12
+
13
+ # 3. Fallback to current HEAD
14
+ result = run_command(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=base_dir, check=False)
15
+ if result.returncode == 0:
16
+ return result.stdout.strip()
17
+
18
+ return None
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: easy-worktree
3
+ Version: 0.1.0
4
+ Summary: Git worktree を簡単に管理するための CLI ツール
5
+ Project-URL: Homepage, https://github.com/igtm/easy-worktree
6
+ Project-URL: Repository, https://github.com/igtm/easy-worktree
7
+ Project-URL: Issues, https://github.com/igtm/easy-worktree/issues
8
+ Author: igtm
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,git,tool,worktree
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Version Control :: Git
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: toml
21
+ Description-Content-Type: text/markdown
22
+
23
+ ![hero](hero.png)
24
+
25
+ # easy-worktree
26
+
27
+ A CLI tool for easy Git worktree management.
28
+
29
+ [日本語版 README](README_ja.md)
30
+
31
+ ## Overview
32
+
33
+ `easy-worktree` simplifies git worktree management.
34
+ It keeps the root of your git repository as your primary working area (main), while managing other worktrees in a subdirectory (default: `.worktrees/`).
35
+
36
+ ### Key Features
37
+
38
+ - **Standardized directory structure**: Worktrees are created in a `.worktrees/` subdirectory (configurable). Keeps your root directory clean.
39
+ - **Auto Sync**: Automatically sync files ignored by git (like `.env`) from the root to each worktree.
40
+ - **Clear Status**: `wt list` shows worktree branches, their status (clean/dirty), and associated GitHub PRs in a beautiful table.
41
+ - **Smart Cleanup**: Easily batch remove merged branches or old unused worktrees.
42
+ - **Two-letter shortcuts**: Fast execution with shortcuts like `ad`, `ls`, `st`, `sy`, `cl`.
43
+
44
+ ## Prerequisites
45
+
46
+ `easy-worktree` requires the following:
47
+
48
+ - **Git**: 2.34 or higher recommended.
49
+ - **GitHub CLI (gh)**: Required for PR features (`wt list --pr`, `wt pr add`, `wt clean --merged`). [Installation guide](https://cli.github.com/).
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install easy-worktree
55
+ ```
56
+
57
+ Or install the development version:
58
+
59
+ ```bash
60
+ git clone https://github.com/igtm/easy-worktree.git
61
+ cd easy-worktree
62
+ pip install -e .
63
+ ```
64
+
65
+ ## Usage
66
+
67
+ ### Getting Started
68
+
69
+ #### Clone a new repository
70
+
71
+ ```bash
72
+ wt clone https://github.com/user/repo.git
73
+ ```
74
+
75
+ This clones the repository and initializes `easy-worktree` configuration.
76
+
77
+ #### Initialize an existing repository
78
+
79
+ ```bash
80
+ cd my-repo/
81
+ wt init
82
+ ```
83
+
84
+ Initializes `easy-worktree` in the current repository. Your main repository stays at the project root.
85
+
86
+ ### Managing Worktrees
87
+
88
+ #### Add a worktree (shortcut: `ad`)
89
+
90
+ ```bash
91
+ wt add feature-1
92
+ ```
93
+
94
+ This creates the following structure:
95
+
96
+ ```
97
+ my-repo/ (main)
98
+ .worktrees/
99
+ feature-1/ # Your new worktree
100
+ .wt/
101
+ ...
102
+ ```
103
+
104
+ You can also specify a base branch:
105
+
106
+ ```bash
107
+ wt add feature-1 main
108
+ ```
109
+
110
+ #### List worktrees
111
+
112
+ ```bash
113
+ wt list
114
+ wt list --pr # Show PR information
115
+ ```
116
+
117
+
118
+ #### Stash and Move (shortcut: `st`)
119
+
120
+ Quickly stash your current changes and move them to a new worktree.
121
+
122
+ ```bash
123
+ wt stash feature-2
124
+ ```
125
+
126
+ #### PR Management
127
+
128
+ Fetch a PR and create a worktree for it. (Requires `gh` CLI)
129
+
130
+ ```bash
131
+ wt pr add 123 # Fetches PR #123 and creates 'pr@123' worktree
132
+ ```
133
+
134
+ #### Remove a worktree
135
+
136
+ ```bash
137
+ wt rm feature-1
138
+ ```
139
+
140
+ Removes the worktree and its directory.
141
+
142
+ ### Useful Features
143
+
144
+ #### Sync configuration files (shortcut: `sy`)
145
+
146
+ Sync files like `.env` that are not in git from the root to your worktrees.
147
+
148
+ ```bash
149
+ wt sync .env
150
+ ```
151
+
152
+
153
+ #### Cleanup (shortcut: `cl`)
154
+
155
+ ```bash
156
+ wt clean --merged
157
+ wt clean --closed # Remove worktrees for closed (unmerged) PRs
158
+ wt clean --days 30
159
+ ```
160
+
161
+
162
+
163
+ ### Configuration
164
+
165
+ Customize behavior in `.wt/config.toml`:
166
+
167
+ ```toml
168
+ worktrees_dir = ".worktrees" # Directory where worktrees are created
169
+ sync_files = [".env"] # Files to auto-sync
170
+ auto_copy_on_add = true # Enable auto-sync on add
171
+ ```
172
+
173
+ ## Hooks
174
+
175
+ You can define scripts to run automatically after `wt add`.
176
+ Templates are created in `.wt/post-add` upon initialization.
177
+
178
+ ## License
179
+
180
+ MIT License
@@ -0,0 +1,7 @@
1
+ easy_worktree/__init__.py,sha256=ngkcFWlpshtSnRH1GWAThgAclSa2VKk88hOBe2xRd9k,54851
2
+ easy_worktree/__init__.py_snippet_helper,sha256=6-PBMv5BXr02rpe1-4-jN7t0GQMkOBAhL8H4og3R5hA,729
3
+ easy_worktree-0.1.0.dist-info/METADATA,sha256=e8FeCMY-c0rXNb635ftsszgqguwVA7Qx2KTjAkT9fnk,4047
4
+ easy_worktree-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
+ easy_worktree-0.1.0.dist-info/entry_points.txt,sha256=Mf6MYDS2obZLvIJJFl-BbU8-SL0QGu5UWcC0FWnqtbg,42
6
+ easy_worktree-0.1.0.dist-info/licenses/LICENSE,sha256=7MGvWFDxXPqW2nrr9D7KHT0vWFiGwIUL5SQCj0IiAPc,1061
7
+ easy_worktree-0.1.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,237 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: easy-worktree
3
- Version: 0.0.5
4
- Summary: Git worktree を簡単に管理するための CLI ツール
5
- Project-URL: Homepage, https://github.com/igtm/easy-worktree
6
- Project-URL: Repository, https://github.com/igtm/easy-worktree
7
- Project-URL: Issues, https://github.com/igtm/easy-worktree/issues
8
- Author: igtm
9
- License: MIT
10
- License-File: LICENSE
11
- Keywords: cli,git,tool,worktree
12
- Classifier: Development Status :: 3 - Alpha
13
- Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Software Development :: Version Control :: Git
19
- Requires-Python: >=3.11
20
- Description-Content-Type: text/markdown
21
-
22
- # easy-worktree
23
-
24
- A CLI tool for easy Git worktree management
25
-
26
- [日本語版 README](README_ja.md)
27
-
28
- ## Overview
29
-
30
- `easy-worktree` simplifies git worktree management by establishing conventions, reducing the cognitive load of managing multiple working trees.
31
-
32
- ### Key Features
33
-
34
- - **Standardized directory structure**: Creates a `_base/` directory within `WT_<repository_name>/` as the main repository
35
- - **Easy worktree management**: Create and remove worktrees from `_base/`
36
- - **Automatic branch updates**: Runs `git fetch --all` automatically when creating worktrees
37
-
38
- ## Installation
39
-
40
- ```bash
41
- pip install easy-worktree
42
- ```
43
-
44
- Or install the development version:
45
-
46
- ```bash
47
- git clone https://github.com/igtm/easy-worktree.git
48
- cd easy-worktree
49
- pip install -e .
50
- ```
51
-
52
- ## Usage
53
-
54
- ### Clone a new repository
55
-
56
- ```bash
57
- wt clone https://github.com/user/repo.git
58
- ```
59
-
60
- This creates the following structure:
61
-
62
- ```
63
- WT_repo/
64
- _base/ # Main repository (typically don't modify directly)
65
- ```
66
-
67
- ### Convert an existing repository to easy-worktree structure
68
-
69
- ```bash
70
- cd my-repo/
71
- wt init
72
- ```
73
-
74
- The current directory will be moved to `../WT_my-repo/_base/`.
75
-
76
- ### Add a worktree
77
-
78
- ```bash
79
- cd WT_repo/
80
- wt add feature-1
81
- ```
82
-
83
- This creates the following structure:
84
-
85
- ```
86
- WT_repo/
87
- _base/
88
- feature-1/ # Working worktree
89
- ```
90
-
91
- You can also specify a branch name:
92
-
93
- ```bash
94
- wt add feature-1 main
95
- ```
96
-
97
- Create a worktree and set an alias at the same time:
98
-
99
- ```bash
100
- wt add feature-123 --alias current # Create feature-123 and set 'current' alias
101
- ```
102
-
103
- ### List worktrees
104
-
105
- ```bash
106
- wt list
107
- ```
108
-
109
- ### Remove a worktree
110
-
111
- ```bash
112
- wt rm feature-1
113
- # or
114
- wt remove feature-1
115
- ```
116
-
117
- ### Initialization hook (post-add)
118
-
119
- You can set up a script to run automatically after creating a worktree.
120
-
121
- **Hook location**: `_base/.wt/post-add`
122
-
123
- **Automatic creation**: When you run `wt clone` or `wt init`, a template file is automatically created at `_base/.wt/post-add` (won't overwrite if it already exists). Edit this file to describe your project-specific initialization process.
124
-
125
- ```bash
126
- # Example: editing the hook script
127
- vim WT_repo/_base/.wt/post-add
128
- ```
129
-
130
- ```bash
131
- #!/bin/bash
132
- set -e
133
-
134
- echo "Initializing worktree: $WT_WORKTREE_NAME"
135
-
136
- # Install npm packages
137
- if [ -f package.json ]; then
138
- npm install
139
- fi
140
-
141
- # Copy .env file
142
- if [ -f "$WT_BASE_DIR/.env.example" ]; then
143
- cp "$WT_BASE_DIR/.env.example" .env
144
- fi
145
-
146
- echo "Setup completed!"
147
- ```
148
-
149
- Don't forget to make it executable:
150
-
151
- ```bash
152
- chmod +x WT_repo/_base/.wt/post-add
153
- ```
154
-
155
- **Available environment variables**:
156
- - `WT_WORKTREE_PATH`: Path to the created worktree
157
- - `WT_WORKTREE_NAME`: Name of the worktree
158
- - `WT_BASE_DIR`: Path to the `_base/` directory
159
- - `WT_BRANCH`: Branch name
160
- - `WT_ACTION`: Action name (`add`)
161
-
162
- The hook runs within the newly created worktree directory.
163
-
164
- ### List worktrees with details
165
-
166
- ```bash
167
- wt list --verbose # Show creation time, last commit, status
168
- wt list --sort age # Sort by creation time
169
- wt list --sort name # Sort by name
170
- ```
171
-
172
- ### Clean up unused worktrees
173
-
174
- Remove clean (no changes) worktrees in batch.
175
-
176
- ```bash
177
- wt clean --dry-run # Preview what will be removed
178
- wt clean --days 30 # Remove clean worktrees older than 30 days
179
- wt clean --all # Remove all clean worktrees without confirmation
180
- ```
181
-
182
- ### Create worktree aliases
183
-
184
- Create symbolic link shortcuts to frequently used worktrees.
185
-
186
- ```bash
187
- wt alias current feature-123 # Create alias named 'current'
188
- wt alias dev feature-xyz # Create alias named 'dev'
189
- wt alias current hoge3 # Automatically override existing alias
190
- wt alias --list # List all aliases
191
- wt alias --remove current # Remove an alias
192
- ```
193
-
194
- ### Check status of all worktrees
195
-
196
- View git status of all worktrees at once.
197
-
198
- ```bash
199
- wt status # Show status of all worktrees
200
- wt status --dirty # Show only worktrees with changes
201
- wt status --short # Concise display
202
- ```
203
-
204
- ### Other git worktree commands
205
-
206
- `wt` also supports other git worktree commands:
207
-
208
- ```bash
209
- wt prune
210
- wt lock <worktree>
211
- wt unlock <worktree>
212
- ```
213
-
214
- ## Directory Structure
215
-
216
- ```
217
- WT_<repository_name>/ # Project root directory
218
- _base/ # Main git repository
219
- feature-1/ # Worktree 1
220
- bugfix-123/ # Worktree 2
221
- ...
222
- ```
223
-
224
- You can run `wt` commands from `WT_<repository_name>/` or from within any worktree directory.
225
-
226
- ## Requirements
227
-
228
- - Python >= 3.11
229
- - Git
230
-
231
- ## License
232
-
233
- MIT License
234
-
235
- ## Contributing
236
-
237
- Issues and Pull Requests are welcome!
@@ -1,6 +0,0 @@
1
- easy_worktree/__init__.py,sha256=4ONRa_gYluNJFBvxWG8Z_J8J4JJJ9hlpPuizZBX7N3g,34039
2
- easy_worktree-0.0.5.dist-info/METADATA,sha256=Dj4_bAcY4oeuj_ywX-4lDQa-JBYJM7f-CVwElKZbkD4,5339
3
- easy_worktree-0.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
- easy_worktree-0.0.5.dist-info/entry_points.txt,sha256=Mf6MYDS2obZLvIJJFl-BbU8-SL0QGu5UWcC0FWnqtbg,42
5
- easy_worktree-0.0.5.dist-info/licenses/LICENSE,sha256=7MGvWFDxXPqW2nrr9D7KHT0vWFiGwIUL5SQCj0IiAPc,1061
6
- easy_worktree-0.0.5.dist-info/RECORD,,