codeowners-git 1.7.0 → 1.8.0

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 (3) hide show
  1. package/README.md +109 -2
  2. package/dist/cli.js +4442 -927
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,6 +11,7 @@ Managing large-scale migrations in big monorepos with multiple codeowners can be
11
11
  - Identifying files owned by specific teams using the CODEOWNERS file.
12
12
  - Creating compact, team-specific branches with only their affected files.
13
13
  - Streamlining the review process with smaller, targeted PRs.
14
+ - **Graceful error handling** with automatic recovery from failures.
14
15
 
15
16
  > **Note:** This tool works with **unstaged files**. Make sure to check if your files are unstaged before proceeding.
16
17
 
@@ -24,8 +25,6 @@ Run commands directly without installation:
24
25
 
25
26
  ```bash
26
27
  npx codeowners-git <command>
27
- # or use the short alias
28
- npx cg <command>
29
28
  ```
30
29
 
31
30
  ### Install globally via npm
@@ -69,6 +68,7 @@ gh auth login
69
68
  ```
70
69
 
71
70
  The tool will automatically:
71
+
72
72
  - Use PR templates if they exist in your repository (`.github/pull_request_template.md`, etc.)
73
73
  - Set the PR title to your commit message
74
74
  - Create PRs against the repository's default branch
@@ -227,6 +227,113 @@ This will:
227
227
  - Add a commit message like "Add new feature - @team-a"
228
228
  - Push each branch to the remote if the `-p` flag is provided
229
229
 
230
+ ### `extract`
231
+
232
+ Extract file changes from a source branch or commit to your working directory (unstaged). This is useful when you want to copy changes from another branch to review and then commit using the `branch` command.
233
+
234
+ Usage:
235
+
236
+ ```bash
237
+ codeowners-git extract [options]
238
+ # or
239
+ cg extract [options]
240
+ ```
241
+
242
+ Options:
243
+
244
+ - `--source, -s` **(required)** Source branch or commit to extract from
245
+ - `--owner, -o` Filter extracted files by code owner (supports micromatch patterns like `@team-*`)
246
+ - `--compare-main` Compare source against main branch instead of detecting merge-base
247
+
248
+ Examples:
249
+
250
+ ```bash
251
+ # Extract all changes from a branch (files will be unstaged in working directory)
252
+ cg extract -s feature/other-team
253
+
254
+ # Extract only specific owner's files using micromatch patterns
255
+ cg extract -s feature/other-team -o "@my-team"
256
+ cg extract -s feature/other-team -o "@team-*"
257
+
258
+ # Extract from a commit hash
259
+ cg extract -s abc123def
260
+
261
+ # Extract comparing against main (instead of detecting merge-base)
262
+ cg extract -s feature/long-running --compare-main
263
+ ```
264
+
265
+ > **Note:** Files are extracted unstaged, allowing you to review and modify them. Use the `branch` command afterward to create a branch, commit, push, and create PRs.
266
+
267
+ ### `recover`
268
+
269
+ Recover from failed or incomplete operations. When `branch` or `multi-branch` commands fail, the tool tracks the operation state and allows you to clean up and return to your original branch.
270
+
271
+ Usage:
272
+
273
+ ```bash
274
+ codeowners-git recover [options]
275
+ # or
276
+ cg recover [options]
277
+ ```
278
+
279
+ Options:
280
+
281
+ - `--list` List all incomplete operations
282
+ - `--id <operationId>` Recover specific operation by UUID
283
+ - `--keep-branches` Keep created branches instead of deleting them
284
+ - `--auto` Automatically recover most recent operation without prompts
285
+
286
+ Examples:
287
+
288
+ ```bash
289
+ # List all incomplete operations
290
+ cg recover --list
291
+
292
+ # Automatically recover from most recent failure
293
+ cg recover --auto
294
+
295
+ # Recover specific operation
296
+ cg recover --id abc12345-6789-...
297
+
298
+ # Recover but keep the created branches
299
+ cg recover --id abc12345-6789-... --keep-branches
300
+ ```
301
+
302
+ **When to use:**
303
+
304
+ - Operation failed due to network errors
305
+ - Process was interrupted (Ctrl+C)
306
+ - Push failed but branch was created
307
+ - Need to clean up after errors
308
+
309
+ **What it does:**
310
+
311
+ 1. Returns to your original branch
312
+ 2. Optionally deletes created branches (unless `--keep-branches`)
313
+ 3. Cleans up state files
314
+
315
+ **How it works:**
316
+
317
+ Every `branch` and `multi-branch` operation is tracked with a unique UUID in your home directory (`~/.codeowners-git/state/`). If an operation fails, you'll see recovery instructions:
318
+
319
+ ```bash
320
+ ✗ Operation failed: Push failed with exit code 128
321
+
322
+ Recovery options:
323
+ 1. Run 'codeowners-git recover --id abc12345...' to clean up
324
+ 2. Run 'codeowners-git recover --id abc12345... --keep-branches' to keep branches
325
+ 3. Run 'codeowners-git recover --list' to see all incomplete operations
326
+ ```
327
+
328
+ The tool automatically handles:
329
+
330
+ - Graceful shutdown on Ctrl+C (SIGINT/SIGTERM)
331
+ - State persistence across crashes
332
+ - Detailed operation tracking (branch creation, commits, pushes, PR creation)
333
+ - Clean recovery to original state
334
+
335
+ > **Note:** State files are stored in `~/.codeowners-git/state/` outside your project directory, so no `.gitignore` entries are needed.
336
+
230
337
  ## Contributing
231
338
 
232
339
  1. Clone the repository