git-worktree-pool 0.0.0-stage → 0.1.2
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.
- package/LICENSE +21 -0
- package/README.md +94 -2
- package/launchers/wtp +6 -0
- package/launchers/wtp.cmd +28 -0
- package/launchers/wtp.ps1 +26 -0
- package/package.json +70 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yoav Vainrich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# git-worktree-pool
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Work on several branches at once, without a fresh `npm install` for each one.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
`git worktree add` gives you a second checkout of a branch in seconds. In a large monorepo, though, the checkout is not where the time goes. A new worktree has no `node_modules`, so you run `npm install` there, and that can take a long time.
|
|
8
|
+
|
|
9
|
+
It is worst on Windows. Antivirus and other IT security tools there often check each file as it is written and hold the write until the check ends, so writing the many files of `node_modules` is slow. On macOS, some of these tools check files after they are written, so the same install finishes sooner.
|
|
10
|
+
|
|
11
|
+
`wtp` keeps a pool of worktrees next to your clone and reuses them, so you pay for that install once per slot, not once per branch. When you finish a branch, wtp frees its slot: it discards the branch's changes but keeps the ignored files, such as `node_modules` and build output. The next branch gets that slot with its dependencies already in place, and a later `npm install` there only has to apply the difference. wtp also moves your shell into the slot, so you can start work at once.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g git-worktree-pool
|
|
17
|
+
worktree-pool setup
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Requirements: Node 22.12 or later, git 2.31 or later.
|
|
21
|
+
|
|
22
|
+
`worktree-pool setup` gives you the `wtp` command, which moves the shell you type it in. Setup asks before each change. `worktree-pool setup --remove` undoes them.
|
|
23
|
+
|
|
24
|
+
* **cmd and PowerShell:** `wtp` works right after setup. Windows PowerShell 5.1 also needs scripts allowed: `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`.
|
|
25
|
+
* **bash, zsh, fish, Git Bash:** setup adds a `wtp` function to your shell profile. Open a new shell to use it.
|
|
26
|
+
|
|
27
|
+
Without setup, wtp still copies the slot path to the clipboard, and you paste it.
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
cd my-repo
|
|
33
|
+
wtp assign my-feature # gives the branch a slot and moves you there
|
|
34
|
+
wtp switch 0 # back to your clone
|
|
35
|
+
wtp free 1 # done with slot 1: it is free for the next branch
|
|
36
|
+
wtp # or do all of this from the TUI
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The pool sits next to your clone:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
my-repo/ slot 0, your clone
|
|
43
|
+
my-repo-wt-pool/
|
|
44
|
+
my-repo-wt-1/ slot 1
|
|
45
|
+
my-repo-wt-2/ slot 2
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
wtp works from the clone, from the pool folder, and from any slot.
|
|
49
|
+
|
|
50
|
+
## Commands
|
|
51
|
+
|
|
52
|
+
| Command | What it does |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `wtp` | Opens the TUI. |
|
|
55
|
+
| `wtp list`, `wtp ls` | Prints the slot table. `--json` prints the data. `--no-changes` skips the change counts. |
|
|
56
|
+
| `wtp assign <branch>` | Gives the branch a slot, copies the path, and moves the shell there. `--no-cd` only copies. When the branch is already in a slot, wtp offers to switch there. |
|
|
57
|
+
| `wtp switch <index\|branch>` | Copies the slot path and moves the shell there. A branch name must match exactly. It also reaches a worktree outside the pool. |
|
|
58
|
+
| `wtp free <index>` | Asks, then discards uncommitted changes, releases the branch, and marks the slot free. `--yes` skips the question. `--force` frees a locked slot. |
|
|
59
|
+
| `wtp delete <index>` | Asks, then discards uncommitted changes and removes the slot folder. `--yes` skips the question. `--branch` also deletes the local branch. `--force` allows unmerged branches and locked slots. |
|
|
60
|
+
| `wtp path <index\|branch>` | Prints the slot path. |
|
|
61
|
+
| `wtp doctor` | Reports pool problems and repairs the safe ones. |
|
|
62
|
+
|
|
63
|
+
`assign` takes the lowest free slot, or makes a new one. For the branch, it uses the local branch, else the branch on `origin`, else a new branch from your local `main`. wtp does not fetch `main` first.
|
|
64
|
+
|
|
65
|
+
## TUI keys
|
|
66
|
+
|
|
67
|
+
| Key | Action |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `↑` `↓`, `k` `j` | Move the selection |
|
|
70
|
+
| `0`-`9` | Jump to a slot index |
|
|
71
|
+
| `Enter` | Move the shell to the slot and exit |
|
|
72
|
+
| `a` | Assign a branch. The suggestions leave out branches that a worktree already has. The TUI stays open with the new slot selected; Enter goes there. |
|
|
73
|
+
| `f` | Free the slot |
|
|
74
|
+
| `d` | Delete the slot |
|
|
75
|
+
| `c` | Copy the path |
|
|
76
|
+
| `/` | Filter by branch |
|
|
77
|
+
| `?` | Help |
|
|
78
|
+
| `q`, `Esc` | Quit. If you freed or deleted the slot you are in, quit moves you to the clone. |
|
|
79
|
+
|
|
80
|
+
## Settings
|
|
81
|
+
|
|
82
|
+
Per-repo settings live in git config:
|
|
83
|
+
|
|
84
|
+
| Key | Default | Meaning |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `wtp.base` | `main` | The branch that new branches start from |
|
|
87
|
+
| `wtp.remote` | `origin` | The remote that assign looks at |
|
|
88
|
+
|
|
89
|
+
For example: `git config wtp.base develop`.
|
|
90
|
+
|
|
91
|
+
## Notes
|
|
92
|
+
|
|
93
|
+
* Slot 0 is your clone. wtp never frees or deletes it.
|
|
94
|
+
* Free and delete always say what they discard before they ask.
|
|
95
|
+
* On Windows, wtp can't delete the slot your shell is in. Run `wtp switch 0` first.
|
package/launchers/wtp
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# wtp-launcher 2
|
|
3
|
+
# Written by "worktree-pool setup". It runs worktree-pool. A script cannot change its caller's
|
|
4
|
+
# folder; the wtp function in your shell profile does that. WTP_VIA tells worktree-pool which hint to show.
|
|
5
|
+
command -v worktree-pool >/dev/null 2>&1 || { echo "wtp: worktree-pool is not installed. Reinstall git-worktree-pool, or delete $0." >&2; exit 127; }
|
|
6
|
+
WTP_VIA=sh exec worktree-pool "$@"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
rem wtp-launcher 2
|
|
3
|
+
rem Written by "worktree-pool setup". It runs worktree-pool, then moves this cmd session to
|
|
4
|
+
rem the folder that worktree-pool picked. "worktree-pool setup --remove" deletes this file.
|
|
5
|
+
setlocal
|
|
6
|
+
where /q worktree-pool || goto :missing
|
|
7
|
+
if defined WTP_CWD_FILE (
|
|
8
|
+
call worktree-pool %*
|
|
9
|
+
exit /b
|
|
10
|
+
)
|
|
11
|
+
set "WTP_CWD_FILE=%TEMP%\wtp-cwd-%RANDOM%%RANDOM%.txt"
|
|
12
|
+
call worktree-pool %*
|
|
13
|
+
set "WTP_RC=%ERRORLEVEL%"
|
|
14
|
+
set "WTP_DIR="
|
|
15
|
+
if not exist "%WTP_CWD_FILE%" (endlocal & exit /b %WTP_RC%)
|
|
16
|
+
rem worktree-pool writes UTF-8. Read it under code page 65001, then restore the user's code page.
|
|
17
|
+
rem These lines must stay outside a ( ) block: inside one, a non-ASCII path fails.
|
|
18
|
+
for /f "tokens=2 delims=:." %%c in ('chcp') do set /a "WTP_CP=%%c"
|
|
19
|
+
chcp 65001 >nul
|
|
20
|
+
set /p WTP_DIR=<"%WTP_CWD_FILE%"
|
|
21
|
+
chcp %WTP_CP% >nul
|
|
22
|
+
del "%WTP_CWD_FILE%" >nul 2>&1
|
|
23
|
+
if not defined WTP_DIR (endlocal & exit /b %WTP_RC%)
|
|
24
|
+
endlocal & cd /d "%WTP_DIR%" & exit /b %WTP_RC%
|
|
25
|
+
|
|
26
|
+
:missing
|
|
27
|
+
>&2 echo wtp: worktree-pool is not installed. Reinstall git-worktree-pool, or delete "%~f0".
|
|
28
|
+
exit /b 9009
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# wtp-launcher 2
|
|
2
|
+
# Written by "worktree-pool setup". It runs worktree-pool, then moves this PowerShell session
|
|
3
|
+
# to the folder that worktree-pool picked. "worktree-pool setup --remove" deletes this file.
|
|
4
|
+
if (-not (Get-Command worktree-pool -CommandType Application, ExternalScript -ErrorAction SilentlyContinue)) {
|
|
5
|
+
[Console]::Error.WriteLine("wtp: worktree-pool is not installed. Reinstall git-worktree-pool, or delete $PSCommandPath.")
|
|
6
|
+
exit 1
|
|
7
|
+
}
|
|
8
|
+
if ($env:WTP_CWD_FILE) {
|
|
9
|
+
& worktree-pool @args
|
|
10
|
+
exit $LASTEXITCODE
|
|
11
|
+
}
|
|
12
|
+
# .NET, not New-TemporaryFile: a Windows PowerShell 5.1 started from pwsh inherits pwsh's
|
|
13
|
+
# PSModulePath and then cannot load New-TemporaryFile.
|
|
14
|
+
$f = [IO.Path]::GetTempFileName()
|
|
15
|
+
$env:WTP_CWD_FILE = $f
|
|
16
|
+
$rc = 0
|
|
17
|
+
try {
|
|
18
|
+
& worktree-pool @args
|
|
19
|
+
$rc = $LASTEXITCODE
|
|
20
|
+
} finally {
|
|
21
|
+
Remove-Item Env:WTP_CWD_FILE -ErrorAction SilentlyContinue
|
|
22
|
+
}
|
|
23
|
+
$dir = Get-Content -LiteralPath $f -Raw -Encoding UTF8 -ErrorAction SilentlyContinue
|
|
24
|
+
Remove-Item -LiteralPath $f -ErrorAction SilentlyContinue
|
|
25
|
+
if ($dir) { Set-Location -LiteralPath $dir.Trim() }
|
|
26
|
+
exit $rc
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-worktree-pool",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Manage a pool of reusable git worktrees from the command line or a TUI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"worktree-pool": "dist/bin/wtp.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.build.json",
|
|
11
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
14
|
+
"eslint": "eslint --cache --cache-location ./.eslint-cache/ --cache-strategy content src/ tests/ tests-e2e/ eslint.config.mjs vitest.config.ts vitest.e2e.config.ts",
|
|
15
|
+
"eslint:fix": "npm run eslint -- --fix"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/yoavain/git-worktree-pool.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"git",
|
|
23
|
+
"worktree",
|
|
24
|
+
"git-worktree",
|
|
25
|
+
"worktrees",
|
|
26
|
+
"pool",
|
|
27
|
+
"cli",
|
|
28
|
+
"tui",
|
|
29
|
+
"ink",
|
|
30
|
+
"developer-tools",
|
|
31
|
+
"productivity"
|
|
32
|
+
],
|
|
33
|
+
"author": "yoavain",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22.12",
|
|
37
|
+
"npm": ">=10"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"launchers"
|
|
42
|
+
],
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/yoavain/git-worktree-pool/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/yoavain/git-worktree-pool#readme",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@eslint/js": "10.0.1",
|
|
49
|
+
"@types/node": "24.6.0",
|
|
50
|
+
"@types/react": "19.3.0",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "8.71.0",
|
|
52
|
+
"@typescript-eslint/parser": "8.71.0",
|
|
53
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
54
|
+
"eslint": "10.11.0",
|
|
55
|
+
"eslint-import-resolver-typescript": "4.4.5",
|
|
56
|
+
"eslint-plugin-import-x": "4.17.1",
|
|
57
|
+
"eslint-plugin-n": "18.4.0",
|
|
58
|
+
"eslint-plugin-security": "4.2.0",
|
|
59
|
+
"globals": "17.13.0",
|
|
60
|
+
"ink-testing-library": "4.0.0",
|
|
61
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
62
|
+
"vite": "8.3.2",
|
|
63
|
+
"vitest": "5.0.3"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"ink": "7.1.1",
|
|
67
|
+
"react": "19.3.0"
|
|
68
|
+
},
|
|
69
|
+
"overrides": {
|
|
70
|
+
"rolldown": "1.2.12"
|
|
71
|
+
}
|
|
72
|
+
}
|