git-worktrees 0.6.0__tar.gz → 0.6.2__tar.gz

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.
Files changed (105) hide show
  1. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.github/workflows/publish.yml +18 -3
  2. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.releasetools.yaml +3 -1
  3. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/AGENTS.md +15 -4
  4. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/CHANGELOG.md +29 -0
  5. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/PKG-INFO +50 -7
  6. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/README.md +49 -6
  7. git_worktrees-0.6.2/conf.d/worktrees.fish +7 -0
  8. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/docs/DEVELOPMENT.md +11 -2
  9. git_worktrees-0.6.2/functions/gwp!.fish +4 -0
  10. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/hatch_build.py +2 -2
  11. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/pyproject.toml +1 -1
  12. git_worktrees-0.6.2/scripts/bump_version.py +77 -0
  13. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/cli.py +59 -1
  14. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_shims.py +75 -7
  15. git_worktrees-0.6.2/tests/test_version.py +233 -0
  16. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/uv.lock +1 -1
  17. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwp +1 -1
  18. git_worktrees-0.6.2/zsh/plugins/worktrees/functions/gwp! +2 -0
  19. git_worktrees-0.6.2/zsh/plugins/worktrees/worktrees.plugin.zsh +21 -0
  20. git_worktrees-0.6.0/conf.d/worktrees.fish +0 -3
  21. git_worktrees-0.6.0/tests/test_version.py +0 -87
  22. git_worktrees-0.6.0/zsh/plugins/worktrees/worktrees.plugin.zsh +0 -15
  23. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.claude/settings.json +0 -0
  24. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.github/workflows/codeql.yml +0 -0
  25. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.github/workflows/testpypi.yml +0 -0
  26. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.github/workflows/tests.yml +0 -0
  27. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.gitignore +0 -0
  28. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.pre-commit-config.yaml +0 -0
  29. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/.python-version +0 -0
  30. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/LICENSE +0 -0
  31. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/Makefile +0 -0
  32. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gw.fish +0 -0
  33. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwa.fish +0 -0
  34. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwbc.fish +0 -0
  35. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwbd.fish +0 -0
  36. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwbs.fish +0 -0
  37. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwh.fish +0 -0
  38. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwl.fish +0 -0
  39. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwm.fish +0 -0
  40. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwp.fish +0 -0
  41. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwr.fish +0 -0
  42. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gwrot.fish +0 -0
  43. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/gws.fish +0 -0
  44. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/completions/worktrees.fish +0 -0
  45. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/docs/BENCHMARK.md +0 -0
  46. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/docs/REFERENCE.md +0 -0
  47. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/docs/commands/branch-delete.md +0 -0
  48. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/docs/commands/branch-status.md +0 -0
  49. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/functions/gwa.fish +0 -0
  50. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/functions/gwl.fish +0 -0
  51. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/functions/gwm.fish +0 -0
  52. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/functions/gwr!.fish +0 -0
  53. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/functions/gwr.fish +0 -0
  54. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/renovate.json +0 -0
  55. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/scripts/README.md +0 -0
  56. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/scripts/benchmark.py +0 -0
  57. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/scripts/verify-publish.bash +0 -0
  58. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/__init__.py +0 -0
  59. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/branch_cli.py +0 -0
  60. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/branch_forge.py +0 -0
  61. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/branches.py +0 -0
  62. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/errors.py +0 -0
  63. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/forge.py +0 -0
  64. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/git.py +0 -0
  65. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/layout.py +0 -0
  66. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/merged.py +0 -0
  67. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/new_branch.py +0 -0
  68. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/pick.py +0 -0
  69. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/progress.py +0 -0
  70. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/prune.py +0 -0
  71. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/render.py +0 -0
  72. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/repo.py +0 -0
  73. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/rotate.py +0 -0
  74. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/verdicts.py +0 -0
  75. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/src/worktrees/worktree.py +0 -0
  76. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/conftest.py +0 -0
  77. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_benchmark.py +0 -0
  78. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_branch_forge.py +0 -0
  79. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_branches.py +0 -0
  80. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_cli.py +0 -0
  81. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_completions.py +0 -0
  82. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_fixture.py +0 -0
  83. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_forge.py +0 -0
  84. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_gates.py +0 -0
  85. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_new_branch.py +0 -0
  86. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_render.py +0 -0
  87. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_rotate.py +0 -0
  88. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_spec.py +0 -0
  89. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/tests/test_worktree.py +0 -0
  90. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gw +0 -0
  91. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwa +0 -0
  92. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwbc +0 -0
  93. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwbd +0 -0
  94. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwbs +0 -0
  95. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwh +0 -0
  96. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwl +0 -0
  97. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwm +0 -0
  98. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwr +0 -0
  99. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gwrot +0 -0
  100. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/completions/_gws +0 -0
  101. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/functions/gwa +0 -0
  102. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/functions/gwl +0 -0
  103. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/functions/gwm +0 -0
  104. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/functions/gwr +0 -0
  105. {git_worktrees-0.6.0 → git_worktrees-0.6.2}/zsh/plugins/worktrees/functions/gwr! +0 -0
@@ -192,12 +192,27 @@ jobs:
192
192
  name: dist
193
193
  path: dist/
194
194
 
195
- # The install check waits for PyPI to serve the files.
195
+ # The install check resolves the wheel alone, so the sdist can still be
196
+ # missing from PyPI here. A file PyPI does not serve yet is asked again,
197
+ # backing off from 15s over eight attempts as the install check does;
198
+ # any other failure ends the job at once.
196
199
  - name: Verify attestations on PyPI
197
200
  run: |
198
201
  for f in dist/*.whl dist/*.tar.gz; do
199
- uvx pypi-attestations@0.0.30 verify pypi \
200
- --repository "https://github.com/$GITHUB_REPOSITORY" "pypi:${f#dist/}"
202
+ file="${f#dist/}"
203
+ delay=15
204
+ for attempt in 1 2 3 4 5 6 7 8; do
205
+ code=0
206
+ uvx pypi-attestations@0.0.30 verify pypi \
207
+ --repository "https://github.com/$GITHUB_REPOSITORY" "pypi:$file" 2>err.txt || code=$?
208
+ cat err.txt >&2
209
+ [ "$code" -ne 0 ] || break
210
+ grep -q "Could not find the artifact" err.txt || exit 1
211
+ [ "$attempt" -lt 8 ] || exit 1
212
+ echo "waiting ${delay}s for PyPI to serve $file (attempt $attempt/8)..." >&2
213
+ sleep "$delay"
214
+ delay=$((delay * 2))
215
+ done
201
216
  done
202
217
 
203
218
  release:
@@ -10,7 +10,9 @@ projects:
10
10
  - path: ./
11
11
  manifest: pyproject.toml
12
12
  changelog: CHANGELOG.md
13
- bump: uv version {version}
13
+ # `uv version` for pyproject.toml and uv.lock, then the copies the shell
14
+ # plugins and the README's install lines carry.
15
+ bump: python3 scripts/bump_version.py {version}
14
16
 
15
17
  release:
16
18
  branch: main
@@ -69,10 +69,13 @@ end
69
69
 
70
70
  `command` is what stops the function calling itself, in all three shells.
71
71
 
72
- One other kind of function exists: a shortcut, a banged name that calls a shim
73
- with its flags fixed and does nothing else. `gwr!` is `gwr --delete-ignored`.
74
- It calls the `gwr` function rather than `command gwr`, so the caller still
75
- lands where the binary says, and it has no console script of its own.
72
+ One other kind of function exists: a shortcut, a banged name that calls a
73
+ command with its flags fixed and does nothing else. `gwr!` is `gwr
74
+ --delete-ignored`, and `gwp!` is `gwp --force-refresh --delete-ignored
75
+ --yes`. A shortcut calls its command by its plain name, so `gwr!` reaches the
76
+ `gwr` function rather than `command gwr` and the caller still lands where the
77
+ binary says. No binary carries a banged name, so a shortcut shadows nothing,
78
+ and none has a console script of its own.
76
79
  `SHORTCUTS` in `tests/test_shims.py` lists them and holds each to one line.
77
80
 
78
81
  ## Two commands start branches
@@ -105,6 +108,14 @@ zsh/plugins/worktrees/completions/_gwa
105
108
  Neither manager puts a binary on `$PATH`. The console scripts arrive through
106
109
  `uv tool install` from the published package, which is a separate step.
107
110
 
111
+ Both plugins export `WORKTREES_PLUGIN_VERSION`, the release they came from:
112
+ `conf.d/worktrees.fish` and `worktrees.plugin.zsh`, one assignment each.
113
+ `gwh` and `gw version` compare it with `__version__`, in Python; the shell
114
+ files hold the value and no logic. Nothing built can stamp a file a plugin
115
+ manager copies from git, so `scripts/bump_version.py` writes it at release,
116
+ along with the tag in the README's install lines, and `tests/test_version.py`
117
+ fails when a copy disagrees with `pyproject.toml`.
118
+
108
119
  Nothing installs this from a checkout on the user's disk. It is consumed as a
109
120
  third-party plugin and a third-party tool, so anything that assumes a local
110
121
  clone at a known path is wrong here.
@@ -17,6 +17,35 @@ not in here, whatever it cost to build.
17
17
  A release closes with a `### Choices` section when a decision in it is worth
18
18
  the reader's time: what was chosen, and what the alternative failed to do.
19
19
 
20
+ ## 0.6.2 - 2026-11-04
21
+
22
+ ### Added
23
+
24
+ `gwp!` runs `gwp --force-refresh --delete-ignored --yes` in fish and zsh:
25
+ it fetches fresh, counts worktrees holding gitignored files as removable,
26
+ and removes everything `gws` marks removable without asking. Arguments
27
+ after it pass through, so `gwp! --branch NAME` works. Update the fish or
28
+ zsh plugin to install this shortcut.
29
+
30
+ ## 0.6.1 - 2026-11-02
31
+
32
+ ### Added
33
+
34
+ `gwh` says which release the shell plugin in this shell came from, and whether
35
+ it matches the commands. When the plugin is older, it names the tag to pin it
36
+ to, and when newer, it gives the `uv tool upgrade git-worktrees` to run.
37
+ `gw version` says the same on stderr, and its stdout is still the version
38
+ alone. Both plugins export `WORKTREES_PLUGIN_VERSION` for this. A shell whose
39
+ plugin predates this release reports none.
40
+
41
+ ### Changed
42
+
43
+ The README installs the plugins at the release's tag, `fisher install
44
+ MihaiBojin/worktrees@v0.6.1` for fish and `branch:v0.6.1` for Antidote, and
45
+ says how to move each to another release. Moving an existing install onto a
46
+ tag takes an edit to `fish_plugins` and `fisher update`, or `antidote purge
47
+ MihaiBojin/worktrees` before editing the tag.
48
+
20
49
  ## 0.6.0 - 2026-11-02
21
50
 
22
51
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: git-worktrees
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: Git worktree commands that refuse to lose work.
5
5
  Project-URL: Bug reports, https://github.com/MihaiBojin/worktrees/issues/new
6
6
  Project-URL: Source, https://github.com/MihaiBojin/worktrees
@@ -46,6 +46,7 @@ a shell function of the same name.
46
46
  | `gwm NEW` | rename this worktree's branch and move the checkout to match |
47
47
  | `gwr [QUERY]` | remove a worktree whose branch is finished, and the branch |
48
48
  | `gwr! [QUERY]` | `gwr --delete-ignored`, a shell function in fish and zsh |
49
+ | `gwp!` | `gwp --force-refresh --delete-ignored --yes`, a shell function in fish and zsh |
49
50
  | `gwbc NAME` | fetch, then branch `NAME` off the head branch and check it out |
50
51
  | `gwrot` | start the next branch after this one, or catch the head branch up |
51
52
  | `gwh` | print that table, with every name each command answers to |
@@ -132,21 +133,35 @@ That installs `gws`, `gwp`, `gwbs`, `gwbd`, `gwbc`, `gwrot`, and `gwh`. The
132
133
  four that land you somewhere need a shell function too, and every command has
133
134
  a completion, both of which arrive through a plugin manager.
134
135
 
136
+ Install the plugin at the tag of the release `uv` installed. Without a tag
137
+ both managers take `main`, which can be ahead of the last release, and the
138
+ functions then call commands they were not tested against. `gwh` says which
139
+ release the plugin here came from, and whether it is the same one.
140
+
141
+ To upgrade, move both: `uv tool upgrade git-worktrees` for the commands, then
142
+ the plugin's tag to the same release, as each manager below describes.
143
+
135
144
  ### fish
136
145
 
137
146
  ```console
138
- fisher install MihaiBojin/worktrees
147
+ fisher install MihaiBojin/worktrees@v0.6.2
139
148
  ```
140
149
 
141
- Fisher copies `functions/` and `completions/` from the repository root, so the
142
- five functions and ten completions land together. Nothing has to be sourced.
150
+ Fisher copies `functions/`, `completions/` and `conf.d/` from the repository
151
+ root, so the functions for `gwa`, `gwl`, `gwm`, `gwr`, `gwr!` and `gwp!` land
152
+ together with a completion for every command. Nothing has to be sourced.
153
+
154
+ To change release, edit the tag on that line of
155
+ `$__fish_config_dir/fish_plugins` and run `fisher update`. The same edit moves
156
+ an install without a tag onto one; `fisher install` with a tag refuses while
157
+ the untagged one holds the files.
143
158
 
144
159
  ### zsh
145
160
 
146
- Antidote takes a `path:` into the repository:
161
+ Antidote takes a `path:` into the repository, and `branch:` takes a tag:
147
162
 
148
163
  ```
149
- MihaiBojin/worktrees path:zsh/plugins/worktrees # in zsh_plugins.txt
164
+ MihaiBojin/worktrees branch:v0.6.2 path:zsh/plugins/worktrees # in zsh_plugins.txt
150
165
  ```
151
166
 
152
167
  The plugin puts its own `functions/` and `completions/` on `fpath` and
@@ -157,6 +172,19 @@ run; without one, add it after the plugin loads:
157
172
  autoload -Uz compinit && compinit
158
173
  ```
159
174
 
175
+ Antidote checks a tag out only when it clones, and `antidote update` leaves a
176
+ tag where it is. To change release, remove the clone, then edit the tag, then
177
+ open a new shell, which clones it again at the new tag:
178
+
179
+ ```zsh
180
+ antidote purge MihaiBojin/worktrees
181
+ ```
182
+
183
+ The order matters. Antidote rebuilds its bundle only when `zsh_plugins.txt` is
184
+ newer than the bundle, so a tag edited before the purge leaves a new shell
185
+ with no plugin until the file changes again. The same three steps move a clone
186
+ without a tag onto one.
187
+
160
188
  ### What the shell code does
161
189
 
162
190
  Each function runs `command <name>` and `cd`s to what it printed, provided
@@ -166,6 +194,16 @@ somewhere to go and stays put when it is not. `gws`, `gwp`, `gwbc`, `gwrot` and
166
194
  change no directory, so they ship as console scripts alone and answer the same
167
195
  from a prompt and from a script.
168
196
 
197
+ Both plugins export `WORKTREES_PLUGIN_VERSION`, the release they came from,
198
+ since the environment is all a binary sees of the shell that started it. `gwh`
199
+ and `gw version` compare it with their own and say whether the two match,
200
+ which is older, and what to run: `gwh` in its text, `gw version` on stderr, so
201
+ its stdout stays the version alone for a script to read.
202
+
203
+ A shell without the variable has no plugin loaded, or one older than the
204
+ release that started exporting it, and nothing can tell those two apart. A
205
+ bash started from fish or zsh inherits the variable without the functions.
206
+
169
207
  The completions hold no candidate of their own. `gw --complete` prints every
170
208
  subcommand and shorthand, `gwl --complete` prints every worktree, and both
171
209
  shells narrow what those return, so the matching stays in one place and a
@@ -495,7 +533,7 @@ their own and `gwbc` puts them on a branch.
495
533
 
496
534
  ```console
497
535
  $ gwh
498
- worktrees 0.5.1: git worktree commands that refuse to lose work
536
+ worktrees 0.6.2: git worktree commands that refuse to lose work
499
537
 
500
538
  COMMAND GW DOES
501
539
  gws gw status (s, st) which worktrees are finished, and why
@@ -510,6 +548,11 @@ gwh gw help (h) every command and alias, this list
510
548
  gwbc NAME gw branch create branch off the head branch
511
549
  gwbs [NAME ...] gw branch status which branches are finished, and why
512
550
  gwbd [NAME ...] gw branch delete delete local branches proved finished
551
+
552
+ gwa, gwl, gwm and gwr change the directory you are standing in.
553
+ A binary cannot do that, so each needs the shell function of the same name
554
+ from the plugin; the rest need nothing but $PATH.
555
+ The shell plugin here is 0.6.2, the same release as these commands.
513
556
  ```
514
557
 
515
558
  `gw help`, `gw h` and `gw` with no subcommand print the same thing. One table
@@ -20,6 +20,7 @@ a shell function of the same name.
20
20
  | `gwm NEW` | rename this worktree's branch and move the checkout to match |
21
21
  | `gwr [QUERY]` | remove a worktree whose branch is finished, and the branch |
22
22
  | `gwr! [QUERY]` | `gwr --delete-ignored`, a shell function in fish and zsh |
23
+ | `gwp!` | `gwp --force-refresh --delete-ignored --yes`, a shell function in fish and zsh |
23
24
  | `gwbc NAME` | fetch, then branch `NAME` off the head branch and check it out |
24
25
  | `gwrot` | start the next branch after this one, or catch the head branch up |
25
26
  | `gwh` | print that table, with every name each command answers to |
@@ -106,21 +107,35 @@ That installs `gws`, `gwp`, `gwbs`, `gwbd`, `gwbc`, `gwrot`, and `gwh`. The
106
107
  four that land you somewhere need a shell function too, and every command has
107
108
  a completion, both of which arrive through a plugin manager.
108
109
 
110
+ Install the plugin at the tag of the release `uv` installed. Without a tag
111
+ both managers take `main`, which can be ahead of the last release, and the
112
+ functions then call commands they were not tested against. `gwh` says which
113
+ release the plugin here came from, and whether it is the same one.
114
+
115
+ To upgrade, move both: `uv tool upgrade git-worktrees` for the commands, then
116
+ the plugin's tag to the same release, as each manager below describes.
117
+
109
118
  ### fish
110
119
 
111
120
  ```console
112
- fisher install MihaiBojin/worktrees
121
+ fisher install MihaiBojin/worktrees@v0.6.2
113
122
  ```
114
123
 
115
- Fisher copies `functions/` and `completions/` from the repository root, so the
116
- five functions and ten completions land together. Nothing has to be sourced.
124
+ Fisher copies `functions/`, `completions/` and `conf.d/` from the repository
125
+ root, so the functions for `gwa`, `gwl`, `gwm`, `gwr`, `gwr!` and `gwp!` land
126
+ together with a completion for every command. Nothing has to be sourced.
127
+
128
+ To change release, edit the tag on that line of
129
+ `$__fish_config_dir/fish_plugins` and run `fisher update`. The same edit moves
130
+ an install without a tag onto one; `fisher install` with a tag refuses while
131
+ the untagged one holds the files.
117
132
 
118
133
  ### zsh
119
134
 
120
- Antidote takes a `path:` into the repository:
135
+ Antidote takes a `path:` into the repository, and `branch:` takes a tag:
121
136
 
122
137
  ```
123
- MihaiBojin/worktrees path:zsh/plugins/worktrees # in zsh_plugins.txt
138
+ MihaiBojin/worktrees branch:v0.6.2 path:zsh/plugins/worktrees # in zsh_plugins.txt
124
139
  ```
125
140
 
126
141
  The plugin puts its own `functions/` and `completions/` on `fpath` and
@@ -131,6 +146,19 @@ run; without one, add it after the plugin loads:
131
146
  autoload -Uz compinit && compinit
132
147
  ```
133
148
 
149
+ Antidote checks a tag out only when it clones, and `antidote update` leaves a
150
+ tag where it is. To change release, remove the clone, then edit the tag, then
151
+ open a new shell, which clones it again at the new tag:
152
+
153
+ ```zsh
154
+ antidote purge MihaiBojin/worktrees
155
+ ```
156
+
157
+ The order matters. Antidote rebuilds its bundle only when `zsh_plugins.txt` is
158
+ newer than the bundle, so a tag edited before the purge leaves a new shell
159
+ with no plugin until the file changes again. The same three steps move a clone
160
+ without a tag onto one.
161
+
134
162
  ### What the shell code does
135
163
 
136
164
  Each function runs `command <name>` and `cd`s to what it printed, provided
@@ -140,6 +168,16 @@ somewhere to go and stays put when it is not. `gws`, `gwp`, `gwbc`, `gwrot` and
140
168
  change no directory, so they ship as console scripts alone and answer the same
141
169
  from a prompt and from a script.
142
170
 
171
+ Both plugins export `WORKTREES_PLUGIN_VERSION`, the release they came from,
172
+ since the environment is all a binary sees of the shell that started it. `gwh`
173
+ and `gw version` compare it with their own and say whether the two match,
174
+ which is older, and what to run: `gwh` in its text, `gw version` on stderr, so
175
+ its stdout stays the version alone for a script to read.
176
+
177
+ A shell without the variable has no plugin loaded, or one older than the
178
+ release that started exporting it, and nothing can tell those two apart. A
179
+ bash started from fish or zsh inherits the variable without the functions.
180
+
143
181
  The completions hold no candidate of their own. `gw --complete` prints every
144
182
  subcommand and shorthand, `gwl --complete` prints every worktree, and both
145
183
  shells narrow what those return, so the matching stays in one place and a
@@ -469,7 +507,7 @@ their own and `gwbc` puts them on a branch.
469
507
 
470
508
  ```console
471
509
  $ gwh
472
- worktrees 0.5.1: git worktree commands that refuse to lose work
510
+ worktrees 0.6.2: git worktree commands that refuse to lose work
473
511
 
474
512
  COMMAND GW DOES
475
513
  gws gw status (s, st) which worktrees are finished, and why
@@ -484,6 +522,11 @@ gwh gw help (h) every command and alias, this list
484
522
  gwbc NAME gw branch create branch off the head branch
485
523
  gwbs [NAME ...] gw branch status which branches are finished, and why
486
524
  gwbd [NAME ...] gw branch delete delete local branches proved finished
525
+
526
+ gwa, gwl, gwm and gwr change the directory you are standing in.
527
+ A binary cannot do that, so each needs the shell function of the same name
528
+ from the plugin; the rest need nothing but $PATH.
529
+ The shell plugin here is 0.6.2, the same release as these commands.
487
530
  ```
488
531
 
489
532
  `gw help`, `gw h` and `gw` with no subcommand print the same thing. One table
@@ -0,0 +1,7 @@
1
+ # Fisher autoloads functions/ and completions/ on demand, and the binaries
2
+ # come from `uv tool install` rather than from this package.
3
+ #
4
+ # The release this plugin came from, which `gwh` and `gw version` compare
5
+ # with their own. Exported, because the environment is all a binary can see
6
+ # of the shell that started it.
7
+ set -gx WORKTREES_PLUGIN_VERSION 0.6.2
@@ -157,7 +157,7 @@ network. `GIT_CONFIG_GLOBAL` carries that: without it git still reads
157
157
  ```
158
158
 
159
159
  That does the whole of it: cut `release/v0.2.0` from `origin/main`,
160
- `uv version 0.2.0`, open the pull request, wait for its checks, squash-merge,
160
+ `scripts/bump_version.py 0.2.0`, open the pull request, wait for its checks, squash-merge,
161
161
  wait for main's own run on the merged commit, and only then tag. The tag lands
162
162
  on a commit already proved green, so it never has to move.
163
163
 
@@ -201,13 +201,22 @@ published. Nothing is generated from pull request titles.
201
201
  By hand it is the same four commands:
202
202
 
203
203
  ```console
204
- uv version 0.2.0 # rewrites pyproject.toml and re-locks
204
+ python3 scripts/bump_version.py 0.2.0 # uv version, then the plugins and README
205
205
  # open a pull request, review it, merge it
206
206
  git switch main && git pull
207
207
  git tag -a v0.2.0 -m v0.2.0
208
208
  git push origin v0.2.0
209
209
  ```
210
210
 
211
+ `uv version` alone is not the bump. It rewrites `pyproject.toml` and
212
+ `uv.lock`, and the shell plugins carry a copy it never sees: Fisher and
213
+ Antidote install them from the tag rather than from anything built, so each
214
+ exports `WORKTREES_PLUGIN_VERSION` written into it, and the README's install
215
+ lines name the tag. `scripts/bump_version.py` writes every one of them, and
216
+ checks each line matches before it writes any. `tests/test_version.py` fails
217
+ when one disagrees with `pyproject.toml`, so a release pull request missing
218
+ one fails its checks before anything is tagged.
219
+
211
220
  The version lives in `pyproject.toml`, in the repository, on every commit,
212
221
  and in git history. The tag agrees with it or nothing is published. A tag
213
222
  moved onto a commit carrying a different version is refused, which is the
@@ -0,0 +1,4 @@
1
+ # gwp! [--branch NAME]: gwp after a fresh fetch, deleting ignored files, without asking.
2
+ function gwp! --wraps 'gwp --force-refresh --delete-ignored --yes' --description 'gwp, fresh, deleting the gitignored files too, without asking'
3
+ gwp --force-refresh --delete-ignored --yes $argv
4
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  Reading it back through `importlib.metadata` at import instead costs 10 ms of
4
4
  a 67 ms invocation, on every command, for a string two of them print. A
5
- constant in the wheel costs nothing, and `pyproject.toml` stays the one place
6
- the version is written.
5
+ constant in the wheel costs nothing, and the package reads its version from
6
+ `pyproject.toml` alone. The shell plugins' copy is `scripts/bump_version.py`'s.
7
7
 
8
8
  Not `hatch-vcs`: deriving the version from a tag inverts which of the two has
9
9
  to agree with the other, and `publish.yml` refuses a tag whose commit carries
@@ -9,7 +9,7 @@ authors = [
9
9
  ]
10
10
  # Static, and the single source of truth for the version. Bump it in a pull
11
11
  # request and run `uv lock`; the release tag only has to agree with it.
12
- version = "0.6.0"
12
+ version = "0.6.2"
13
13
  # The standard library answers every question this asks. A dependency here
14
14
  # would be paid on every invocation, and an invocation is 67 ms of which 25 ms
15
15
  # is the interpreter starting.
@@ -0,0 +1,77 @@
1
+ """Set the release version in every file that names it.
2
+
3
+ python3 scripts/bump_version.py 0.7.0
4
+
5
+ `uv version` writes `pyproject.toml` and `uv.lock`, and the wheel reads it
6
+ from there. The shell plugins carry a copy of their own, because Fisher and
7
+ Antidote install them from a git tag rather than from anything built, and the
8
+ README's install lines name that tag. `.releasetools.yaml` runs this as the
9
+ release's bump, and `tests/test_version.py` fails when a copy disagrees with
10
+ `pyproject.toml`.
11
+
12
+ Every line is checked before anything is written: a line that no longer
13
+ matches stops the bump with nothing changed, rather than releasing a version
14
+ some copy never heard of.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import re
20
+ import subprocess
21
+ import sys
22
+ from pathlib import Path
23
+
24
+ ROOT = Path(__file__).resolve().parents[1]
25
+
26
+ # Each file, and the lines in it that name the release, `{}` where it goes.
27
+ STAMPS: dict[str, tuple[str, ...]] = {
28
+ "conf.d/worktrees.fish": ("set -gx WORKTREES_PLUGIN_VERSION {}",),
29
+ "zsh/plugins/worktrees/worktrees.plugin.zsh": (
30
+ "export WORKTREES_PLUGIN_VERSION={}",
31
+ ),
32
+ "README.md": (
33
+ "MihaiBojin/worktrees@v{}",
34
+ "MihaiBojin/worktrees branch:v{}",
35
+ "worktrees {}: git worktree commands",
36
+ "The shell plugin here is {}, the same release",
37
+ ),
38
+ }
39
+
40
+
41
+ def _pattern(template: str) -> re.Pattern[str]:
42
+ """The template with any version where `{}` is."""
43
+ before, after = (re.escape(part) for part in template.split("{}"))
44
+ return re.compile(before + r"[0-9][0-9A-Za-z.+]*" + after)
45
+
46
+
47
+ def stamped(root: Path, version: str) -> dict[Path, str]:
48
+ """Every file's text with `version` written in, or SystemExit naming the
49
+ line that matched nothing."""
50
+ texts = {}
51
+ for name, templates in STAMPS.items():
52
+ path = root / name
53
+ text = path.read_text()
54
+ for template in templates:
55
+ # subn reads a backslash in the replacement as a group reference.
56
+ line = template.format(version).replace("\\", r"\\")
57
+ text, count = _pattern(template).subn(line, text)
58
+ if not count:
59
+ raise SystemExit(f"{name}: no line matches {template!r}")
60
+ texts[path] = text
61
+ return texts
62
+
63
+
64
+ def main(argv: list[str]) -> int:
65
+ if len(argv) != 1:
66
+ print("usage: bump_version.py VERSION", file=sys.stderr)
67
+ return 2
68
+ (version,) = argv
69
+ texts = stamped(ROOT, version)
70
+ subprocess.run(["uv", "version", version], cwd=ROOT, check=True)
71
+ for path, text in texts.items():
72
+ path.write_text(text)
73
+ return 0
74
+
75
+
76
+ if __name__ == "__main__":
77
+ raise SystemExit(main(sys.argv[1:]))
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import argparse
6
+ import os
6
7
  import sys
7
8
  import time
8
9
  from collections.abc import Callable
@@ -1059,9 +1060,64 @@ def run_remove(args: argparse.Namespace) -> int:
1059
1060
  # --------------------------------------------------------------------------
1060
1061
 
1061
1062
 
1063
+ # Exported by conf.d/worktrees.fish and worktrees.plugin.zsh, set to the
1064
+ # release each came from. scripts/bump_version.py writes both.
1065
+ PLUGIN_VERSION = "WORKTREES_PLUGIN_VERSION"
1066
+
1067
+
1068
+ def _release(version: str) -> tuple[int, ...] | None:
1069
+ """`x.y.z` as numbers to compare, or None for anything else, such as the
1070
+ `0+unknown` of a source tree nothing installed."""
1071
+ parts = version.split(".")
1072
+ if len(parts) != 3 or not all(p.isdigit() for p in parts):
1073
+ return None
1074
+ return tuple(int(p) for p in parts)
1075
+
1076
+
1077
+ def plugin_state() -> tuple[str, bool]:
1078
+ """What the shell plugin here says about its release, against this
1079
+ package's, and whether the two are the same release.
1080
+
1081
+ A shell without the variable has no plugin loaded, or one from before the
1082
+ plugin carried it. Nothing here can tell those two apart.
1083
+ """
1084
+ plugin = os.environ.get(PLUGIN_VERSION, "")
1085
+ if not plugin:
1086
+ return (
1087
+ "No shell plugin here says which release it is: none is loaded,\n"
1088
+ "or it is older than the release that started saying so.",
1089
+ False,
1090
+ )
1091
+ if plugin == __version__:
1092
+ return (
1093
+ f"The shell plugin here is {plugin}, the same release as these commands.",
1094
+ True,
1095
+ )
1096
+ ours, theirs = _release(__version__), _release(plugin)
1097
+ if ours and theirs and theirs < ours:
1098
+ return (
1099
+ f"The shell plugin here is {plugin}, older than these commands.\n"
1100
+ f"Pin it to v{__version__}: https://github.com/MihaiBojin/worktrees#install",
1101
+ False,
1102
+ )
1103
+ if ours and theirs:
1104
+ return (
1105
+ f"The shell plugin here is {plugin}, newer than these commands.\n"
1106
+ "Upgrade them with `uv tool upgrade git-worktrees`.",
1107
+ False,
1108
+ )
1109
+ return (
1110
+ f"The shell plugin here is {plugin}, and these commands are {__version__}.",
1111
+ False,
1112
+ )
1113
+
1114
+
1062
1115
  def run_version(args: argparse.Namespace) -> int:
1063
- """The version of the installed distribution."""
1116
+ """The version of the installed distribution on stdout, which is what a
1117
+ script reads, and the shell plugin's on stderr."""
1064
1118
  print(__version__)
1119
+ text, same = plugin_state()
1120
+ _err(render.note(text) if same else render.warn(text))
1065
1121
  return 0
1066
1122
 
1067
1123
 
@@ -1109,6 +1165,8 @@ def run_help(args: argparse.Namespace) -> int:
1109
1165
  "standing in.\nA binary cannot do that, so each needs the shell function "
1110
1166
  "of the same name\nfrom the plugin; the rest need nothing but $PATH."
1111
1167
  )
1168
+ text, same = plugin_state()
1169
+ print(o(text, "" if same else YELLOW))
1112
1170
  print()
1113
1171
  # Which commands take the common flags is the table's answer, not a second
1114
1172
  # list here: a row with no flags takes none, and saying so in prose is how