git-chopstick-core 0.1.1 → 0.1.3
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 +324 -32
- package/dist/git/add.d.ts +9 -0
- package/dist/git/add.js +11 -0
- package/dist/git/add.js.map +1 -0
- package/dist/git/apply.d.ts +33 -0
- package/dist/git/apply.js +103 -0
- package/dist/git/apply.js.map +1 -0
- package/dist/git/authentication.d.ts +5 -0
- package/dist/git/authentication.js +19 -0
- package/dist/git/authentication.js.map +1 -0
- package/dist/git/branch.d.ts +43 -0
- package/dist/git/branch.js +150 -0
- package/dist/git/branch.js.map +1 -0
- package/dist/git/checkout-index.d.ts +19 -0
- package/{src/git/checkout-index.ts → dist/git/checkout-index.js} +11 -22
- package/dist/git/checkout-index.js.map +1 -0
- package/dist/git/checkout.d.ts +46 -0
- package/dist/git/checkout.js +126 -0
- package/dist/git/checkout.js.map +1 -0
- package/dist/git/cherry-pick.d.ts +82 -0
- package/dist/git/cherry-pick.js +371 -0
- package/dist/git/cherry-pick.js.map +1 -0
- package/dist/git/clean.d.ts +5 -0
- package/dist/git/clean.js +8 -0
- package/dist/git/clean.js.map +1 -0
- package/dist/git/clone.d.ts +22 -0
- package/dist/git/clone.js +58 -0
- package/dist/git/clone.js.map +1 -0
- package/dist/git/coerce-to-buffer.d.ts +1 -0
- package/dist/git/coerce-to-buffer.js +2 -0
- package/dist/git/coerce-to-buffer.js.map +1 -0
- package/dist/git/coerce-to-string.d.ts +1 -0
- package/dist/git/coerce-to-string.js +2 -0
- package/dist/git/coerce-to-string.js.map +1 -0
- package/dist/git/commit.d.ts +25 -0
- package/dist/git/commit.js +99 -0
- package/dist/git/commit.js.map +1 -0
- package/dist/git/config.d.ts +98 -0
- package/dist/git/config.js +249 -0
- package/dist/git/config.js.map +1 -0
- package/dist/git/core.d.ts +167 -0
- package/dist/git/core.js +368 -0
- package/dist/git/core.js.map +1 -0
- package/dist/git/create-tail-stream.d.ts +4 -0
- package/dist/git/create-tail-stream.js +30 -0
- package/dist/git/create-tail-stream.js.map +1 -0
- package/dist/git/credential.d.ts +5 -0
- package/dist/git/credential.js +64 -0
- package/dist/git/credential.js.map +1 -0
- package/dist/git/description.d.ts +5 -0
- package/dist/git/description.js +24 -0
- package/dist/git/description.js.map +1 -0
- package/dist/git/diff-check.d.ts +7 -0
- package/dist/git/diff-check.js +17 -0
- package/dist/git/diff-check.js.map +1 -0
- package/dist/git/diff-index.d.ts +31 -0
- package/dist/git/diff-index.js +76 -0
- package/dist/git/diff-index.js.map +1 -0
- package/dist/git/diff.d.ts +81 -0
- package/dist/git/diff.js +611 -0
- package/dist/git/diff.js.map +1 -0
- package/dist/git/environment.d.ts +51 -0
- package/dist/git/environment.js +97 -0
- package/dist/git/environment.js.map +1 -0
- package/dist/git/exec.d.ts +109 -0
- package/dist/git/exec.js +224 -0
- package/dist/git/exec.js.map +1 -0
- package/dist/git/fetch.d.ts +25 -0
- package/dist/git/fetch.js +100 -0
- package/dist/git/fetch.js.map +1 -0
- package/dist/git/for-each-ref.d.ts +13 -0
- package/dist/git/for-each-ref.js +114 -0
- package/dist/git/for-each-ref.js.map +1 -0
- package/dist/git/format-patch.d.ts +10 -0
- package/dist/git/format-patch.js +16 -0
- package/dist/git/format-patch.js.map +1 -0
- package/dist/git/git-delimiter-parser.d.ts +38 -0
- package/dist/git/git-delimiter-parser.js +79 -0
- package/dist/git/git-delimiter-parser.js.map +1 -0
- package/dist/git/gitignore.d.ts +26 -0
- package/dist/git/gitignore.js +124 -0
- package/dist/git/gitignore.js.map +1 -0
- package/dist/git/index.d.ts +46 -0
- package/dist/git/index.js +47 -0
- package/dist/git/index.js.map +1 -0
- package/dist/git/init.d.ts +2 -0
- package/dist/git/init.js +7 -0
- package/dist/git/init.js.map +1 -0
- package/{src/git/interpret-trailers.ts → dist/git/interpret-trailers.d.ts} +9 -97
- package/dist/git/interpret-trailers.js +130 -0
- package/dist/git/interpret-trailers.js.map +1 -0
- package/dist/git/lfs.d.ts +25 -0
- package/dist/git/lfs.js +73 -0
- package/dist/git/lfs.js.map +1 -0
- package/dist/git/log.d.ts +56 -0
- package/dist/git/log.js +258 -0
- package/dist/git/log.js.map +1 -0
- package/dist/git/merge-tree.d.ts +13 -0
- package/dist/git/merge-tree.js +24 -0
- package/dist/git/merge-tree.js.map +1 -0
- package/dist/git/merge.d.ts +50 -0
- package/dist/git/merge.js +111 -0
- package/dist/git/merge.js.map +1 -0
- package/dist/git/multi-operation-terminal-output.d.ts +20 -0
- package/dist/git/multi-operation-terminal-output.js +56 -0
- package/dist/git/multi-operation-terminal-output.js.map +1 -0
- package/dist/git/pull.d.ts +24 -0
- package/dist/git/pull.js +91 -0
- package/dist/git/pull.js.map +1 -0
- package/{src/git/push-terminal-chunk.ts → dist/git/push-terminal-chunk.d.ts} +1 -23
- package/dist/git/push-terminal-chunk.js +36 -0
- package/dist/git/push-terminal-chunk.js.map +1 -0
- package/dist/git/push.d.ts +42 -0
- package/dist/git/push.js +80 -0
- package/dist/git/push.js.map +1 -0
- package/dist/git/rebase.d.ts +119 -0
- package/dist/git/rebase.js +415 -0
- package/dist/git/rebase.js.map +1 -0
- package/dist/git/reflog.d.ts +14 -0
- package/dist/git/reflog.js +88 -0
- package/dist/git/reflog.js.map +1 -0
- package/dist/git/refs.d.ts +26 -0
- package/dist/git/refs.js +53 -0
- package/dist/git/refs.js.map +1 -0
- package/dist/git/remote.d.ts +31 -0
- package/dist/git/remote.js +81 -0
- package/dist/git/remote.js.map +1 -0
- package/dist/git/reorder.d.ts +23 -0
- package/dist/git/reorder.js +111 -0
- package/dist/git/reorder.js.map +1 -0
- package/dist/git/reset.d.ts +41 -0
- package/dist/git/reset.js +86 -0
- package/dist/git/reset.js.map +1 -0
- package/dist/git/rev-list.d.ts +67 -0
- package/dist/git/rev-list.js +157 -0
- package/dist/git/rev-list.js.map +1 -0
- package/dist/git/rev-parse.d.ts +24 -0
- package/dist/git/rev-parse.js +65 -0
- package/dist/git/rev-parse.js.map +1 -0
- package/dist/git/revert.d.ts +12 -0
- package/dist/git/revert.js +30 -0
- package/dist/git/revert.js.map +1 -0
- package/dist/git/rm.d.ts +12 -0
- package/dist/git/rm.js +22 -0
- package/dist/git/rm.js.map +1 -0
- package/dist/git/show.d.ts +42 -0
- package/{src/git/show.ts → dist/git/show.js} +17 -46
- package/dist/git/show.js.map +1 -0
- package/dist/git/spawn.d.ts +18 -0
- package/dist/git/spawn.js +16 -0
- package/dist/git/spawn.js.map +1 -0
- package/dist/git/squash.d.ts +28 -0
- package/dist/git/squash.js +127 -0
- package/dist/git/squash.js.map +1 -0
- package/dist/git/stage.d.ts +21 -0
- package/dist/git/stage.js +72 -0
- package/dist/git/stage.js.map +1 -0
- package/dist/git/stash.d.ts +53 -0
- package/dist/git/stash.js +204 -0
- package/dist/git/stash.js.map +1 -0
- package/dist/git/status.d.ts +39 -0
- package/dist/git/status.js +293 -0
- package/dist/git/status.js.map +1 -0
- package/dist/git/submodule.d.ts +20 -0
- package/dist/git/submodule.js +153 -0
- package/dist/git/submodule.js.map +1 -0
- package/dist/git/tag.d.ts +32 -0
- package/dist/git/tag.js +101 -0
- package/dist/git/tag.js.map +1 -0
- package/dist/git/update-index.d.ts +11 -0
- package/dist/git/update-index.js +99 -0
- package/dist/git/update-index.js.map +1 -0
- package/dist/git/update-ref.d.ts +23 -0
- package/{src/git/update-ref.ts → dist/git/update-ref.js} +10 -28
- package/dist/git/update-ref.js.map +1 -0
- package/dist/git/var.d.ts +18 -0
- package/{src/git/var.ts → dist/git/var.js} +16 -25
- package/dist/git/var.js.map +1 -0
- package/dist/git/worktree-include.d.ts +42 -0
- package/dist/git/worktree-include.js +109 -0
- package/dist/git/worktree-include.js.map +1 -0
- package/dist/git/worktree.d.ts +25 -0
- package/dist/git/worktree.js +139 -0
- package/dist/git/worktree.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +2 -0
- package/dist/lib/api.js +7 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/diff-parser.d.ts +20 -0
- package/dist/lib/diff-parser.js +184 -0
- package/dist/lib/diff-parser.js.map +1 -0
- package/dist/lib/directory-exists.d.ts +1 -0
- package/dist/lib/directory-exists.js +11 -0
- package/dist/lib/directory-exists.js.map +1 -0
- package/dist/lib/errno-exception.d.ts +6 -0
- package/dist/lib/errno-exception.js +6 -0
- package/dist/lib/errno-exception.js.map +1 -0
- package/dist/lib/fatal-error.d.ts +4 -0
- package/dist/lib/fatal-error.js +18 -0
- package/dist/lib/fatal-error.js.map +1 -0
- package/dist/lib/feature-flag.d.ts +14 -0
- package/dist/lib/feature-flag.js +25 -0
- package/dist/lib/feature-flag.js.map +1 -0
- package/dist/lib/file-system.d.ts +1 -0
- package/dist/lib/file-system.js +7 -0
- package/dist/lib/file-system.js.map +1 -0
- package/dist/lib/get-old-path.d.ts +2 -0
- package/dist/lib/get-old-path.js +9 -0
- package/dist/lib/get-old-path.js.map +1 -0
- package/dist/lib/git/environment.d.ts +3 -0
- package/dist/lib/git/environment.js +7 -0
- package/dist/lib/git/environment.js.map +1 -0
- package/dist/lib/git-perf.d.ts +1 -0
- package/dist/lib/git-perf.js +4 -0
- package/dist/lib/git-perf.js.map +1 -0
- package/dist/lib/helpers/default-branch.d.ts +1 -0
- package/dist/lib/helpers/default-branch.js +4 -0
- package/dist/lib/helpers/default-branch.js.map +1 -0
- package/dist/lib/helpers/path.d.ts +1 -0
- package/dist/lib/helpers/path.js +5 -0
- package/dist/lib/helpers/path.js.map +1 -0
- package/dist/lib/hooks/with-hooks-env.d.ts +3 -0
- package/dist/lib/hooks/with-hooks-env.js +4 -0
- package/dist/lib/hooks/with-hooks-env.js.map +1 -0
- package/dist/lib/merge.d.ts +1 -0
- package/dist/lib/merge.js +4 -0
- package/dist/lib/merge.js.map +1 -0
- package/dist/lib/noop.d.ts +1 -0
- package/dist/lib/noop.js +2 -0
- package/dist/lib/noop.js.map +1 -0
- package/dist/lib/patch-formatter.d.ts +5 -0
- package/dist/lib/patch-formatter.js +7 -0
- package/dist/lib/patch-formatter.js.map +1 -0
- package/dist/lib/path-exists.d.ts +1 -0
- package/dist/lib/path-exists.js +3 -0
- package/dist/lib/path-exists.js.map +1 -0
- package/dist/lib/progress/from-process.d.ts +2 -0
- package/dist/lib/progress/from-process.js +4 -0
- package/dist/lib/progress/from-process.js.map +1 -0
- package/dist/lib/progress/index.d.ts +49 -0
- package/dist/lib/progress/index.js +32 -0
- package/dist/lib/progress/index.js.map +1 -0
- package/dist/lib/progress/revert.d.ts +8 -0
- package/dist/lib/progress/revert.js +15 -0
- package/dist/lib/progress/revert.js.map +1 -0
- package/dist/lib/rebase.d.ts +1 -0
- package/dist/lib/rebase.js +4 -0
- package/dist/lib/rebase.js.map +1 -0
- package/dist/lib/remove-remote-prefix.d.ts +1 -0
- package/dist/lib/remove-remote-prefix.js +5 -0
- package/dist/lib/remove-remote-prefix.js.map +1 -0
- package/dist/lib/resolve-git-proxy.d.ts +1 -0
- package/dist/lib/resolve-git-proxy.js +4 -0
- package/dist/lib/resolve-git-proxy.js.map +1 -0
- package/dist/lib/round.d.ts +1 -0
- package/dist/lib/round.js +5 -0
- package/dist/lib/round.js.map +1 -0
- package/dist/lib/split-buffer.d.ts +1 -0
- package/dist/lib/split-buffer.js +15 -0
- package/dist/lib/split-buffer.js.map +1 -0
- package/dist/lib/status-parser.d.ts +19 -0
- package/dist/lib/status-parser.js +125 -0
- package/dist/lib/status-parser.js.map +1 -0
- package/dist/lib/stores/helpers/find-default-remote.d.ts +1 -0
- package/dist/lib/stores/helpers/find-default-remote.js +4 -0
- package/dist/lib/stores/helpers/find-default-remote.js.map +1 -0
- package/dist/lib/trampoline/trampoline-environment.d.ts +1 -0
- package/dist/lib/trampoline/trampoline-environment.js +4 -0
- package/dist/lib/trampoline/trampoline-environment.js.map +1 -0
- package/dist/models/branch.d.ts +44 -0
- package/dist/models/branch.js +59 -0
- package/dist/models/branch.js.map +1 -0
- package/dist/models/cherry-pick.d.ts +11 -0
- package/dist/models/cherry-pick.js +2 -0
- package/dist/models/cherry-pick.js.map +1 -0
- package/dist/models/clone-options.d.ts +6 -0
- package/dist/models/clone-options.js +2 -0
- package/dist/models/clone-options.js.map +1 -0
- package/dist/models/commit-identity.d.ts +9 -0
- package/dist/models/commit-identity.js +34 -0
- package/dist/models/commit-identity.js.map +1 -0
- package/dist/models/commit.d.ts +30 -0
- package/dist/models/commit.js +32 -0
- package/dist/models/commit.js.map +1 -0
- package/dist/models/computed-action.d.ts +6 -0
- package/dist/models/computed-action.js +8 -0
- package/dist/models/computed-action.js.map +1 -0
- package/dist/models/diff/diff-data.d.ts +53 -0
- package/dist/models/diff/diff-data.js +19 -0
- package/dist/models/diff/diff-data.js.map +1 -0
- package/dist/models/diff/diff-line.d.ts +18 -0
- package/dist/models/diff/diff-line.js +33 -0
- package/dist/models/diff/diff-line.js.map +1 -0
- package/dist/models/diff/diff-selection.d.ts +22 -0
- package/dist/models/diff/diff-selection.js +127 -0
- package/dist/models/diff/diff-selection.js.map +1 -0
- package/dist/models/diff/image-diff.d.ts +6 -0
- package/dist/models/diff/image-diff.js +8 -0
- package/dist/models/diff/image-diff.js.map +1 -0
- package/dist/models/diff/image.d.ts +7 -0
- package/dist/models/diff/image.js +13 -0
- package/dist/models/diff/image.js.map +1 -0
- package/dist/models/diff/index.d.ts +6 -0
- package/dist/models/diff/index.js +7 -0
- package/dist/models/diff/index.js.map +1 -0
- package/dist/models/diff/raw-diff.d.ts +32 -0
- package/dist/models/diff/raw-diff.js +38 -0
- package/dist/models/diff/raw-diff.js.map +1 -0
- package/dist/models/git-author.d.ts +7 -0
- package/dist/models/git-author.js +18 -0
- package/dist/models/git-author.js.map +1 -0
- package/dist/models/index.d.ts +21 -0
- package/dist/models/index.js +20 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/manual-conflict-resolution.d.ts +4 -0
- package/dist/models/manual-conflict-resolution.js +6 -0
- package/dist/models/manual-conflict-resolution.js.map +1 -0
- package/dist/models/merge.d.ts +6 -0
- package/dist/models/merge.js +2 -0
- package/dist/models/merge.js.map +1 -0
- package/dist/models/multi-commit-operation.d.ts +6 -0
- package/dist/models/multi-commit-operation.js +8 -0
- package/dist/models/multi-commit-operation.js.map +1 -0
- package/dist/models/progress.d.ts +41 -0
- package/dist/models/progress.js +7 -0
- package/dist/models/progress.js.map +1 -0
- package/dist/models/rebase.d.ts +17 -0
- package/dist/models/rebase.js +8 -0
- package/dist/models/rebase.js.map +1 -0
- package/dist/models/remote.d.ts +5 -0
- package/dist/models/remote.js +8 -0
- package/dist/models/remote.js.map +1 -0
- package/dist/models/repository.d.ts +7 -0
- package/dist/models/repository.js +15 -0
- package/dist/models/repository.js.map +1 -0
- package/dist/models/stash-entry.d.ts +20 -0
- package/dist/models/stash-entry.js +7 -0
- package/dist/models/stash-entry.js.map +1 -0
- package/dist/models/status.d.ts +166 -0
- package/dist/models/status.js +135 -0
- package/dist/models/status.js.map +1 -0
- package/dist/models/submodule.d.ts +12 -0
- package/dist/models/submodule.js +2 -0
- package/dist/models/submodule.js.map +1 -0
- package/dist/models/worktree.d.ts +10 -0
- package/dist/models/worktree.js +2 -0
- package/dist/models/worktree.js.map +1 -0
- package/package.json +44 -5
- package/examples/get-status.ts +0 -84
- package/src/git/add.ts +0 -16
- package/src/git/apply.ts +0 -154
- package/src/git/authentication.ts +0 -19
- package/src/git/branch.ts +0 -206
- package/src/git/checkout.ts +0 -235
- package/src/git/cherry-pick.ts +0 -504
- package/src/git/clean.ts +0 -9
- package/src/git/clone.ts +0 -86
- package/src/git/coerce-to-buffer.ts +0 -4
- package/src/git/coerce-to-string.ts +0 -4
- package/src/git/commit.ts +0 -136
- package/src/git/config.ts +0 -392
- package/src/git/core.ts +0 -625
- package/src/git/create-tail-stream.ts +0 -36
- package/src/git/credential.ts +0 -83
- package/src/git/description.ts +0 -33
- package/src/git/diff-check.ts +0 -27
- package/src/git/diff-index.ts +0 -116
- package/src/git/diff.ts +0 -880
- package/src/git/environment.ts +0 -116
- package/src/git/exec.ts +0 -285
- package/src/git/fetch.ts +0 -141
- package/src/git/for-each-ref.ts +0 -160
- package/src/git/format-patch.ts +0 -17
- package/src/git/git-delimiter-parser.ts +0 -95
- package/src/git/gitignore.ts +0 -157
- package/src/git/index.ts +0 -36
- package/src/git/init.ts +0 -11
- package/src/git/lfs.ts +0 -100
- package/src/git/log.ts +0 -376
- package/src/git/merge-tree.ts +0 -42
- package/src/git/merge.ts +0 -154
- package/src/git/multi-operation-terminal-output.ts +0 -68
- package/src/git/pull.ts +0 -130
- package/src/git/push.ts +0 -119
- package/src/git/rebase.ts +0 -627
- package/src/git/reflog.ts +0 -127
- package/src/git/refs.ts +0 -63
- package/src/git/remote.ts +0 -143
- package/src/git/reorder.ts +0 -153
- package/src/git/reset.ts +0 -101
- package/src/git/rev-list.ts +0 -201
- package/src/git/rev-parse.ts +0 -92
- package/src/git/revert.ts +0 -55
- package/src/git/rm.ts +0 -31
- package/src/git/spawn.ts +0 -38
- package/src/git/squash.ts +0 -173
- package/src/git/stage.ts +0 -97
- package/src/git/stash.ts +0 -302
- package/src/git/status.ts +0 -502
- package/src/git/submodule.ts +0 -212
- package/src/git/tag.ts +0 -134
- package/src/git/update-index.ts +0 -169
- package/src/git/worktree-include.ts +0 -146
- package/src/git/worktree.ts +0 -219
- package/src/index.ts +0 -23
- package/src/lib/api.ts +0 -7
- package/src/lib/diff-parser.ts +0 -249
- package/src/lib/directory-exists.ts +0 -10
- package/src/lib/errno-exception.ts +0 -12
- package/src/lib/fatal-error.ts +0 -23
- package/src/lib/feature-flag.ts +0 -29
- package/src/lib/file-system.ts +0 -7
- package/src/lib/get-old-path.ts +0 -11
- package/src/lib/git/environment.ts +0 -14
- package/src/lib/git-perf.ts +0 -3
- package/src/lib/helpers/default-branch.ts +0 -3
- package/src/lib/helpers/path.ts +0 -5
- package/src/lib/hooks/with-hooks-env.ts +0 -7
- package/src/lib/merge.ts +0 -3
- package/src/lib/noop.ts +0 -1
- package/src/lib/patch-formatter.ts +0 -18
- package/src/lib/path-exists.ts +0 -7
- package/src/lib/progress/from-process.ts +0 -10
- package/src/lib/progress/index.ts +0 -43
- package/src/lib/progress/revert.ts +0 -17
- package/src/lib/rebase.ts +0 -3
- package/src/lib/remove-remote-prefix.ts +0 -4
- package/src/lib/resolve-git-proxy.ts +0 -3
- package/src/lib/round.ts +0 -4
- package/src/lib/split-buffer.ts +0 -14
- package/src/lib/status-parser.ts +0 -188
- package/src/lib/stores/helpers/find-default-remote.ts +0 -3
- package/src/lib/trampoline/trampoline-environment.ts +0 -8
- package/src/models/branch.ts +0 -78
- package/src/models/cherry-pick.ts +0 -12
- package/src/models/clone-options.ts +0 -6
- package/src/models/commit-identity.ts +0 -35
- package/src/models/commit.ts +0 -44
- package/src/models/computed-action.ts +0 -6
- package/src/models/diff/diff-data.ts +0 -78
- package/src/models/diff/diff-line.ts +0 -36
- package/src/models/diff/diff-selection.ts +0 -165
- package/src/models/diff/image-diff.ts +0 -6
- package/src/models/diff/image.ts +0 -8
- package/src/models/diff/index.ts +0 -6
- package/src/models/diff/raw-diff.ts +0 -41
- package/src/models/git-author.ts +0 -16
- package/src/models/manual-conflict-resolution.ts +0 -4
- package/src/models/merge.ts +0 -6
- package/src/models/multi-commit-operation.ts +0 -6
- package/src/models/progress.ts +0 -67
- package/src/models/rebase.ts +0 -20
- package/src/models/remote.ts +0 -10
- package/src/models/repository.ts +0 -16
- package/src/models/stash-entry.ts +0 -25
- package/src/models/status.ts +0 -275
- package/src/models/submodule.ts +0 -13
- package/src/models/worktree.ts +0 -11
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { directoryExists } from '../lib/directory-exists.js';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
/**
|
|
5
|
+
* Attempts to fulfill the work of isGitRepository and isBareRepository while
|
|
6
|
+
* requiring only one Git process to be spawned.
|
|
7
|
+
*
|
|
8
|
+
* Returns 'bare', 'regular', or 'missing' if the repository couldn't be
|
|
9
|
+
* found.
|
|
10
|
+
*/
|
|
11
|
+
export async function getRepositoryType(path) {
|
|
12
|
+
if (!(await directoryExists(path))) {
|
|
13
|
+
return { kind: 'missing' };
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const result = await git(['rev-parse', '--is-bare-repository', '--show-cdup', '--git-dir'], path, 'getRepositoryType', { successExitCodes: new Set([0, 128]) });
|
|
17
|
+
if (result.exitCode === 0) {
|
|
18
|
+
// Bare repositories will not include gitdir so we handle that separately
|
|
19
|
+
if (result.stdout.startsWith('true\n')) {
|
|
20
|
+
return { kind: 'bare' };
|
|
21
|
+
}
|
|
22
|
+
// --is-bare-repository and --show-cdup each produce a single line but
|
|
23
|
+
// --git-dir could theoretically contain newlines so we parse the known
|
|
24
|
+
// fields first and treat the remainder as the git dir. We use [\s\S]*
|
|
25
|
+
// instead of .* for the git dir capture group because .* doesn't match
|
|
26
|
+
// newlines whereas [\s\S]* matches any character including newlines.
|
|
27
|
+
const match = result.stdout.match(/^(true|false)\n(.*)\n([\s\S]*)\n$/);
|
|
28
|
+
if (match) {
|
|
29
|
+
const [, isBare, cdup, gitDir] = match;
|
|
30
|
+
return isBare === 'true'
|
|
31
|
+
? { kind: 'bare' }
|
|
32
|
+
: {
|
|
33
|
+
kind: 'regular',
|
|
34
|
+
topLevelWorkingDirectory: resolve(path, cdup),
|
|
35
|
+
gitDir: resolve(path, gitDir),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const unsafeMatch = /fatal: detected dubious ownership in repository at '(.+)'/.exec(result.stderr);
|
|
40
|
+
if (unsafeMatch) {
|
|
41
|
+
return { kind: 'unsafe', path: unsafeMatch[1] };
|
|
42
|
+
}
|
|
43
|
+
return { kind: 'missing' };
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err?.code === 'ENOENT') {
|
|
47
|
+
return { kind: 'missing' };
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export async function getUpstreamRefForRef(path, ref) {
|
|
53
|
+
const rev = (ref ?? '') + '@{upstream}';
|
|
54
|
+
const args = ['rev-parse', '--symbolic-full-name', rev];
|
|
55
|
+
const opts = { successExitCodes: new Set([0, 128]) };
|
|
56
|
+
const result = await git(args, path, 'getUpstreamRefForRef', opts);
|
|
57
|
+
return result.exitCode === 0 ? result.stdout.trim() : null;
|
|
58
|
+
}
|
|
59
|
+
export async function getUpstreamRemoteNameForRef(path, ref) {
|
|
60
|
+
const remoteRef = await getUpstreamRefForRef(path, ref);
|
|
61
|
+
return remoteRef?.match(/^refs\/remotes\/([^/]+)\//)?.[1] ?? null;
|
|
62
|
+
}
|
|
63
|
+
export const getCurrentUpstreamRef = (path) => getUpstreamRefForRef(path);
|
|
64
|
+
export const getCurrentUpstreamRemoteName = (path) => getUpstreamRemoteNameForRef(path);
|
|
65
|
+
//# sourceMappingURL=rev-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rev-parse.js","sourceRoot":"","sources":["../../src/git/rev-parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAQ9B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,IAAI,CAAC,CAAC,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC5B,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,CAAC,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,CAAC,EACjE,I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E,IAAI,EAAE,SAAS,EAAE,CAAA;QAC5B,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAY,EAAE,GAAY;IACnE,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,aAAa,CAAA;IACvC,MAAM,IAAI,GAAG,CAAC,WAAW,EAAE,sBAAsB,EAAE,GAAG,CAAC,CAAA;IACvD,MAAM,IAAI,GAAG,EAAE,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAA;IACpD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAA;IAElE,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,IAAY,EAAE,GAAY;IAC1E,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACvD,OAAO,SAAS,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE,CACpD,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3D,2BAA2B,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { Commit } from '../models/commit.js';
|
|
3
|
+
import { IRevertProgress } from '../models/progress.js';
|
|
4
|
+
import { IRemote } from '../models/remote.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new commit that reverts the changes of a previous commit
|
|
7
|
+
*
|
|
8
|
+
* @param repository - The repository to update
|
|
9
|
+
*
|
|
10
|
+
* @param commit - The SHA of the commit to be reverted
|
|
11
|
+
*/
|
|
12
|
+
export declare function revertCommit(repository: Repository, commit: Commit, currentRemote: IRemote | null, progressCallback?: (progress: IRevertProgress) => void): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { executionOptionsWithProgress } from '../lib/progress/from-process.js';
|
|
3
|
+
import { RevertProgressParser } from '../lib/progress/revert.js';
|
|
4
|
+
import { envForRemoteOperation, getFallbackUrlForProxyResolve, } from './environment.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new commit that reverts the changes of a previous commit
|
|
7
|
+
*
|
|
8
|
+
* @param repository - The repository to update
|
|
9
|
+
*
|
|
10
|
+
* @param commit - The SHA of the commit to be reverted
|
|
11
|
+
*/
|
|
12
|
+
export async function revertCommit(repository, commit, currentRemote, progressCallback) {
|
|
13
|
+
const args = ['revert'];
|
|
14
|
+
if (commit.parentSHAs.length > 1) {
|
|
15
|
+
args.push('-m', '1');
|
|
16
|
+
}
|
|
17
|
+
args.push(commit.sha);
|
|
18
|
+
let opts = {};
|
|
19
|
+
if (progressCallback) {
|
|
20
|
+
const env = await envForRemoteOperation(getFallbackUrlForProxyResolve(repository, currentRemote));
|
|
21
|
+
opts = await executionOptionsWithProgress({ env, trackLFSProgress: true }, new RevertProgressParser(), progress => {
|
|
22
|
+
const description = progress.kind === 'progress' ? progress.details.text : progress.text;
|
|
23
|
+
const title = progress.kind === 'progress' ? progress.details.title : '';
|
|
24
|
+
const value = progress.percent;
|
|
25
|
+
progressCallback({ kind: 'revert', description, value, title });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
await git(args, repository.path, 'revert', opts);
|
|
29
|
+
}
|
|
30
|
+
//# s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AO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;YACxE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAA;YAE9B,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QACjE,CAAC,CACF,CAAA;IACH,CAAC;IAED,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAClD,CAAC"}
|
package/dist/git/rm.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { WorkingDirectoryFileChange } from '../models/status.js';
|
|
3
|
+
/**
|
|
4
|
+
* Remove all files from the index
|
|
5
|
+
*
|
|
6
|
+
* @param repository the repository to update
|
|
7
|
+
*/
|
|
8
|
+
export declare function unstageAllFiles(repository: Repository): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Remove conflicted file from working tree and index
|
|
11
|
+
*/
|
|
12
|
+
export declare function removeConflictedFile(repository: Repository, file: WorkingDirectoryFileChange): Promise<void>;
|
package/dist/git/rm.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
/**
|
|
3
|
+
* Remove all files from the index
|
|
4
|
+
*
|
|
5
|
+
* @param repository the repository to update
|
|
6
|
+
*/
|
|
7
|
+
export async function unstageAllFiles(repository) {
|
|
8
|
+
await git(
|
|
9
|
+
// these flags are important:
|
|
10
|
+
// --cached to only remove files from the index
|
|
11
|
+
// -r to recursively remove files, in case files are in folders
|
|
12
|
+
// -f to ignore differences between working directory and index
|
|
13
|
+
// which will block this
|
|
14
|
+
['rm', '--cached', '-r', '-f', '.'], repository.path, 'unstageAllFiles');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Remove conflicted file from working tree and index
|
|
18
|
+
*/
|
|
19
|
+
export async function removeConflictedFile(repository, file) {
|
|
20
|
+
await git(['rm', '--', file.path], repository.path, 'removeConflictedFile');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=rm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rm.js","sourceRoot":"","sources":["../../src/git/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAI/B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAsB;IAC1D,MAAM,GAAG;IACP,6BAA6B;IAC7B,+CAA+C;IAC/C,qEAAqE;IACrE,qEAAqE;IACrE,iCAAiC;IACjC,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EACnC,UAAU,CAAC,IAAI,EACf,iBAAiB,CAClB,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,UAAsB,EACtB,IAAgC;IAEhC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve the binary contents of a blob from the repository at a given
|
|
4
|
+
* reference, commit, or tree.
|
|
5
|
+
*
|
|
6
|
+
* Returns a promise that will produce a Buffer instance containing
|
|
7
|
+
* the binary contents of the blob or an error if the file doesn't
|
|
8
|
+
* exists in the given revision.
|
|
9
|
+
*
|
|
10
|
+
* @param repository - The repository from where to read the blob
|
|
11
|
+
*
|
|
12
|
+
* @param commitish - A commit SHA or some other identifier that
|
|
13
|
+
* ultimately dereferences to a commit/tree.
|
|
14
|
+
*
|
|
15
|
+
* @param path - The file path, relative to the repository
|
|
16
|
+
* root from where to read the blob contents
|
|
17
|
+
*/
|
|
18
|
+
export declare const getBlobContents: (repository: Repository, commitish: string, path: string) => Promise<Buffer<ArrayBufferLike>>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve some or all binary contents of a blob from the repository
|
|
21
|
+
* at a given reference, commit, or tree. This is almost identical
|
|
22
|
+
* to the getBlobContents method except that it supports only reading
|
|
23
|
+
* a maximum number of bytes.
|
|
24
|
+
*
|
|
25
|
+
* Returns a promise that will produce a Buffer instance containing
|
|
26
|
+
* the binary contents of the blob or an error if the file doesn't
|
|
27
|
+
* exists in the given revision.
|
|
28
|
+
*
|
|
29
|
+
* @param repository - The repository from where to read the blob
|
|
30
|
+
*
|
|
31
|
+
* @param commitish - A commit SHA or some other identifier that
|
|
32
|
+
* ultimately dereferences to a commit/tree.
|
|
33
|
+
*
|
|
34
|
+
* @param path - The file path, relative to the repository
|
|
35
|
+
* root from where to read the blob contents
|
|
36
|
+
*
|
|
37
|
+
* @param length - The maximum number of bytes to read from
|
|
38
|
+
* the blob. Note that the number of bytes
|
|
39
|
+
* returned may always be less than this number.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPartialBlobContents(repository: Repository, commitish: string, path: string, length: number): Promise<Buffer | null>;
|
|
42
|
+
export declare function getPartialBlobContentsCatchPathNotInRef(repository: Repository, commitish: string, path: string, length: number): Promise<Buffer | null>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { git, isMaxBufferExceededError } from './core'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { GitError } from './exec'
|
|
5
|
-
import { coerceToBuffer } from './coerce-to-buffer'
|
|
6
|
-
|
|
1
|
+
import { git, isMaxBufferExceededError } from './core.js';
|
|
2
|
+
import { GitError } from './exec.js';
|
|
3
|
+
import { coerceToBuffer } from './coerce-to-buffer.js';
|
|
7
4
|
/**
|
|
8
5
|
* Retrieve the binary contents of a blob from the repository at a given
|
|
9
6
|
* reference, commit, or tree.
|
|
@@ -20,16 +17,10 @@ import { coerceToBuffer } from './coerce-to-buffer'
|
|
|
20
17
|
* @param path - The file path, relative to the repository
|
|
21
18
|
* root from where to read the blob contents
|
|
22
19
|
*/
|
|
23
|
-
export const getBlobContents = (
|
|
24
|
-
repository: Repository,
|
|
25
|
-
commitish: string,
|
|
26
|
-
path: string
|
|
27
|
-
) =>
|
|
28
|
-
git(['show', `${commitish}:${path}`], repository.path, 'getBlobContents', {
|
|
20
|
+
export const getBlobContents = (repository, commitish, path) => git(['show', `${commitish}:${path}`], repository.path, 'getBlobContents', {
|
|
29
21
|
successExitCodes: new Set([0, 1]),
|
|
30
22
|
encoding: 'buffer',
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
}).then(r => r.stdout);
|
|
33
24
|
/**
|
|
34
25
|
* Retrieve some or all binary contents of a blob from the repository
|
|
35
26
|
* at a given reference, commit, or tree. This is almost identical
|
|
@@ -52,37 +43,17 @@ export const getBlobContents = (
|
|
|
52
43
|
* the blob. Note that the number of bytes
|
|
53
44
|
* returned may always be less than this number.
|
|
54
45
|
*/
|
|
55
|
-
export async function getPartialBlobContents(
|
|
56
|
-
|
|
57
|
-
commitish: string,
|
|
58
|
-
path: string,
|
|
59
|
-
length: number
|
|
60
|
-
): Promise<Buffer | null> {
|
|
61
|
-
return getPartialBlobContentsCatchPathNotInRef(
|
|
62
|
-
repository,
|
|
63
|
-
commitish,
|
|
64
|
-
path,
|
|
65
|
-
length
|
|
66
|
-
)
|
|
46
|
+
export async function getPartialBlobContents(repository, commitish, path, length) {
|
|
47
|
+
return getPartialBlobContentsCatchPathNotInRef(repository, commitish, path, length);
|
|
67
48
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return git(args, repository.path, 'getPartialBlobContentsCatchPathNotInRef', {
|
|
78
|
-
maxBuffer: length,
|
|
79
|
-
expectedErrors: new Set([GitError.PathExistsButNotInRef]),
|
|
80
|
-
encoding: 'buffer',
|
|
81
|
-
})
|
|
82
|
-
.then(r =>
|
|
83
|
-
r.gitError === GitError.PathExistsButNotInRef ? null : r.stdout
|
|
84
|
-
)
|
|
85
|
-
.catch(e =>
|
|
86
|
-
isMaxBufferExceededError(e) ? coerceToBuffer(e.stdout) : Promise.reject(e)
|
|
87
|
-
)
|
|
49
|
+
export async function getPartialBlobContentsCatchPathNotInRef(repository, commitish, path, length) {
|
|
50
|
+
const args = ['show', `${commitish}:${path}`];
|
|
51
|
+
return git(args, repository.path, 'getPartialBlobContentsCatchPathNotInRef', {
|
|
52
|
+
maxBuffer: length,
|
|
53
|
+
expectedErrors: new Set([GitError.PathExistsButNotInRef]),
|
|
54
|
+
encoding: 'buffer',
|
|
55
|
+
})
|
|
56
|
+
.then(r => r.gitError === GitError.PathExistsButNotInRef ? null : r.stdout)
|
|
57
|
+
.catch(e => isMaxBufferExceededError(e) ? coerceToBuffer(e.stdout) : Promise.reject(e));
|
|
88
58
|
}
|
|
59
|
+
//# sourceMappingURL=show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../src/git/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAGzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAAsB,EACtB,SAAiB,EACjB,IAAY,EACZ,EAAE,CACF,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,iBAAiB,EAAE;IACxE,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,QAAQ,EAAE,QAAQ;CACnB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,UAAsB,EACtB,SAAiB,EACjB,IAAY,EACZ,MAAc;IAEd,OAAO,uCAAuC,CAC5C,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,CACP,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAC3D,UAAsB,EACtB,SAAiB,EACjB,IAAY,EACZ,MAAc;IAEd,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAA;IAE7C,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,yCAAyC,EAAE;QAC3E,SAAS,EAAE,MAAM;QACjB,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QACzD,QAAQ,EAAE,QAAQ;KACnB,CAAC;SACC,IAAI,CAAC,CAAC,CAAC,EAAE,CACR,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAChE;SACA,KAAK,CAAC,CAAC,CAAC,EAAE,CACT,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAC3E,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IGitSpawnOptions } from './exec.js';
|
|
2
|
+
type SpawnOptions = IGitSpawnOptions & {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the command about to run is part of a background task or not.
|
|
5
|
+
* This affects error handling and UI such as credential prompts.
|
|
6
|
+
*/
|
|
7
|
+
readonly isBackgroundTask?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Spawn a Git process, deferring all processing work to the caller.
|
|
11
|
+
*
|
|
12
|
+
* @param args Array of strings to pass to the Git executable.
|
|
13
|
+
* @param path The path to execute the command from.
|
|
14
|
+
* @param name The name of the operation - for tracing purposes.
|
|
15
|
+
* @param successExitCodes An optional array of exit codes that indicate success.
|
|
16
|
+
*/
|
|
17
|
+
export declare const spawnGit: (args: string[], path: string, name: string, options?: SpawnOptions) => Promise<import("child_process").ChildProcess>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { spawnGit as spawn } from './exec.js';
|
|
2
|
+
import * as GitPerf from '../lib/git-perf.js';
|
|
3
|
+
import { withTrampolineEnv } from '../lib/trampoline/trampoline-environment.js';
|
|
4
|
+
/**
|
|
5
|
+
* Spawn a Git process, deferring all processing work to the caller.
|
|
6
|
+
*
|
|
7
|
+
* @param args Array of strings to pass to the Git executable.
|
|
8
|
+
* @param path The path to execute the command from.
|
|
9
|
+
* @param name The name of the operation - for tracing purposes.
|
|
10
|
+
* @param successExitCodes An optional array of exit codes that indicate success.
|
|
11
|
+
*/
|
|
12
|
+
export const spawnGit = (args, path, name, options) => withTrampolineEnv(trampolineEnv => GitPerf.measure(`${name}: git ${args.join(' ')}`, async () => spawn(args, path, {
|
|
13
|
+
...options,
|
|
14
|
+
env: { ...options?.env, ...trampolineEnv },
|
|
15
|
+
})), path, options?.isBackgroundTask ?? false, options?.env);
|
|
16
|
+
//# sourceMappingURL=spawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/git/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAoB,MAAM,WAAW,CAAA;AAC/D,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAU/E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,OAAsB,EACtB,EAAE,CACF,iBAAiB,CACf,aAAa,CAAC,EAAE,CACd,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE,CAC3D,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE;IAChB,GAAG,OAAO;IACV,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,GAAG,aAAa,EAAE;CAC3C,CAAC,CACH,EACH,IAAI,EACJ,OAAO,EAAE,gBAAgB,IAAI,KAAK,EAClC,OAAO,EAAE,GAAG,CACb,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Commit } from '../models/commit.js';
|
|
2
|
+
import { IMultiCommitOperationProgress } from '../models/progress.js';
|
|
3
|
+
import { Repository } from '../models/repository.js';
|
|
4
|
+
import { RebaseResult } from './rebase.js';
|
|
5
|
+
/**
|
|
6
|
+
* Squashes provided commits by calling interactive rebase.
|
|
7
|
+
*
|
|
8
|
+
* Goal is to replay the commits in order from oldest to newest to reduce
|
|
9
|
+
* conflicts with toSquash commits placed in the log at the location of the
|
|
10
|
+
* squashOnto commit.
|
|
11
|
+
*
|
|
12
|
+
* Example: A user's history from oldest to newest is A, B, C, D, E and they
|
|
13
|
+
* want to squash A and E (toSquash) onto C. Our goal: B, A-C-E, D. Thus,
|
|
14
|
+
* maintaining that A came before C and E came after C, placed in history at the
|
|
15
|
+
* the squashOnto of C.
|
|
16
|
+
*
|
|
17
|
+
* Also means if the last 2 commits in history are A, B, whether user squashes A
|
|
18
|
+
* onto B or B onto A. It will always perform based on log history, thus, B onto
|
|
19
|
+
* A.
|
|
20
|
+
*
|
|
21
|
+
* @param toSquash - commits to squash onto another commit and does not contain the squashOnto commit
|
|
22
|
+
* @param squashOnto - commit to squash the `toSquash` commits onto
|
|
23
|
+
* @param lastRetainedCommitRef - sha of commit before commits in squash or null
|
|
24
|
+
* if commit to be squash is the root (first in history) of the branch
|
|
25
|
+
* @param commitMessage - the first line of the string provided will be the
|
|
26
|
+
* summary and rest the body (similar to commit implementation)
|
|
27
|
+
*/
|
|
28
|
+
export declare function squash(repository: Repository, toSquash: ReadonlyArray<Commit>, squashOnto: Commit, lastRetainedCommitRef: string | null, commitMessage: string, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<RebaseResult>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { appendFile, rm, writeFile } from 'fs/promises';
|
|
2
|
+
import { getCommits, revRange } from './index.js';
|
|
3
|
+
import { MultiCommitOperationKind } from '../models/multi-commit-operation.js';
|
|
4
|
+
import { getTempFilePath } from '../lib/file-system.js';
|
|
5
|
+
import { rebaseInteractive, RebaseResult } from './rebase.js';
|
|
6
|
+
/**
|
|
7
|
+
* Squashes provided commits by calling interactive rebase.
|
|
8
|
+
*
|
|
9
|
+
* Goal is to replay the commits in order from oldest to newest to reduce
|
|
10
|
+
* conflicts with toSquash commits placed in the log at the location of the
|
|
11
|
+
* squashOnto commit.
|
|
12
|
+
*
|
|
13
|
+
* Example: A user's history from oldest to newest is A, B, C, D, E and they
|
|
14
|
+
* want to squash A and E (toSquash) onto C. Our goal: B, A-C-E, D. Thus,
|
|
15
|
+
* maintaining that A came before C and E came after C, placed in history at the
|
|
16
|
+
* the squashOnto of C.
|
|
17
|
+
*
|
|
18
|
+
* Also means if the last 2 commits in history are A, B, whether user squashes A
|
|
19
|
+
* onto B or B onto A. It will always perform based on log history, thus, B onto
|
|
20
|
+
* A.
|
|
21
|
+
*
|
|
22
|
+
* @param toSquash - commits to squash onto another commit and does not contain the squashOnto commit
|
|
23
|
+
* @param squashOnto - commit to squash the `toSquash` commits onto
|
|
24
|
+
* @param lastRetainedCommitRef - sha of commit before commits in squash or null
|
|
25
|
+
* if commit to be squash is the root (first in history) of the branch
|
|
26
|
+
* @param commitMessage - the first line of the string provided will be the
|
|
27
|
+
* summary and rest the body (similar to commit implementation)
|
|
28
|
+
*/
|
|
29
|
+
export async function squash(repository, toSquash, squashOnto, lastRetainedCommitRef, commitMessage, progressCallback) {
|
|
30
|
+
let messagePath, todoPath;
|
|
31
|
+
let result;
|
|
32
|
+
try {
|
|
33
|
+
if (toSquash.length === 0) {
|
|
34
|
+
throw new Error('[squash] No commits provided to squash.');
|
|
35
|
+
}
|
|
36
|
+
const toSquashShas = new Set(toSquash.map(c => c.sha));
|
|
37
|
+
if (toSquashShas.has(squashOnto.sha)) {
|
|
38
|
+
throw new Error('[squash] The commits to squash cannot contain the commit to squash onto.');
|
|
39
|
+
}
|
|
40
|
+
const commits = await getCommits(repository, lastRetainedCommitRef === null
|
|
41
|
+
? undefined
|
|
42
|
+
: revRange(lastRetainedCommitRef, 'HEAD'));
|
|
43
|
+
if (commits.length === 0) {
|
|
44
|
+
throw new Error('[squash] Could not find commits in log for last retained commit ref.');
|
|
45
|
+
}
|
|
46
|
+
todoPath = await getTempFilePath('squashTodo');
|
|
47
|
+
let foundSquashOntoCommitInLog = false;
|
|
48
|
+
const toReplayAtSquash = [];
|
|
49
|
+
const toReplayAfterSquash = [];
|
|
50
|
+
// Traversed in reverse so we do oldest to newest (replay commits)
|
|
51
|
+
for (let i = commits.length - 1; i >= 0; i--) {
|
|
52
|
+
const commit = commits[i];
|
|
53
|
+
if (toSquashShas.has(commit.sha)) {
|
|
54
|
+
// If it is toSquash commit and we have found the squashOnto commit, we
|
|
55
|
+
// can go ahead and squash them (as we will hold any picks till after)
|
|
56
|
+
if (foundSquashOntoCommitInLog) {
|
|
57
|
+
await appendFile(todoPath, `squash ${commit.sha} ${commit.summary}\n`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// However, if we have not found the squashOnto commit yet we want to
|
|
61
|
+
// keep track of them in the order of the log. Thus, we use a new
|
|
62
|
+
// `toReplayAtSquash` array and not trust that what was sent is in the
|
|
63
|
+
// order of the log.
|
|
64
|
+
toReplayAtSquash.push(commit);
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// If it's the squashOnto commit, replay to the toSquash in the order they
|
|
69
|
+
// appeared on the log to reduce potential conflicts.
|
|
70
|
+
if (commit.sha === squashOnto.sha) {
|
|
71
|
+
foundSquashOntoCommitInLog = true;
|
|
72
|
+
toReplayAtSquash.push(commit);
|
|
73
|
+
for (let j = 0; j < toReplayAtSquash.length; j++) {
|
|
74
|
+
const action = j === 0 ? 'pick' : 'squash';
|
|
75
|
+
await appendFile(todoPath, `${action} ${toReplayAtSquash[j].sha} ${toReplayAtSquash[j].summary}\n`);
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// We can't just replay a pick in case there is a commit from the toSquash
|
|
80
|
+
// commits further up in history that need to be replayed with the
|
|
81
|
+
// squashes. Thus, we will keep track of these and replay after traversing
|
|
82
|
+
// the remainder of the log.
|
|
83
|
+
if (foundSquashOntoCommitInLog) {
|
|
84
|
+
toReplayAfterSquash.push(commit);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// If it is not one toSquash nor the squashOnto and have not found the
|
|
88
|
+
// squashOnto commit, we simply record it is an unchanged pick (before the
|
|
89
|
+
// squash)
|
|
90
|
+
await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`);
|
|
91
|
+
}
|
|
92
|
+
if (toReplayAfterSquash.length > 0) {
|
|
93
|
+
for (let i = 0; i < toReplayAfterSquash.length; i++) {
|
|
94
|
+
await appendFile(todoPath, `pick ${toReplayAfterSquash[i].sha} ${toReplayAfterSquash[i].summary}\n`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!foundSquashOntoCommitInLog) {
|
|
98
|
+
throw new Error('[squash] The commit to squash onto was not in the log. Continuing would result in dropping the commits in the toSquash array.');
|
|
99
|
+
}
|
|
100
|
+
if (commitMessage.trim() !== '') {
|
|
101
|
+
messagePath = await getTempFilePath('squashCommitMessage');
|
|
102
|
+
await writeFile(messagePath, commitMessage);
|
|
103
|
+
}
|
|
104
|
+
// if no commit message provided, accept default editor
|
|
105
|
+
const gitEditor = messagePath !== undefined ? `cat "${messagePath}" >` : undefined;
|
|
106
|
+
result = await rebaseInteractive(repository, todoPath, lastRetainedCommitRef, {
|
|
107
|
+
action: MultiCommitOperationKind.Squash,
|
|
108
|
+
gitEditor,
|
|
109
|
+
progressCallback,
|
|
110
|
+
commits: [...toSquash, squashOnto],
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
console.error(e);
|
|
115
|
+
return RebaseResult.Error;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
if (todoPath !== undefined) {
|
|
119
|
+
await rm(todoPath, { recursive: true, force: true });
|
|
120
|
+
}
|
|
121
|
+
if (messagePath !== undefined) {
|
|
122
|
+
await rm(messagePath, { recursive: true, force: true });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=squash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"squash.js","sourceRoot":"","sources":["../../src/git/squash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAG9E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,MAA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EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACtD,CAAC;QAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { WorkingDirectoryFileChange } from '../models/status.js';
|
|
3
|
+
import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
|
|
4
|
+
/**
|
|
5
|
+
* Stages a file with the given manual resolution method. Useful for resolving binary conflicts at commit-time.
|
|
6
|
+
*
|
|
7
|
+
* @param repository
|
|
8
|
+
* @param file conflicted file to stage
|
|
9
|
+
* @param manualResolution method to resolve the conflict of file
|
|
10
|
+
* @returns true if successful, false if something went wrong
|
|
11
|
+
*/
|
|
12
|
+
export declare function stageManualConflictResolution(repository: Repository, file: WorkingDirectoryFileChange, manualResolution: ManualConflictResolution): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Stages all resolved conflict files before a checkout operation to prevent
|
|
15
|
+
* "error: you need to resolve your current index first" from git.
|
|
16
|
+
*
|
|
17
|
+
* Handles two kinds of resolved conflicts:
|
|
18
|
+
* - Text conflicts resolved in an external editor (conflictMarkerCount === 0)
|
|
19
|
+
* - Manual conflicts where the user chose ours/theirs in the Desktop UI
|
|
20
|
+
*/
|
|
21
|
+
export declare function stageResolvedConflictFiles(repository: Repository, files: ReadonlyArray<WorkingDirectoryFileChange>, manualResolutions: ReadonlyMap<string, ManualConflictResolution>): Promise<void>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isConflictedFileStatus, GitStatusEntry, isConflictWithMarkers, } from '../models/status.js';
|
|
2
|
+
import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
|
|
3
|
+
import { assertNever } from '../lib/fatal-error.js';
|
|
4
|
+
import { removeConflictedFile } from './rm.js';
|
|
5
|
+
import { checkoutConflictedFile } from './checkout.js';
|
|
6
|
+
import { addConflictedFile } from './add.js';
|
|
7
|
+
/**
|
|
8
|
+
* Stages a file with the given manual resolution method. Useful for resolving binary conflicts at commit-time.
|
|
9
|
+
*
|
|
10
|
+
* @param repository
|
|
11
|
+
* @param file conflicted file to stage
|
|
12
|
+
* @param manualResolution method to resolve the conflict of file
|
|
13
|
+
* @returns true if successful, false if something went wrong
|
|
14
|
+
*/
|
|
15
|
+
export async function stageManualConflictResolution(repository, file, manualResolution) {
|
|
16
|
+
const { status } = file;
|
|
17
|
+
// if somehow the file isn't in a conflicted state
|
|
18
|
+
if (!isConflictedFileStatus(status)) {
|
|
19
|
+
console.error(`tried to manually resolve unconflicted file (${file.path})`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (isConflictWithMarkers(status) && status.conflictMarkerCount === 0) {
|
|
23
|
+
// If somehow the user used the Desktop UI to solve the conflict via ours/theirs
|
|
24
|
+
// but afterwards resolved manually the conflicts via an editor, used the manually
|
|
25
|
+
// resolved file.
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const chosen = manualResolution === ManualConflictResolution.theirs
|
|
29
|
+
? status.entry.them
|
|
30
|
+
: status.entry.us;
|
|
31
|
+
const addedInBoth = status.entry.us === GitStatusEntry.Added &&
|
|
32
|
+
status.entry.them === GitStatusEntry.Added;
|
|
33
|
+
if (chosen === GitStatusEntry.UpdatedButUnmerged || addedInBoth) {
|
|
34
|
+
await checkoutConflictedFile(repository, file, manualResolution);
|
|
35
|
+
}
|
|
36
|
+
switch (chosen) {
|
|
37
|
+
case GitStatusEntry.Deleted:
|
|
38
|
+
return removeConflictedFile(repository, file);
|
|
39
|
+
case GitStatusEntry.Added:
|
|
40
|
+
case GitStatusEntry.UpdatedButUnmerged:
|
|
41
|
+
return addConflictedFile(repository, file);
|
|
42
|
+
default:
|
|
43
|
+
assertNever(chosen, 'unaccounted for git status entry possibility');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Stages all resolved conflict files before a checkout operation to prevent
|
|
48
|
+
* "error: you need to resolve your current index first" from git.
|
|
49
|
+
*
|
|
50
|
+
* Handles two kinds of resolved conflicts:
|
|
51
|
+
* - Text conflicts resolved in an external editor (conflictMarkerCount === 0)
|
|
52
|
+
* - Manual conflicts where the user chose ours/theirs in the Desktop UI
|
|
53
|
+
*/
|
|
54
|
+
export async function stageResolvedConflictFiles(repository, files, manualResolutions) {
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
const { status } = file;
|
|
57
|
+
if (!isConflictedFileStatus(status)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const manualResolution = manualResolutions.get(file.path);
|
|
61
|
+
if (manualResolution !== undefined) {
|
|
62
|
+
// Binary/manual conflict resolved via Desktop UI — stage it
|
|
63
|
+
await stageManualConflictResolution(repository, file, manualResolution);
|
|
64
|
+
}
|
|
65
|
+
else if (isConflictWithMarkers(status) &&
|
|
66
|
+
status.conflictMarkerCount === 0) {
|
|
67
|
+
// Text conflict resolved in external editor — stage it
|
|
68
|
+
await addConflictedFile(repository, file);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=stage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/git/stage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAA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