patchy-cli 0.0.21 → 0.0.22

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 (2) hide show
  1. package/README.md +53 -101
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://github.com/richardgill/patchy">
3
- <img width="180" src="./assets/logo.png" alt="Patchy logo">
3
+ <img width="120" src="./assets/logo.png" alt="Patchy logo">
4
4
  </a>
5
5
  </p>
6
6
  <br/>
@@ -15,123 +15,43 @@
15
15
 
16
16
  A CLI for generating and applying patches to git repositories.
17
17
 
18
- ## Patches vs forks
18
+ ## Why Patchy?
19
19
 
20
- A traditional fork means maintaining a separate repository or long-lived branch. Over time, your history diverges from upstream, which can make updates painful.
20
+ For long-lived git forks with no plans to merge upstream:
21
21
 
22
- With patches, you store your changes as `.diff` files. You can inspect them, edit them, and apply them to a fresh clone of the repo.
22
+ - A **git fork** stores your changes as commits.
23
+ - **Patches** store them as `.diff`
23
24
 
24
- ## What is Patchy?
25
+ Patch files are a clean way to store long-lived changes - human-readable, easy to review and version. But managing them can be cumbersome.
25
26
 
26
- Patchy helps you **generate** and **apply** `.diff` patches for a git repo you've cloned on your machine.
27
-
28
- It's opinionated and has [conventions](#patch-file-layout) about how the `.diff` files are stored.
27
+ Patchy makes managing patches easy: make changes to a clone save them as patches → reapply anytime.
29
28
 
30
29
  ## How it works
31
30
 
32
- 1. `patchy init` - sets up config and clones the upstream repo
33
- 2. Make your changes directly in the cloned repo
34
- 3. `patchy generate` - saves your changes as `.diff` files in `./patches/`
35
- 4. `patchy apply` - applies patches back to the repo
36
-
37
- Patchy also has commands to: reset your cloned repo, create more clones, switch which SHA or Tag to clone from etc.
38
-
39
- ## Detailed walkthrough
40
-
41
- Starting a patch-based fork of https://github.com/octocat/spoon-knife.
42
-
43
- ### Setup Patchy
44
-
45
- Create a folder for the fork: `mkdir spoon-knife-fork && cd spoon-knife-fork`
46
-
47
- - [Install Patchy](#installation)
48
- - Run `patchy init`
49
- - press enter to select all the default options
50
-
51
- `patchy init` creates your config: `./patchy.json` ([full reference](#patchyjson-reference))
52
- ```json5
53
- {
54
- "source_repo": "https://github.com/octocat/spoon-knife",
55
- "patches_dir": "./patches/",
56
- "clones_dir": "./clones/",
57
- "target_repo": "spoon-knife",
58
- "base_revision": "d0dd1f61b33d64e29d8bc1372a94ef6a2fee76a9",
59
- "upstream_branch": "main"
60
- }
61
- ```
62
-
63
- `patchy init` also creates an empty `./patches` folder and clones the spoon-knife repo into `./clones`:
31
+ `patchy init` sets up your project:
64
32
 
65
33
  ```
66
- ./
67
- ├── patches/
34
+ ├── patchy.json ← config (source: github.com/org/repo, base: v2.1.0)
68
35
  ├── clones/
69
- │ └── spoon-knife/
70
- └── path/to/existingFile.txt
71
- └── patchy.json
36
+ │ └── upstream-repo/ ← a clone of the source repo - your working copy
37
+ └── patches/ ← empty for now - your patches live here
72
38
  ```
73
39
 
74
- ### Make changes to the cloned repo
75
-
76
- We can now make changes directly in the cloned spoon-knife repo:
77
-
78
- ```bash
79
- echo "edit existing file" >> clones/spoon-knife/path/to/existingFile.txt
80
- echo "new file" > clones/spoon-knife/path/to/newFile.txt
81
- ```
82
-
83
- ### Generate patches:
84
-
85
- To generate the patches for the changes run `patchy generate`:
86
-
87
- Patchy will prompt you to create your first **patch set**, let's name it: 'first-patch-set'
88
-
89
- ```
90
- ./
91
- ├── clones/
92
- │ └── spoon-knife/
93
- │ ├── path/to/existingFile.txt
94
- │ └── path/to/newFile.txt
95
- ├── patches/
96
- │ └── 001-first-patch-set/ (created)
97
- │ ├── path/to/existingFile.txt.diff (generated)
98
- │ └── path/to/newFile.txt (generated)
99
- └── patchy.json
100
- ```
101
-
102
- - **Edits** are stored as `.diff` files e.g. `existingFile.txt.diff`.
103
- - **New files** are copied as regular files e.g. `newFile.txt` (easier to inspect and edit directly).
104
-
105
- ### Reapplying patches:
40
+ The workflow:
106
41
 
107
- Reset the current upstream repo with `patchy repo reset`, which will reset everything to `base_revision`:
42
+ 1. Make changes directly in `clones/upstream-repo/`
43
+ 2. Run `patchy generate` to generate patches:
108
44
 
109
45
  ```
110
- ./
111
- ├── clones/
112
- │ └── spoon-knife/ <<< reset
113
- │ ├── path/to/existingFile.txt
114
- ├── patches/
115
- │ └── 001-first-patch-set/
116
- │ ├── path/to/existingFile.txt.diff
117
- │ └── path/to/newFile.txt
118
- └── patchy.json
46
+ patches/
47
+ └── 001-feature-name/
48
+ ├── src/file.ts.diff ← edits to existing files
49
+ └── src/newFile.ts ← new files (no .diff suffix)
119
50
  ```
120
51
 
121
- Apply the patches back to the cloned repo with: `patchy apply`
52
+ 3. Run `patchy apply` to reapply your patches to `clones/upstream-repo/` anytime
122
53
 
123
- ```
124
- ./
125
- ├── clones/
126
- │ └── spoon-knife/
127
- │ ├── path/to/existingFile.txt (modified)
128
- │ └── path/to/newFile.txt (added)
129
- ├── patches/
130
- │ └── 001-first-patch-set/
131
- │ ├── path/to/existingFile.txt.diff
132
- │ └── path/to/newFile.txt
133
- └── patchy.json
134
- ```
54
+ See the [example walkthrough](./docs/example.md) for a step-by-step guide.
135
55
 
136
56
  ## Getting started
137
57
 
@@ -236,6 +156,8 @@ patches/
236
156
  └── patchy-post-apply # runs after patches
237
157
  ```
238
158
 
159
+ Patch sets support scripts without diffs, enabling pure automation steps.
160
+
239
161
  ### Hook execution
240
162
 
241
163
  - Hooks run with `cwd` set to `target_repo`
@@ -267,6 +189,8 @@ If `--patch-set` is not provided (and not set via env/config), prompts to select
267
189
 
268
190
  Note: `patchy generate` is destructive and will remove any unneeded files in the patch set directory.
269
191
 
192
+ ---
193
+
270
194
  ### `patchy apply`
271
195
 
272
196
  Apply patch files from `patches/` into `target_repo`. Patch sets are applied in alphabetical order.
@@ -279,7 +203,25 @@ patchy apply [--only <patch-set>] [--until <patch-set>] [--auto-commit=<mode>] [
279
203
  |------|-------------|
280
204
  | `--only <name>` | Apply only the specified patch set |
281
205
  | `--until <name>` | Apply patch sets up to and including the specified one |
282
- | `--auto-commit=<mode>` | Control auto-commit behavior: `all` (commit everything), `interactive` (prompt on last, default), `skip-last` (leave last uncommitted), `off` (commit nothing) |
206
+ | `--auto-commit=<mode>` | Control auto-commit behavior (see below) |
207
+
208
+ #### Auto-commit behavior
209
+
210
+ Each patch set creates a single commit with message `Apply patch set: <name>`. The `--auto-commit` flag controls when commits happen:
211
+
212
+ | Mode | Behavior |
213
+ |------|----------|
214
+ | `interactive` (default) | Commits all patch sets automatically, prompts for the last one |
215
+ | `all` | Commits every patch set immediately after applying |
216
+ | `skip-last` | Commits all except the last patch set |
217
+ | `off` | No commits are made |
218
+
219
+ **Notes:**
220
+ - In non-interactive environments (e.g., CI), `interactive` mode auto-commits everything
221
+ - Commits are skipped if any patch in the set fails to apply
222
+ - `--dry-run` skips all commits
223
+
224
+ ---
283
225
 
284
226
  ### `patchy repo reset`
285
227
 
@@ -289,6 +231,8 @@ Hard reset the Git working tree of `target_repo` to `base_revision`. Discards al
289
231
  patchy repo reset [--base-revision] [--target-repo]
290
232
  ```
291
233
 
234
+ ---
235
+
292
236
  ### `patchy repo clone`
293
237
 
294
238
  Clone a repository into a subdirectory of `clones_dir` and checkout `base_revision`. The target directory is derived from the repo name.
@@ -297,6 +241,8 @@ Clone a repository into a subdirectory of `clones_dir` and checkout `base_revisi
297
241
  patchy repo clone [--source-repo] [--clones-dir] [--base-revision]
298
242
  ```
299
243
 
244
+ ---
245
+
300
246
  ### `patchy base [revision]`
301
247
 
302
248
  View or update the `base_revision` in config.
@@ -306,6 +252,8 @@ patchy base # Interactive
306
252
  patchy base abc123def # Set base_revision to the specified SHA or tag
307
253
  ```
308
254
 
255
+ ---
256
+
309
257
  ### `patchy prime`
310
258
 
311
259
  Prints a prompt you can include in your `AGENTS.md` / `CLAUDE.md`.
@@ -322,6 +270,8 @@ patchy prime >> CLAUDE.md
322
270
 
323
271
  Outputs a brief description of Patchy, key paths, and essential commands to help AI coding agents understand your project's patch workflow.
324
272
 
273
+ ---
274
+
325
275
  ### `patchy config get <key>`
326
276
 
327
277
  Output a single config value (raw, no label). Useful for shell scripts.
@@ -354,6 +304,8 @@ patchy config get verbose # false
354
304
  - Unset raw keys exit with code 1
355
305
  - Unset computed keys (e.g., `patch_set_path` when `patch_set` is not set) output an empty line
356
306
 
307
+ ---
308
+
357
309
  ### `patchy config list`
358
310
 
359
311
  Output all config values as aligned key-value pairs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchy-cli",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "A CLI tool for managing Git patch workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -64,11 +64,11 @@
64
64
  "url": "https://github.com/richardgill/patchy"
65
65
  },
66
66
  "optionalDependencies": {
67
- "patchy-cli-linux-x64": "0.0.21",
68
- "patchy-cli-linux-arm64": "0.0.21",
69
- "patchy-cli-darwin-x64": "0.0.21",
70
- "patchy-cli-darwin-arm64": "0.0.21",
71
- "patchy-cli-windows-x64": "0.0.21"
67
+ "patchy-cli-linux-x64": "0.0.22",
68
+ "patchy-cli-linux-arm64": "0.0.22",
69
+ "patchy-cli-darwin-x64": "0.0.22",
70
+ "patchy-cli-darwin-arm64": "0.0.22",
71
+ "patchy-cli-windows-x64": "0.0.22"
72
72
  },
73
73
  "publishConfig": {
74
74
  "access": "public"