patchy-cli 0.0.6 → 0.0.7-pr.173.c4e5bf0
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/README.md +49 -31
- package/package.json +9 -7
- package/schema.json +5 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
# Patchy 🩹
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
A CLI for generating and applying patches to git repositories.
|
|
17
17
|
|
|
18
18
|
## Patches vs forks
|
|
19
19
|
|
|
@@ -42,10 +42,10 @@ Create a folder for the fork: `mkdir spoon-knife-fork && cd spoon-knife-fork`
|
|
|
42
42
|
`patchy init` creates your config: `./patchy.json` ([full reference](#patchyjson-reference))
|
|
43
43
|
```json5
|
|
44
44
|
{
|
|
45
|
-
"
|
|
45
|
+
"source_repo": "https://github.com/octocat/spoon-knife",
|
|
46
46
|
"patches_dir": "./patches/",
|
|
47
47
|
"clones_dir": "./clones/",
|
|
48
|
-
"
|
|
48
|
+
"target_repo": "spoon-knife",
|
|
49
49
|
"ref": "main"
|
|
50
50
|
}
|
|
51
51
|
```
|
|
@@ -74,6 +74,7 @@ echo "new file" > clones/spoon-knife/path/to/newFile.txt
|
|
|
74
74
|
|
|
75
75
|
To generate the patches for the changes run `patchy generate`:
|
|
76
76
|
|
|
77
|
+
Patchy will prompt you to create your first **patch set**, let's name it: 'first-patch-set'
|
|
77
78
|
|
|
78
79
|
```
|
|
79
80
|
./
|
|
@@ -82,10 +83,12 @@ To generate the patches for the changes run `patchy generate`:
|
|
|
82
83
|
│ ├── path/to/existingFile.txt
|
|
83
84
|
│ └── path/to/newFile.txt
|
|
84
85
|
├── patches/
|
|
85
|
-
│
|
|
86
|
-
│
|
|
86
|
+
│ └── 001-first-patch-set/ (created)
|
|
87
|
+
│ ├── path/to/existingFile.txt.diff (generated)
|
|
88
|
+
│ └── path/to/newFile.txt (generated)
|
|
87
89
|
└── patchy.json
|
|
88
90
|
```
|
|
91
|
+
|
|
89
92
|
- **Edits** are stored as `.diff` files e.g. `existingFile.txt.diff`.
|
|
90
93
|
- **New files** are copied as regular files e.g. `newFile.txt` (easier to inspect and edit directly).
|
|
91
94
|
|
|
@@ -99,8 +102,9 @@ Reset the current upstream repo `patchy repo reset main`, which will reset every
|
|
|
99
102
|
│ └── spoon-knife/ <<< reset
|
|
100
103
|
│ ├── path/to/existingFile.txt
|
|
101
104
|
├── patches/
|
|
102
|
-
│
|
|
103
|
-
│
|
|
105
|
+
│ └── 001-first-patch-set/
|
|
106
|
+
│ ├── path/to/existingFile.txt.diff
|
|
107
|
+
│ └── path/to/newFile.txt
|
|
104
108
|
└── patchy.json
|
|
105
109
|
```
|
|
106
110
|
|
|
@@ -113,8 +117,9 @@ Apply the patches back to the cloned repo with: `patchy apply`
|
|
|
113
117
|
│ ├── path/to/existingFile.txt (modified)
|
|
114
118
|
│ └── path/to/newFile.txt (added)
|
|
115
119
|
├── patches/
|
|
116
|
-
│
|
|
117
|
-
│
|
|
120
|
+
│ └── 001-first-patch-set/
|
|
121
|
+
│ ├── path/to/existingFile.txt.diff
|
|
122
|
+
│ └── path/to/newFile.txt
|
|
118
123
|
└── patchy.json
|
|
119
124
|
```
|
|
120
125
|
|
|
@@ -154,18 +159,22 @@ patchy init
|
|
|
154
159
|
|
|
155
160
|
```jsonc
|
|
156
161
|
{
|
|
157
|
-
// Git URL to clone from.
|
|
158
|
-
"
|
|
159
|
-
|
|
160
|
-
// Path to repo you're generating patches from or applying patches to.
|
|
161
|
-
"repo_dir": "~/repos/repo", // Override: --repo-dir | env: PATCHY_REPO_DIR
|
|
162
|
-
|
|
162
|
+
// Git URL or local file path to clone from.
|
|
163
|
+
"source_repo": "https://github.com/example/repo.git", // Override: --source-repo | env: PATCHY_SOURCE_REPO
|
|
163
164
|
// Directory containing patch files.
|
|
164
165
|
"patches_dir": "./patches/", // Override: --patches-dir | env: PATCHY_PATCHES_DIR
|
|
165
166
|
|
|
166
|
-
//
|
|
167
|
+
// Default directory for cloning repos.
|
|
167
168
|
"clones_dir": "./clones/", // Override: --clones-dir | env: PATCHY_CLONES_DIR
|
|
168
169
|
|
|
170
|
+
// Path to repo you're generating patches from or applying patches to.
|
|
171
|
+
// Can be relative to clones_dir: <clones_dir>/<target_repo> or absolute.
|
|
172
|
+
"target_repo": "repo", // Override: --target-repo | env: PATCHY_TARGET_REPO
|
|
173
|
+
|
|
174
|
+
// Patch set to generate into (subdirectory of patches_dir).
|
|
175
|
+
// If not set, prompts interactively or errors in non-interactive mode.
|
|
176
|
+
"patch_set": "001-security-fixes", // Override: --patch-set | env: PATCHY_PATCH_SET
|
|
177
|
+
|
|
169
178
|
// Git ref to checkout (branch, tag, SHA).
|
|
170
179
|
"ref": "main" // Override: --ref | env: PATCHY_REF
|
|
171
180
|
}
|
|
@@ -176,68 +185,77 @@ Precedence: CLI flags > Environment variables > `patchy.json`
|
|
|
176
185
|
|
|
177
186
|
## Patch file layout
|
|
178
187
|
|
|
179
|
-
The `patches/` directory (customizable via [`patches_dir`](#patchyjson-reference)) uses the same folder structure as `
|
|
188
|
+
The `patches/` directory (customizable via [`patches_dir`](#patchyjson-reference)) uses the same folder structure as `target_repo`:
|
|
180
189
|
|
|
181
190
|
```
|
|
182
191
|
./
|
|
183
192
|
├── patches/
|
|
184
|
-
│
|
|
185
|
-
│
|
|
193
|
+
│ └── 001-first-patch-set/
|
|
194
|
+
│ ├── path/to/existingFile.txt.diff
|
|
195
|
+
│ └── path/to/newFile.txt
|
|
186
196
|
├── clones/
|
|
187
197
|
│ └── repo-clone-1/
|
|
188
198
|
│ ├── path/to/existingFile.txt (modified)
|
|
189
199
|
│ └── path/to/newFile.txt (added)
|
|
190
200
|
└── patchy.json
|
|
191
201
|
```
|
|
202
|
+
Patches are grouped into **patch sets** for organizing related changes. Patch sets have numeric prefixes (e.g., `001-auth`, `002-ui`) and are applied in order.
|
|
192
203
|
|
|
193
204
|
**Two types of patch files:**
|
|
194
205
|
- **`.diff` files** — For modified existing files (generated via `git diff HEAD`)
|
|
195
206
|
- **Plain files** — For newly added files (copied verbatim for easier inspection and editing)
|
|
196
207
|
|
|
197
|
-
`patchy generate` automatically removes stale files in `patches
|
|
208
|
+
`patchy generate` automatically removes stale files in `patches/<patch-set>` that no longer correspond to changes in `target_repo`.
|
|
198
209
|
|
|
199
210
|
## Commands
|
|
200
211
|
|
|
201
212
|
### `patchy generate`
|
|
202
213
|
|
|
203
|
-
Generate `.diff` files and new files into `./patches
|
|
214
|
+
Generate `.diff` files and new files into `./patches/<patch-set>/` based on current `git diff` in `target_repo`.
|
|
204
215
|
|
|
205
216
|
```sh
|
|
206
|
-
patchy generate [--
|
|
217
|
+
patchy generate [--patch-set] [--target-repo] [--patches-dir] [--dry-run]
|
|
207
218
|
```
|
|
208
219
|
|
|
209
|
-
|
|
220
|
+
If `--patch-set` is not provided (and not set via env/config), prompts to select an existing patch set or create a new one.
|
|
221
|
+
|
|
222
|
+
Note: `patchy generate` is destructive and will remove any unneeded files in the patch set directory.
|
|
210
223
|
|
|
211
224
|
### `patchy apply`
|
|
212
225
|
|
|
213
|
-
Apply patch files from `patches/` into `
|
|
226
|
+
Apply patch files from `patches/` into `target_repo`. Patch sets are applied in alphabetical order.
|
|
214
227
|
|
|
215
228
|
```sh
|
|
216
|
-
patchy apply [--
|
|
229
|
+
patchy apply [--only <patch-set>] [--until <patch-set>] [--target-repo] [--patches-dir] [--dry-run]
|
|
217
230
|
```
|
|
218
231
|
|
|
232
|
+
| Flag | Description |
|
|
233
|
+
|------|-------------|
|
|
234
|
+
| `--only <name>` | Apply only the specified patch set |
|
|
235
|
+
| `--until <name>` | Apply patch sets up to and including the specified one |
|
|
236
|
+
|
|
219
237
|
### `patchy repo reset`
|
|
220
238
|
|
|
221
|
-
Hard reset the Git working tree of `
|
|
239
|
+
Hard reset the Git working tree of `target_repo`. Discards local changes.
|
|
222
240
|
|
|
223
241
|
```sh
|
|
224
|
-
patchy repo reset [--repo
|
|
242
|
+
patchy repo reset [--target-repo]
|
|
225
243
|
```
|
|
226
244
|
|
|
227
245
|
### `patchy repo checkout --ref <git-ref>`
|
|
228
246
|
|
|
229
|
-
Check out a specific Git ref (branch, tag, or SHA) in `
|
|
247
|
+
Check out a specific Git ref (branch, tag, or SHA) in `target_repo`.
|
|
230
248
|
|
|
231
249
|
```sh
|
|
232
|
-
patchy repo checkout --ref main [--repo
|
|
250
|
+
patchy repo checkout --ref main [--target-repo]
|
|
233
251
|
```
|
|
234
252
|
|
|
235
|
-
### `patchy repo clone
|
|
253
|
+
### `patchy repo clone`
|
|
236
254
|
|
|
237
255
|
Clone a repository into a subdirectory of `clones_dir`. The target directory is derived from the repo name.
|
|
238
256
|
|
|
239
257
|
```sh
|
|
240
|
-
patchy repo clone [--
|
|
258
|
+
patchy repo clone [--source-repo] [--clones-dir] [--ref]
|
|
241
259
|
```
|
|
242
260
|
|
|
243
261
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "patchy-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-pr.173.c4e5bf0",
|
|
4
4
|
"description": "A CLI tool for managing Git patch workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"changeset-version": "changeset version",
|
|
21
21
|
"dev": "bun run src/cli.ts",
|
|
22
22
|
"knip": "knip-bun",
|
|
23
|
+
"lint-versions": "syncpack lint",
|
|
23
24
|
"local-ci": "bun run scripts/local-ci.ts",
|
|
24
25
|
"prepare": "[ -n \"$CI\" ] || lefthook install",
|
|
25
26
|
"typecheck": "tsgo --noEmit",
|
|
@@ -36,10 +37,11 @@
|
|
|
36
37
|
"bun-types": "=1.3.4",
|
|
37
38
|
"knip": "=5.73.4",
|
|
38
39
|
"lefthook": "=2.0.11",
|
|
40
|
+
"syncpack": "=13.0.4",
|
|
39
41
|
"typescript": "=5.9.3"
|
|
40
42
|
},
|
|
41
43
|
"dependencies": {
|
|
42
|
-
"@clack/prompts": "1.0.0-alpha.8",
|
|
44
|
+
"@clack/prompts": "=1.0.0-alpha.8",
|
|
43
45
|
"@stricli/core": "=1.2.4",
|
|
44
46
|
"chalk": "=5.6.2",
|
|
45
47
|
"diff": "=8.0.2",
|
|
@@ -62,11 +64,11 @@
|
|
|
62
64
|
"url": "https://github.com/richardgill/patchy"
|
|
63
65
|
},
|
|
64
66
|
"optionalDependencies": {
|
|
65
|
-
"patchy-cli-linux-x64": "0.0.
|
|
66
|
-
"patchy-cli-linux-arm64": "0.0.
|
|
67
|
-
"patchy-cli-darwin-x64": "0.0.
|
|
68
|
-
"patchy-cli-darwin-arm64": "0.0.
|
|
69
|
-
"patchy-cli-windows-x64": "0.0.
|
|
67
|
+
"patchy-cli-linux-x64": "0.0.7-pr.173.c4e5bf0",
|
|
68
|
+
"patchy-cli-linux-arm64": "0.0.7-pr.173.c4e5bf0",
|
|
69
|
+
"patchy-cli-darwin-x64": "0.0.7-pr.173.c4e5bf0",
|
|
70
|
+
"patchy-cli-darwin-arm64": "0.0.7-pr.173.c4e5bf0",
|
|
71
|
+
"patchy-cli-windows-x64": "0.0.7-pr.173.c4e5bf0"
|
|
70
72
|
},
|
|
71
73
|
"publishConfig": {
|
|
72
74
|
"access": "public"
|
package/schema.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
|
-
"
|
|
7
|
+
"source_repo": {
|
|
8
8
|
"type": "string"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
10
|
+
"target_repo": {
|
|
11
11
|
"type": "string"
|
|
12
12
|
},
|
|
13
13
|
"clones_dir": {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"patches_dir": {
|
|
17
17
|
"type": "string"
|
|
18
18
|
},
|
|
19
|
+
"patch_set": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
19
22
|
"ref": {
|
|
20
23
|
"type": "string"
|
|
21
24
|
},
|