@procedures/git 0.2.3 → 0.3.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 (141) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +77 -12
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/module.d.ts.map +1 -1
  5. package/dist/module.js +312 -2
  6. package/dist/module.js.map +1 -1
  7. package/dist/procedures/git/blame.d.ts +17 -0
  8. package/dist/procedures/git/blame.d.ts.map +1 -0
  9. package/dist/procedures/git/blame.js +69 -0
  10. package/dist/procedures/git/blame.js.map +1 -0
  11. package/dist/procedures/git/branch/add.d.ts +12 -0
  12. package/dist/procedures/git/branch/add.d.ts.map +1 -0
  13. package/dist/procedures/git/branch/add.js +21 -0
  14. package/dist/procedures/git/branch/add.js.map +1 -0
  15. package/dist/procedures/git/branch/delete.d.ts +13 -0
  16. package/dist/procedures/git/branch/delete.d.ts.map +1 -0
  17. package/dist/procedures/git/branch/delete.js +24 -0
  18. package/dist/procedures/git/branch/delete.js.map +1 -0
  19. package/dist/procedures/git/branch/list.d.ts +13 -0
  20. package/dist/procedures/git/branch/list.d.ts.map +1 -0
  21. package/dist/procedures/git/branch/list.js +37 -0
  22. package/dist/procedures/git/branch/list.js.map +1 -0
  23. package/dist/procedures/git/branch.d.ts +8 -2
  24. package/dist/procedures/git/branch.d.ts.map +1 -1
  25. package/dist/procedures/git/branch.js +18 -37
  26. package/dist/procedures/git/branch.js.map +1 -1
  27. package/dist/procedures/git/commit.d.ts.map +1 -1
  28. package/dist/procedures/git/commit.js +9 -11
  29. package/dist/procedures/git/commit.js.map +1 -1
  30. package/dist/procedures/git/index.d.ts +19 -0
  31. package/dist/procedures/git/index.d.ts.map +1 -1
  32. package/dist/procedures/git/index.js +19 -0
  33. package/dist/procedures/git/index.js.map +1 -1
  34. package/dist/procedures/git/init.d.ts +6 -2
  35. package/dist/procedures/git/init.d.ts.map +1 -1
  36. package/dist/procedures/git/init.js +8 -4
  37. package/dist/procedures/git/init.js.map +1 -1
  38. package/dist/procedures/git/merge/abort.d.ts +14 -0
  39. package/dist/procedures/git/merge/abort.d.ts.map +1 -0
  40. package/dist/procedures/git/merge/abort.js +18 -0
  41. package/dist/procedures/git/merge/abort.js.map +1 -0
  42. package/dist/procedures/git/merge.d.ts +16 -0
  43. package/dist/procedures/git/merge.d.ts.map +1 -0
  44. package/dist/procedures/git/merge.js +41 -0
  45. package/dist/procedures/git/merge.js.map +1 -0
  46. package/dist/procedures/git/push.d.ts.map +1 -1
  47. package/dist/procedures/git/push.js +4 -2
  48. package/dist/procedures/git/push.js.map +1 -1
  49. package/dist/procedures/git/rebase/abort.d.ts +13 -0
  50. package/dist/procedures/git/rebase/abort.d.ts.map +1 -0
  51. package/dist/procedures/git/rebase/abort.js +17 -0
  52. package/dist/procedures/git/rebase/abort.js.map +1 -0
  53. package/dist/procedures/git/rebase/continue.d.ts +13 -0
  54. package/dist/procedures/git/rebase/continue.d.ts.map +1 -0
  55. package/dist/procedures/git/rebase/continue.js +23 -0
  56. package/dist/procedures/git/rebase/continue.js.map +1 -0
  57. package/dist/procedures/git/rebase.d.ts +22 -0
  58. package/dist/procedures/git/rebase.d.ts.map +1 -0
  59. package/dist/procedures/git/rebase.js +46 -0
  60. package/dist/procedures/git/rebase.js.map +1 -0
  61. package/dist/procedures/git/refs.d.ts +31 -0
  62. package/dist/procedures/git/refs.d.ts.map +1 -0
  63. package/dist/procedures/git/refs.js +52 -0
  64. package/dist/procedures/git/refs.js.map +1 -0
  65. package/dist/procedures/git/reset.d.ts +13 -0
  66. package/dist/procedures/git/reset.d.ts.map +1 -0
  67. package/dist/procedures/git/reset.js +31 -0
  68. package/dist/procedures/git/reset.js.map +1 -0
  69. package/dist/procedures/git/restore.d.ts +13 -0
  70. package/dist/procedures/git/restore.d.ts.map +1 -0
  71. package/dist/procedures/git/restore.js +26 -0
  72. package/dist/procedures/git/restore.js.map +1 -0
  73. package/dist/procedures/git/revParse.d.ts +13 -0
  74. package/dist/procedures/git/revParse.d.ts.map +1 -0
  75. package/dist/procedures/git/revParse.js +23 -0
  76. package/dist/procedures/git/revParse.js.map +1 -0
  77. package/dist/procedures/git/run.d.ts +2 -0
  78. package/dist/procedures/git/run.d.ts.map +1 -1
  79. package/dist/procedures/git/run.js +1 -0
  80. package/dist/procedures/git/run.js.map +1 -1
  81. package/dist/procedures/git/show.d.ts +15 -0
  82. package/dist/procedures/git/show.d.ts.map +1 -0
  83. package/dist/procedures/git/show.js +49 -0
  84. package/dist/procedures/git/show.js.map +1 -0
  85. package/dist/procedures/git/tag/add.d.ts +12 -0
  86. package/dist/procedures/git/tag/add.d.ts.map +1 -0
  87. package/dist/procedures/git/tag/add.js +25 -0
  88. package/dist/procedures/git/tag/add.js.map +1 -0
  89. package/dist/procedures/git/tag/delete.d.ts +12 -0
  90. package/dist/procedures/git/tag/delete.d.ts.map +1 -0
  91. package/dist/procedures/git/tag/delete.js +19 -0
  92. package/dist/procedures/git/tag/delete.js.map +1 -0
  93. package/dist/procedures/git/tag/list.d.ts +12 -0
  94. package/dist/procedures/git/tag/list.d.ts.map +1 -0
  95. package/dist/procedures/git/tag/list.js +34 -0
  96. package/dist/procedures/git/tag/list.js.map +1 -0
  97. package/dist/procedures/git/worktree/add.d.ts +13 -0
  98. package/dist/procedures/git/worktree/add.d.ts.map +1 -0
  99. package/dist/procedures/git/worktree/add.js +35 -0
  100. package/dist/procedures/git/worktree/add.js.map +1 -0
  101. package/dist/procedures/git/worktree/list.d.ts +17 -0
  102. package/dist/procedures/git/worktree/list.d.ts.map +1 -0
  103. package/dist/procedures/git/worktree/list.js +52 -0
  104. package/dist/procedures/git/worktree/list.js.map +1 -0
  105. package/dist/procedures/git/worktree/remove.d.ts +13 -0
  106. package/dist/procedures/git/worktree/remove.d.ts.map +1 -0
  107. package/dist/procedures/git/worktree/remove.js +20 -0
  108. package/dist/procedures/git/worktree/remove.js.map +1 -0
  109. package/dist/types.d.ts +308 -0
  110. package/dist/types.d.ts.map +1 -1
  111. package/dist/types.js +265 -0
  112. package/dist/types.js.map +1 -1
  113. package/package.json +4 -4
  114. package/src/module.ts +411 -2
  115. package/src/procedures/git/blame.ts +68 -0
  116. package/src/procedures/git/branch/add.ts +24 -0
  117. package/src/procedures/git/branch/delete.ts +29 -0
  118. package/src/procedures/git/branch/list.ts +40 -0
  119. package/src/procedures/git/branch.ts +19 -40
  120. package/src/procedures/git/commit.ts +9 -11
  121. package/src/procedures/git/index.ts +19 -0
  122. package/src/procedures/git/init.ts +11 -10
  123. package/src/procedures/git/merge/abort.ts +20 -0
  124. package/src/procedures/git/merge.ts +42 -0
  125. package/src/procedures/git/push.ts +4 -2
  126. package/src/procedures/git/rebase/abort.ts +19 -0
  127. package/src/procedures/git/rebase/continue.ts +25 -0
  128. package/src/procedures/git/rebase.ts +48 -0
  129. package/src/procedures/git/refs.ts +55 -0
  130. package/src/procedures/git/reset.ts +34 -0
  131. package/src/procedures/git/restore.ts +27 -0
  132. package/src/procedures/git/revParse.ts +24 -0
  133. package/src/procedures/git/run.ts +3 -0
  134. package/src/procedures/git/show.ts +57 -0
  135. package/src/procedures/git/tag/add.ts +27 -0
  136. package/src/procedures/git/tag/delete.ts +22 -0
  137. package/src/procedures/git/tag/list.ts +36 -0
  138. package/src/procedures/git/worktree/add.ts +35 -0
  139. package/src/procedures/git/worktree/list.ts +48 -0
  140. package/src/procedures/git/worktree/remove.ts +21 -0
  141. package/src/types.ts +623 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # @procedures/git
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4cad9ab: More git procedures (roadmap R40): `git.show`, `git.blame`, `git.tag.list`, `git.tag.add`, `git.tag.delete`, `git.revParse`, `git.reset`, `git.restore`, `git.merge`, `git.merge.abort`, `git.rebase`, `git.rebase.continue`, `git.rebase.abort`, `git.worktree.list`, `git.worktree.add` and `git.worktree.remove`. Each one declares its effects. A merge or a rebase that stops on conflicts gives `conflict: true` and the files, and git never starts an editor.
8
+
9
+ `git.branch` becomes three procedures: `git.branch.list`, `git.branch.add` and `git.branch.delete`. `git.branch` is deprecated. It stays for one release with the same input and output, and it calls the new code.
10
+
11
+ The current branch comes from `git symbolic-ref`. Before, `git.branch` and `git.push` used `git rev-parse --abbrev-ref HEAD`, which fails in a repository without commits. `git.branch.list` and `git.branch` work there now.
12
+
13
+ ### Patch Changes
14
+
15
+ - 95b660d: Three defects that the new tests of roadmap R33 found:
16
+
17
+ - `git.commit` gives `skipped: true` when nothing is staged. Before, an untracked file or a change that was not staged made `git commit` fail with "nothing added to commit". With `all`, a change of a tracked file is a change to commit, and an untracked file is not.
18
+ - `git.init` looks for `.git` itself. Before, it used `fs.exists` through its context, so it failed in a registry of `gitModule` alone (`createRegistry(gitModule)`).
19
+ - A component of `@procedures/splay` gives its registry to the children that it renders. Before, the child of a child came from the global registry, so a component in a registry of `createRegistry()` rendered an "unknown" grandchild.
20
+ - Updated dependencies [ddea529]
21
+ - Updated dependencies [b2a3e3a]
22
+ - Updated dependencies [a8c47f1]
23
+ - Updated dependencies [381ce3a]
24
+ - Updated dependencies [0c627f8]
25
+ - Updated dependencies [ae7f05f]
26
+ - Updated dependencies [7873940]
27
+ - Updated dependencies [a70d445]
28
+ - Updated dependencies [bc70357]
29
+ - Updated dependencies [07cc998]
30
+ - Updated dependencies [a6b01a9]
31
+ - Updated dependencies [c799cdd]
32
+ - Updated dependencies [540f8d9]
33
+ - Updated dependencies [b6daaec]
34
+ - Updated dependencies [5b9264e]
35
+ - Updated dependencies [956e88b]
36
+ - Updated dependencies [ff62281]
37
+ - Updated dependencies [d81d0ed]
38
+ - Updated dependencies [aa67cc7]
39
+ - Updated dependencies [061fa22]
40
+ - Updated dependencies [cfb9d69]
41
+ - Updated dependencies [43f7de5]
42
+ - Updated dependencies [b07bb50]
43
+ - Updated dependencies [4a3bfa1]
44
+ - Updated dependencies [bd0b626]
45
+ - Updated dependencies [a6be873]
46
+ - Updated dependencies [fb30718]
47
+ - Updated dependencies [c5528e4]
48
+ - Updated dependencies [fee5d9c]
49
+ - Updated dependencies [21f7743]
50
+ - Updated dependencies [31a0b46]
51
+ - @procedures/client@0.3.0
52
+ - @procedures/shell@0.3.0
53
+
3
54
  ## 0.2.3
4
55
 
5
56
  ### Patch Changes
package/README.md CHANGED
@@ -3,13 +3,13 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@procedures/git.svg)](https://www.npmjs.com/package/@procedures/git)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- > Git operations as RPC procedures - `git.add`, `git.commit`, `git.push`, `git.status`, and 22 more git commands exposed as type-safe procedures.
6
+ > Git operations as RPC procedures - `git.add`, `git.commit`, `git.push`, `git.status`, and 41 more git commands exposed as type-safe procedures.
7
7
 
8
8
  ## Overview
9
9
 
10
- `@procedures/git` exposes comprehensive Git functionality as RPC procedures through the client system. It provides 26 procedures covering all major Git operations including repository state management, staging, commits, branching, remote operations, stashing, and repository predicates.
10
+ `@procedures/git` exposes comprehensive Git functionality as RPC procedures through the client system. It provides 45 procedures covering all major Git operations including repository state management, staging, commits, branching, tags, merges, rebases, working trees, remote operations, stashing, and repository predicates.
11
11
 
12
- This package wraps Git commands directly (not through `client-shell`), providing structured input/output with full type safety via Zod schemas.
12
+ The package starts git with `runCommand` of `@procedures/shell`: an argument list, no shell. Each call is async, and its signal stops git. Zod schemas validate the input and the output.
13
13
 
14
14
  ## Architecture
15
15
 
@@ -36,11 +36,12 @@ graph TB
36
36
 
37
37
  ```mermaid
38
38
  graph LR
39
- A[client-git<br/>26 Procedures] --> B[Repository State<br/>5 procedures]
39
+ A[client-git<br/>45 Procedures] --> B[Repository State<br/>5 procedures]
40
40
  A --> C[Staging & Commits<br/>3 procedures]
41
41
  A --> D[Remote Operations<br/>5 procedures]
42
42
  A --> E[Predicates<br/>6 procedures]
43
43
  A --> F[Stash Operations<br/>7 procedures]
44
+ A --> G[History, Tags, Merge, Rebase,<br/>Working Trees, Branches<br/>19 procedures]
44
45
 
45
46
  B -.-> B1[status, log, diff,<br/>branch, init]
46
47
  C -.-> C1[add, commit,<br/>checkout]
@@ -226,10 +227,12 @@ console.log(`${diff.additions} additions, ${diff.deletions} deletions`);
226
227
  const staged = await client.exec(["git", "diff"], { staged: true });
227
228
  ```
228
229
 
229
- #### `git.branch`
230
+ #### `git.branch` (deprecated)
230
231
 
231
232
  Branch operations - list, create, delete branches.
232
233
 
234
+ This procedure is deprecated since roadmap R40. Use `git.branch.list`, `git.branch.add` and `git.branch.delete`. It stays for one release, and it calls the code of the three new procedures. Its metadata has `deprecated: true`.
235
+
233
236
  **Path:** `["git", "branch"]`
234
237
 
235
238
  ```typescript
@@ -841,6 +844,51 @@ const exported = await client.exec(["git", "stash", "export"], { index: 0 });
841
844
  fs.writeFileSync("backup.patch", exported.patch);
842
845
  ```
843
846
 
847
+ ### History, tags, merges, rebases and working trees (roadmap R40)
848
+
849
+ Each procedure takes `cwd`, the folder of the repository. A value that starts with `-` is not an option: a ref or a name is refused, and a path stays a path after `--`. The effects column shows `metadata.effects`. "process" means that git starts the hooks of the repository, which are code of the project.
850
+
851
+ | Procedure | Input | Output | Effects |
852
+ |---|---|---|---|
853
+ | `git.show` | `ref` (default `HEAD`), `path`, `stat` | Without `path`: `hash`, `author`, `email`, `date`, `message`, `body`, `files`, `diff`. With `path`: `content` | reads |
854
+ | `git.blame` | `path`, `ref`, `startLine`, `endLine` | `lines`: `line`, `hash`, `author`, `email`, `date`, `summary`, `content` | reads |
855
+ | `git.tag.list` | `pattern` | `tags`: `name`, `hash` (the commit), `annotated`, `message` | reads |
856
+ | `git.tag.add` | `name`, `ref`, `message` | `name`, `hash`, `annotated` | writes, not destructive, idempotent |
857
+ | `git.tag.delete` | `name` | `name`, `hash` (the object of the tag) | writes, destructive, idempotent |
858
+ | `git.revParse` | `ref` (default `HEAD`), `abbrevRef`, `short` | `ref`, `value` | reads |
859
+ | `git.reset` | `ref` (default `HEAD`), `mode` (`soft`, `mixed`, `hard`, `merge`, `keep`), `paths` | `ref`, `mode`, `hash` | writes, destructive |
860
+ | `git.restore` | `paths`, `source`, `staged`, `worktree` | `restored` | writes, process, destructive, idempotent |
861
+ | `git.merge` | `ref`, `fastForward` (`auto`, `only`, `never`), `message` | `hash`, `fastForward`, `upToDate`, `conflict`, `conflicts` | writes, process, idempotent |
862
+ | `git.merge.abort` | none | `aborted`, `hash` | writes, destructive, idempotent |
863
+ | `git.rebase` | `upstream`, `onto`, `branch` | `hash`, `completed`, `upToDate`, `conflict`, `conflicts` | writes, process, destructive, idempotent |
864
+ | `git.rebase.continue` | none | the output of `git.rebase` | writes, process, destructive |
865
+ | `git.rebase.abort` | none | `aborted`, `hash` | writes, destructive, idempotent |
866
+ | `git.worktree.list` | none | `worktrees`: `path`, `head`, `branch`, `detached`, `bare`, `locked`, `prunable` | reads |
867
+ | `git.worktree.add` | `path`, `ref`, `branch`, `detach` | `path`, `head`, `branch` | writes, process, not destructive, idempotent |
868
+ | `git.worktree.remove` | `path`, `force` | `path` | writes, destructive, idempotent |
869
+ | `git.branch.list` | `remote` | `branches`, `current` | reads |
870
+ | `git.branch.add` | `name`, `startPoint` | `name`, `hash` | writes, not destructive, idempotent |
871
+ | `git.branch.delete` | `name`, `force` | `name`, `hash` (the last commit) | writes, destructive, idempotent |
872
+
873
+ - A merge or a rebase that stops on conflicts is a result, not an error. Then `conflict` is `true`, and `conflicts` names the files.
874
+ - After the conflicts of a merge, resolve them and call `git.commit`, or call `git.merge.abort`.
875
+ - After the conflicts of a rebase, resolve them, stage them with `git.add`, and call `git.rebase.continue`. Or call `git.rebase.abort`.
876
+ - A merge and a rebase never start an editor. The rebase is never interactive.
877
+ - `git.tag.add` and `git.branch.add` never move a ref. An existing tag or branch is an error.
878
+ - `git.branch.delete` and `git.tag.delete` give the deleted hash. `git.branch.add` with it makes the branch again.
879
+ - `git.branch.list` works in a repository without commits. Then `branches` is empty and `current` is the branch that `HEAD` names.
880
+
881
+ ```typescript
882
+ const merge = await client.exec(["git", "merge"], { ref: "feature", cwd: "./repo" });
883
+ if (merge.conflict) {
884
+ console.log("Conflicts in", merge.conflicts);
885
+ await client.exec(["git", "merge", "abort"], { cwd: "./repo" });
886
+ }
887
+
888
+ const { lines } = await client.exec(["git", "blame"], { path: "src/index.ts", startLine: 1, endLine: 10 });
889
+ const { value: branch } = await client.exec(["git", "revParse"], { abbrevRef: true });
890
+ ```
891
+
844
892
  ## Complete Procedure List
845
893
 
846
894
  | Category | Procedure | Description |
@@ -848,8 +896,27 @@ fs.writeFileSync("backup.patch", exported.patch);
848
896
  | **Repository State** | `git.status` | Get repository status |
849
897
  | | `git.log` | Show commit history |
850
898
  | | `git.diff` | Show changes |
851
- | | `git.branch` | Branch operations |
899
+ | | `git.show` | Show a commit, or a file at a commit |
900
+ | | `git.blame` | Show the commit and the author of each line |
901
+ | | `git.revParse` | Give the hash or the name of a ref |
902
+ | | `git.branch` | Branch operations (deprecated) |
852
903
  | | `git.init` | Initialize repository |
904
+ | **Branches and Tags** | `git.branch.list` | List the branches |
905
+ | | `git.branch.add` | Make a branch |
906
+ | | `git.branch.delete` | Delete a branch |
907
+ | | `git.tag.list` | List the tags |
908
+ | | `git.tag.add` | Make a tag |
909
+ | | `git.tag.delete` | Delete a tag |
910
+ | **Merge and Rebase** | `git.merge` | Merge into the current branch |
911
+ | | `git.merge.abort` | Stop a merge with conflicts |
912
+ | | `git.rebase` | Rebase the current branch |
913
+ | | `git.rebase.continue` | Continue a rebase |
914
+ | | `git.rebase.abort` | Stop a rebase |
915
+ | **Working Trees** | `git.worktree.list` | List the working trees |
916
+ | | `git.worktree.add` | Add a working tree |
917
+ | | `git.worktree.remove` | Remove a working tree |
918
+ | **Undo** | `git.reset` | Move `HEAD`, reset the index or the working tree |
919
+ | | `git.restore` | Restore files |
853
920
  | **Staging & Commits** | `git.add` | Stage files |
854
921
  | | `git.commit` | Create commit |
855
922
  | | `git.checkout` | Checkout branch/files |
@@ -932,11 +999,9 @@ await client.exec(["git", "commit"], { message: "feat: complete feature" });
932
999
  await client.exec(["git", "checkout"], { ref: "main" });
933
1000
  await client.exec(["git", "pull"], {});
934
1001
 
935
- // Delete feature branch
936
- await client.exec(["git", "branch"], {
937
- name: "feature/new-feature",
938
- delete: true,
939
- });
1002
+ // Merge it, then delete the feature branch
1003
+ await client.exec(["git", "merge"], { ref: "feature/new-feature" });
1004
+ await client.exec(["git", "branch", "delete"], { name: "feature/new-feature" });
940
1005
  ```
941
1006
 
942
1007
  ### Working with Remotes
@@ -949,7 +1014,7 @@ const clone = await client.exec(["git", "clone"], {
949
1014
  });
950
1015
 
951
1016
  // Set remote
952
- await client.exec(["git", "remote"], {
1017
+ await client.exec(["git", "remote", "set"], {
953
1018
  name: "upstream",
954
1019
  url: "https://github.com/original/repo.git",
955
1020
  });