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,81 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { GitError } from './exec.js';
|
|
3
|
+
import { envForRemoteOperation } from './environment.js';
|
|
4
|
+
import { getSymbolicRef } from './refs.js';
|
|
5
|
+
import memoizeOne from 'memoize-one';
|
|
6
|
+
/**
|
|
7
|
+
* List the remotes, sorted alphabetically by `name`, for a repository.
|
|
8
|
+
*/
|
|
9
|
+
export async function getRemotes(repository) {
|
|
10
|
+
return memoizedGetRemotesFromPath(repository.path);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List the remotes, sorted alphabetically by `name`, for a repository path.
|
|
14
|
+
*/
|
|
15
|
+
export async function getRemotesFromPath(path) {
|
|
16
|
+
const result = await git(['remote', '-v'], path, 'getRemotes', {
|
|
17
|
+
expectedErrors: new Set([GitError.NotAGitRepository]),
|
|
18
|
+
});
|
|
19
|
+
if (result.gitError === GitError.NotAGitRepository) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return [...result.stdout.matchAll(/^(.+)\t(.+)\s\(fetch\)/gm)].map(([, name, url]) => ({ name, url }));
|
|
23
|
+
}
|
|
24
|
+
export const memoizedGetRemotesFromPath = memoizeOne(getRemotesFromPath);
|
|
25
|
+
/** Add a new remote with the given URL. */
|
|
26
|
+
export async function addRemote(repository, name, url) {
|
|
27
|
+
await git(['remote', 'add', name, url], repository.path, 'addRemote');
|
|
28
|
+
return { url, name };
|
|
29
|
+
}
|
|
30
|
+
/** Removes an existing remote, or silently errors if it doesn't exist */
|
|
31
|
+
export async function removeRemote(repository, name) {
|
|
32
|
+
const options = {
|
|
33
|
+
successExitCodes: new Set([0, 2, 128]),
|
|
34
|
+
};
|
|
35
|
+
await git(['remote', 'remove', name], repository.path, 'removeRemote', options);
|
|
36
|
+
}
|
|
37
|
+
/** Changes the URL for the remote that matches the given name */
|
|
38
|
+
export async function setRemoteURL(repository, name, url) {
|
|
39
|
+
await git(['remote', 'set-url', name, url], repository.path, 'setRemoteURL');
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the URL for the remote that matches the given name.
|
|
44
|
+
*
|
|
45
|
+
* Returns null if the remote could not be found
|
|
46
|
+
*/
|
|
47
|
+
export async function getRemoteURL(repository, name) {
|
|
48
|
+
const result = await git(['remote', 'get-url', name], repository.path, 'getRemoteURL', { successExitCodes: new Set([0, 2, 128]) });
|
|
49
|
+
if (result.exitCode !== 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return result.stdout;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update the HEAD ref of the remote, which is the default branch.
|
|
56
|
+
*
|
|
57
|
+
* @param isBackgroundTask Whether the fetch is being performed as a
|
|
58
|
+
* background task as opposed to being user initiated
|
|
59
|
+
*/
|
|
60
|
+
export async function updateRemoteHEAD(repository, remote, isBackgroundTask) {
|
|
61
|
+
const options = {
|
|
62
|
+
successExitCodes: new Set([0, 1, 128]),
|
|
63
|
+
env: await envForRemoteOperation(remote.url),
|
|
64
|
+
isBackgroundTask,
|
|
65
|
+
};
|
|
66
|
+
await git(['remote', 'set-head', '-a', remote.name], repository.path, 'updateRemoteHEAD', options);
|
|
67
|
+
}
|
|
68
|
+
export async function getRemoteHEAD(repository, remote) {
|
|
69
|
+
const remoteNamespace = `refs/remotes/${remote}/`;
|
|
70
|
+
const match = await getSymbolicRef(repository, `${remoteNamespace}HEAD`);
|
|
71
|
+
if (match != null &&
|
|
72
|
+
match.length > remoteNamespace.length &&
|
|
73
|
+
match.startsWith(remoteNamespace)) {
|
|
74
|
+
// strip out everything related to the remote because this
|
|
75
|
+
// is likely to be a tracked branch locally
|
|
76
|
+
// e.g. `main`, `develop`, etc
|
|
77
|
+
return match.substring(remoteNamespace.length);
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/git/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAA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gB;KACjB,CAAA;IAED,MAAM,GAAG,CACP,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EACzC,UAAU,CAAC,IAAI,EACf,kBAAkB,EAClB,OAAO,CACR,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAsB,EACtB,MAAc;IAEd,MAAM,eAAe,GAAG,gBAAgB,MAAM,GAAG,CAAA;IACjD,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,GAAG,eAAe,MAAM,CAAC,CAAA;IACxE,IACE,KAAK,IAAI,IAAI;QACb,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM;QACrC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,EACjC,CAAC;QACD,0DAA0D;QAC1D,2CAA2C;QAC3C,8BAA8B;QAC9B,OAAO,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
* Reorders 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 toMove commits placed in the log at the location of the
|
|
10
|
+
* prior to the base commit.
|
|
11
|
+
*
|
|
12
|
+
* Example: A user's history from oldest to newest is A, B, C, D, E and they
|
|
13
|
+
* want to move A and E (toMove) before C. Our goal: B, A, E, C, D. Thus,
|
|
14
|
+
* maintaining that A came before E, placed in history before the the base
|
|
15
|
+
* commit C.
|
|
16
|
+
*
|
|
17
|
+
* @param toMove - commits to move
|
|
18
|
+
* @param beforeCommit - commits will be moved right before this commit. If it's
|
|
19
|
+
* null, the commits will be moved to the end of the history.
|
|
20
|
+
* @param lastRetainedCommitRef - sha of commit before commits to reorder or null
|
|
21
|
+
* if base commit for reordering is the root (first in history) of the branch
|
|
22
|
+
*/
|
|
23
|
+
export declare function reorder(repository: Repository, toMove: ReadonlyArray<Commit>, beforeCommit: Commit | null, lastRetainedCommitRef: string | null, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<RebaseResult>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { appendFile, rm } 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
|
+
* Reorders 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 toMove commits placed in the log at the location of the
|
|
11
|
+
* prior to the base commit.
|
|
12
|
+
*
|
|
13
|
+
* Example: A user's history from oldest to newest is A, B, C, D, E and they
|
|
14
|
+
* want to move A and E (toMove) before C. Our goal: B, A, E, C, D. Thus,
|
|
15
|
+
* maintaining that A came before E, placed in history before the the base
|
|
16
|
+
* commit C.
|
|
17
|
+
*
|
|
18
|
+
* @param toMove - commits to move
|
|
19
|
+
* @param beforeCommit - commits will be moved right before this commit. If it's
|
|
20
|
+
* null, the commits will be moved to the end of the history.
|
|
21
|
+
* @param lastRetainedCommitRef - sha of commit before commits to reorder or null
|
|
22
|
+
* if base commit for reordering is the root (first in history) of the branch
|
|
23
|
+
*/
|
|
24
|
+
export async function reorder(repository, toMove, beforeCommit, lastRetainedCommitRef, progressCallback) {
|
|
25
|
+
let todoPath;
|
|
26
|
+
let result;
|
|
27
|
+
try {
|
|
28
|
+
if (toMove.length === 0) {
|
|
29
|
+
throw new Error('[reorder] No commits provided to reorder.');
|
|
30
|
+
}
|
|
31
|
+
const toMoveShas = new Set(toMove.map(c => c.sha));
|
|
32
|
+
const commits = await getCommits(repository, lastRetainedCommitRef === null
|
|
33
|
+
? undefined
|
|
34
|
+
: revRange(lastRetainedCommitRef, 'HEAD'));
|
|
35
|
+
if (commits.length === 0) {
|
|
36
|
+
throw new Error('[reorder] Could not find commits in log for last retained commit ref.');
|
|
37
|
+
}
|
|
38
|
+
todoPath = await getTempFilePath('reorderTodo');
|
|
39
|
+
let foundBaseCommitInLog = false;
|
|
40
|
+
const toReplayBeforeBaseCommit = [];
|
|
41
|
+
const toReplayAfterReorder = [];
|
|
42
|
+
// Traversed in reverse so we do oldest to newest (replay commits)
|
|
43
|
+
for (let i = commits.length - 1; i >= 0; i--) {
|
|
44
|
+
const commit = commits[i];
|
|
45
|
+
if (toMoveShas.has(commit.sha)) {
|
|
46
|
+
// If it is toMove commit and we have found the base commit, we
|
|
47
|
+
// can go ahead and insert them (as we will hold any picks till after)
|
|
48
|
+
if (foundBaseCommitInLog) {
|
|
49
|
+
await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// However, if we have not found the base commit yet we want to
|
|
53
|
+
// keep track of them in the order of the log. Thus, we use a new
|
|
54
|
+
// `toReplayBeforeBaseCommit` array and not trust that what was sent is in the
|
|
55
|
+
// order of the log.
|
|
56
|
+
toReplayBeforeBaseCommit.push(commit);
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
// If it's the base commit, replay to the toMove in the order they
|
|
61
|
+
// appeared on the log to reduce potential conflicts.
|
|
62
|
+
if (beforeCommit !== null && commit.sha === beforeCommit.sha) {
|
|
63
|
+
foundBaseCommitInLog = true;
|
|
64
|
+
toReplayAfterReorder.push(commit);
|
|
65
|
+
for (let j = 0; j < toReplayBeforeBaseCommit.length; j++) {
|
|
66
|
+
await appendFile(todoPath, `pick ${toReplayBeforeBaseCommit[j].sha} ${toReplayBeforeBaseCommit[j].summary}\n`);
|
|
67
|
+
}
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// We can't just replay a pick in case there is a commit from the toMove
|
|
71
|
+
// commits further up in history that need to be moved. Thus, we will keep
|
|
72
|
+
// track of these and replay after traversing the remainder of the log.
|
|
73
|
+
if (foundBaseCommitInLog) {
|
|
74
|
+
toReplayAfterReorder.push(commit);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// If it is not one toMove nor the base commit and have not found the base
|
|
78
|
+
// commit, we simply record it is an unchanged pick (before the base commit)
|
|
79
|
+
await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`);
|
|
80
|
+
}
|
|
81
|
+
if (toReplayAfterReorder.length > 0) {
|
|
82
|
+
for (let i = 0; i < toReplayAfterReorder.length; i++) {
|
|
83
|
+
await appendFile(todoPath, `pick ${toReplayAfterReorder[i].sha} ${toReplayAfterReorder[i].summary}\n`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (beforeCommit === null) {
|
|
87
|
+
for (let i = 0; i < toReplayBeforeBaseCommit.length; i++) {
|
|
88
|
+
await appendFile(todoPath, `pick ${toReplayBeforeBaseCommit[i].sha} ${toReplayBeforeBaseCommit[i].summary}\n`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (!foundBaseCommitInLog) {
|
|
92
|
+
throw new Error('[reorder] The base commit onto was not in the log. Continuing would result in dropping the commits in the toMove array.');
|
|
93
|
+
}
|
|
94
|
+
result = await rebaseInteractive(repository, todoPath, lastRetainedCommitRef, {
|
|
95
|
+
action: MultiCommitOperationKind.Reorder,
|
|
96
|
+
progressCallback,
|
|
97
|
+
commits,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(e);
|
|
102
|
+
return RebaseResult.Error;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
if (todoPath !== undefined) {
|
|
106
|
+
await rm(todoPath, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=reorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reorder.js","sourceRoot":"","sources":["../../src/git/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAC5C,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;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,UAAsB,EACtB,MAA6B,EAC7B,YAA2B,EAC3B,qBAAoC,EACpC,gBAAoE;IAEpE,IAAI,QAAQ,CAAA;IACZ,IAAI,MAAoB,CAAA;IAExB,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;QAC9D,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAElD,MAAM,OAAO,GAAG,MAAM,UAAU,CAC9B,UAAU,EACV,qBAAqB,KAAK,IAAI;YAC5B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAC5C,CAAA;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,M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wB,CAAC,OAAO;YACxC,gBAAgB;YAChB,OAAO;SACR,CACF,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,YAAY,CAAC,KAAK,CAAA;IAC3B,CAAC;YAAS,CAAC;QACT,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
/** The reset modes which are supported. */
|
|
3
|
+
export declare const enum GitResetMode {
|
|
4
|
+
/**
|
|
5
|
+
* Resets the index and working tree. Any changes to tracked files in the
|
|
6
|
+
* working tree since <commit> are discarded.
|
|
7
|
+
*/
|
|
8
|
+
Hard = 0,
|
|
9
|
+
/**
|
|
10
|
+
* Does not touch the index file or the working tree at all (but resets the
|
|
11
|
+
* head to <commit>, just like all modes do). This leaves all your changed
|
|
12
|
+
* files "Changes to be committed", as git status would put it.
|
|
13
|
+
*/
|
|
14
|
+
Soft = 1,
|
|
15
|
+
/**
|
|
16
|
+
* Resets the index but not the working tree (i.e., the changed files are
|
|
17
|
+
* preserved but not marked for commit) and reports what has not been updated.
|
|
18
|
+
* This is the default action for git reset.
|
|
19
|
+
*/
|
|
20
|
+
Mixed = 2
|
|
21
|
+
}
|
|
22
|
+
/** Reset with the mode to the ref. */
|
|
23
|
+
export declare function reset(repository: Repository, mode: GitResetMode, ref: string): Promise<true>;
|
|
24
|
+
/**
|
|
25
|
+
* Updates the index with information from a particular tree for a given
|
|
26
|
+
* set of paths.
|
|
27
|
+
*
|
|
28
|
+
* @param repository The repository in which to reset the index.
|
|
29
|
+
*
|
|
30
|
+
* @param mode Which mode to use when resetting, see the GitResetMode
|
|
31
|
+
* enum for more information.
|
|
32
|
+
*
|
|
33
|
+
* @param ref A string which resolves to a tree, for example 'HEAD' or a
|
|
34
|
+
* commit sha.
|
|
35
|
+
*
|
|
36
|
+
* @param paths The paths that should be updated in the index with information
|
|
37
|
+
* from the given tree
|
|
38
|
+
*/
|
|
39
|
+
export declare function resetPaths(repository: Repository, mode: GitResetMode, ref: string, paths: ReadonlyArray<string>): Promise<void>;
|
|
40
|
+
/** Unstage all paths. */
|
|
41
|
+
export declare function unstageAll(repository: Repository): Promise<true>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { assertNever } from '../lib/fatal-error.js';
|
|
3
|
+
/** The reset modes which are supported. */
|
|
4
|
+
export var GitResetMode;
|
|
5
|
+
(function (GitResetMode) {
|
|
6
|
+
/**
|
|
7
|
+
* Resets the index and working tree. Any changes to tracked files in the
|
|
8
|
+
* working tree since <commit> are discarded.
|
|
9
|
+
*/
|
|
10
|
+
GitResetMode[GitResetMode["Hard"] = 0] = "Hard";
|
|
11
|
+
/**
|
|
12
|
+
* Does not touch the index file or the working tree at all (but resets the
|
|
13
|
+
* head to <commit>, just like all modes do). This leaves all your changed
|
|
14
|
+
* files "Changes to be committed", as git status would put it.
|
|
15
|
+
*/
|
|
16
|
+
GitResetMode[GitResetMode["Soft"] = 1] = "Soft";
|
|
17
|
+
/**
|
|
18
|
+
* Resets the index but not the working tree (i.e., the changed files are
|
|
19
|
+
* preserved but not marked for commit) and reports what has not been updated.
|
|
20
|
+
* This is the default action for git reset.
|
|
21
|
+
*/
|
|
22
|
+
GitResetMode[GitResetMode["Mixed"] = 2] = "Mixed";
|
|
23
|
+
})(GitResetMode || (GitResetMode = {}));
|
|
24
|
+
function resetModeToArgs(mode, ref) {
|
|
25
|
+
switch (mode) {
|
|
26
|
+
case GitResetMode.Hard:
|
|
27
|
+
return ['reset', '--hard', ref];
|
|
28
|
+
case GitResetMode.Mixed:
|
|
29
|
+
return ['reset', ref];
|
|
30
|
+
case GitResetMode.Soft:
|
|
31
|
+
return ['reset', '--soft', ref];
|
|
32
|
+
default:
|
|
33
|
+
return assertNever(mode, `Unknown reset mode: ${mode}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Reset with the mode to the ref. */
|
|
37
|
+
export async function reset(repository, mode, ref) {
|
|
38
|
+
const args = resetModeToArgs(mode, ref);
|
|
39
|
+
await git(args, repository.path, 'reset');
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Updates the index with information from a particular tree for a given
|
|
44
|
+
* set of paths.
|
|
45
|
+
*
|
|
46
|
+
* @param repository The repository in which to reset the index.
|
|
47
|
+
*
|
|
48
|
+
* @param mode Which mode to use when resetting, see the GitResetMode
|
|
49
|
+
* enum for more information.
|
|
50
|
+
*
|
|
51
|
+
* @param ref A string which resolves to a tree, for example 'HEAD' or a
|
|
52
|
+
* commit sha.
|
|
53
|
+
*
|
|
54
|
+
* @param paths The paths that should be updated in the index with information
|
|
55
|
+
* from the given tree
|
|
56
|
+
*/
|
|
57
|
+
export async function resetPaths(repository, mode, ref, paths) {
|
|
58
|
+
if (!paths.length) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const baseArgs = resetModeToArgs(mode, ref);
|
|
62
|
+
if (process.platform === 'win32' && mode === GitResetMode.Mixed) {
|
|
63
|
+
// Git for Windows has experimental support for reading paths to reset
|
|
64
|
+
// from standard input. This is helpful in situations where your file
|
|
65
|
+
// paths are greater than 32KB in length, because of shell limitations.
|
|
66
|
+
//
|
|
67
|
+
// This hasn't made it to Git core, so we fallback to the default behaviour
|
|
68
|
+
// as macOS and Linux don't have this same shell limitation. See
|
|
69
|
+
// https://github.com/desktop/desktop/issues/2833#issuecomment-331352952
|
|
70
|
+
// for more context.
|
|
71
|
+
const args = [...baseArgs, '--stdin', '-z', '--'];
|
|
72
|
+
await git(args, repository.path, 'resetPaths', {
|
|
73
|
+
stdin: paths.join('\0'),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const args = [...baseArgs, '--', ...paths];
|
|
78
|
+
await git(args, repository.path, 'resetPaths');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Unstage all paths. */
|
|
82
|
+
export async function unstageAll(repository) {
|
|
83
|
+
await git(['reset', '--', '.'], repository.path, 'unstageAll');
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../src/git/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,2CAA2C;AAC3C,MAAM,CAAN,IAAkB,YAmBjB;AAnBD,WAAkB,YAAY;IAC5B;;;OAGG;IACH,+CAAQ,CAAA;IACR;;;;OAIG;IACH,+CAAI,CAAA;IAEJ;;;;OAIG;IACH,iDAAK,CAAA;AACP,CAAC,EAnBiB,YAAY,KAAZ,YAAY,QAmB7B;AAED,SAAS,eAAe,CAAC,IAAkB,EAAE,GAAW;IACtD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;QACjC,KAAK,YAAY,CAAC,KAAK;YACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACvB,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;QACjC;YACE,OAAO,WAAW,CAAC,IAAI,EAAE,uBAAuB,IAAI,EAAE,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAED,sCAAsC;AACtC,MAAM,CAAC,KAAK,UAAU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E,IAAI,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IAC9D,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { Branch, IAheadBehind } from '../models/branch.js';
|
|
3
|
+
import { CommitOneLine } from '../models/commit.js';
|
|
4
|
+
/**
|
|
5
|
+
* Convert two refs into the Git range syntax representing the set of commits
|
|
6
|
+
* that are reachable from `to` but excluding those that are reachable from
|
|
7
|
+
* `from`. This will not be inclusive to the `from` ref, see
|
|
8
|
+
* `revRangeInclusive`.
|
|
9
|
+
*
|
|
10
|
+
* Each parameter can be the commit SHA or a ref name, or specify an empty
|
|
11
|
+
* string to represent HEAD.
|
|
12
|
+
*
|
|
13
|
+
* @param from The start of the range
|
|
14
|
+
* @param to The end of the range
|
|
15
|
+
*/
|
|
16
|
+
export declare function revRange(from: string, to: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Convert two refs into the Git range syntax representing the set of commits
|
|
19
|
+
* that are reachable from `to` but excluding those that are reachable from
|
|
20
|
+
* `from`. However as opposed to `revRange`, this will also include `from` ref.
|
|
21
|
+
*
|
|
22
|
+
* Each parameter can be the commit SHA or a ref name, or specify an empty
|
|
23
|
+
* string to represent HEAD.
|
|
24
|
+
*
|
|
25
|
+
* @param from The start of the range
|
|
26
|
+
* @param to The end of the range
|
|
27
|
+
*/
|
|
28
|
+
export declare function revRangeInclusive(from: string, to: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Convert two refs into the Git symmetric difference syntax, which represents
|
|
31
|
+
* the set of commits that are reachable from either `from` or `to` but not
|
|
32
|
+
* from both.
|
|
33
|
+
*
|
|
34
|
+
* Each parameter can be the commit SHA or a ref name, or you can use an empty
|
|
35
|
+
* string to represent HEAD.
|
|
36
|
+
*
|
|
37
|
+
* @param from The start of the range
|
|
38
|
+
* @param to The end of the range
|
|
39
|
+
*/
|
|
40
|
+
export declare function revSymmetricDifference(from: string, to: string): string;
|
|
41
|
+
/** Calculate the number of commits the range is ahead and behind. */
|
|
42
|
+
export declare function getAheadBehind(repository: Repository, range: string): Promise<IAheadBehind | null>;
|
|
43
|
+
/** Calculate the number of commits `branch` is ahead/behind its upstream. */
|
|
44
|
+
export declare function getBranchAheadBehind(repository: Repository, branch: Branch): Promise<IAheadBehind | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Get a list of commits from the target branch that do not exist on the base
|
|
47
|
+
* branch, ordered how they will be applied to the base branch.
|
|
48
|
+
* Therefore, this will not include the baseBranchSha commit.
|
|
49
|
+
*
|
|
50
|
+
* This emulates how `git rebase` initially determines what will be applied to
|
|
51
|
+
* the repository.
|
|
52
|
+
*
|
|
53
|
+
* Returns `null` when the rebase is not possible to perform, because of a
|
|
54
|
+
* missing commit ID
|
|
55
|
+
*/
|
|
56
|
+
export declare function getCommitsBetweenCommits(repository: Repository, baseBranchSha: string, targetBranchSha: string): Promise<ReadonlyArray<CommitOneLine> | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Get a list of commits inside the provided range.
|
|
59
|
+
*
|
|
60
|
+
* Returns `null` when it is not possible to perform because of a bad range.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getCommitsInRange(repository: Repository, range: string): Promise<ReadonlyArray<CommitOneLine> | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Determine if merge commits exist in history after given commit
|
|
65
|
+
* If commitRef is null, goes back to HEAD of branch.
|
|
66
|
+
*/
|
|
67
|
+
export declare function doMergeCommitsExistAfterCommit(repository: Repository, commitRef: string | null): Promise<boolean>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { GitError } from './exec.js';
|
|
2
|
+
import { git } from './core.js';
|
|
3
|
+
import { BranchType } from '../models/branch.js';
|
|
4
|
+
/**
|
|
5
|
+
* Convert two refs into the Git range syntax representing the set of commits
|
|
6
|
+
* that are reachable from `to` but excluding those that are reachable from
|
|
7
|
+
* `from`. This will not be inclusive to the `from` ref, see
|
|
8
|
+
* `revRangeInclusive`.
|
|
9
|
+
*
|
|
10
|
+
* Each parameter can be the commit SHA or a ref name, or specify an empty
|
|
11
|
+
* string to represent HEAD.
|
|
12
|
+
*
|
|
13
|
+
* @param from The start of the range
|
|
14
|
+
* @param to The end of the range
|
|
15
|
+
*/
|
|
16
|
+
export function revRange(from, to) {
|
|
17
|
+
return `${from}..${to}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert two refs into the Git range syntax representing the set of commits
|
|
21
|
+
* that are reachable from `to` but excluding those that are reachable from
|
|
22
|
+
* `from`. However as opposed to `revRange`, this will also include `from` ref.
|
|
23
|
+
*
|
|
24
|
+
* Each parameter can be the commit SHA or a ref name, or specify an empty
|
|
25
|
+
* string to represent HEAD.
|
|
26
|
+
*
|
|
27
|
+
* @param from The start of the range
|
|
28
|
+
* @param to The end of the range
|
|
29
|
+
*/
|
|
30
|
+
export function revRangeInclusive(from, to) {
|
|
31
|
+
return `${from}^..${to}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert two refs into the Git symmetric difference syntax, which represents
|
|
35
|
+
* the set of commits that are reachable from either `from` or `to` but not
|
|
36
|
+
* from both.
|
|
37
|
+
*
|
|
38
|
+
* Each parameter can be the commit SHA or a ref name, or you can use an empty
|
|
39
|
+
* string to represent HEAD.
|
|
40
|
+
*
|
|
41
|
+
* @param from The start of the range
|
|
42
|
+
* @param to The end of the range
|
|
43
|
+
*/
|
|
44
|
+
export function revSymmetricDifference(from, to) {
|
|
45
|
+
return `${from}...${to}`;
|
|
46
|
+
}
|
|
47
|
+
/** Calculate the number of commits the range is ahead and behind. */
|
|
48
|
+
export async function getAheadBehind(repository, range) {
|
|
49
|
+
// `--left-right` annotates the list of commits in the range with which side
|
|
50
|
+
// they're coming from. When used with `--count`, it tells us how many
|
|
51
|
+
// commits we have from the two different sides of the range.
|
|
52
|
+
const args = ['rev-list', '--left-right', '--count', range, '--'];
|
|
53
|
+
const result = await git(args, repository.path, 'getAheadBehind', {
|
|
54
|
+
expectedErrors: new Set([GitError.BadRevision]),
|
|
55
|
+
});
|
|
56
|
+
// This means one of the refs (most likely the upstream branch) no longer
|
|
57
|
+
// exists. In that case we can't be ahead/behind at all.
|
|
58
|
+
if (result.gitError === GitError.BadRevision) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const stdout = result.stdout;
|
|
62
|
+
const pieces = stdout.split('\t');
|
|
63
|
+
if (pieces.length !== 2) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const ahead = parseInt(pieces[0], 10);
|
|
67
|
+
if (isNaN(ahead)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const behind = parseInt(pieces[1], 10);
|
|
71
|
+
if (isNaN(behind)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return { ahead, behind };
|
|
75
|
+
}
|
|
76
|
+
/** Calculate the number of commits `branch` is ahead/behind its upstream. */
|
|
77
|
+
export async function getBranchAheadBehind(repository, branch) {
|
|
78
|
+
if (branch.type === BranchType.Remote) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const upstream = branch.upstream;
|
|
82
|
+
if (!upstream) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
// NB: The three dot form means we'll go all the way back to the merge base
|
|
86
|
+
// of the branch and its upstream. Practically this is important for seeing
|
|
87
|
+
// "through" merges.
|
|
88
|
+
const range = revSymmetricDifference(branch.name, upstream);
|
|
89
|
+
return getAheadBehind(repository, range);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get a list of commits from the target branch that do not exist on the base
|
|
93
|
+
* branch, ordered how they will be applied to the base branch.
|
|
94
|
+
* Therefore, this will not include the baseBranchSha commit.
|
|
95
|
+
*
|
|
96
|
+
* This emulates how `git rebase` initially determines what will be applied to
|
|
97
|
+
* the repository.
|
|
98
|
+
*
|
|
99
|
+
* Returns `null` when the rebase is not possible to perform, because of a
|
|
100
|
+
* missing commit ID
|
|
101
|
+
*/
|
|
102
|
+
export async function getCommitsBetweenCommits(repository, baseBranchSha, targetBranchSha) {
|
|
103
|
+
const range = revRange(baseBranchSha, targetBranchSha);
|
|
104
|
+
return getCommitsInRange(repository, range);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get a list of commits inside the provided range.
|
|
108
|
+
*
|
|
109
|
+
* Returns `null` when it is not possible to perform because of a bad range.
|
|
110
|
+
*/
|
|
111
|
+
export async function getCommitsInRange(repository, range) {
|
|
112
|
+
const args = [
|
|
113
|
+
'rev-list',
|
|
114
|
+
range,
|
|
115
|
+
'--reverse',
|
|
116
|
+
// the combination of these two arguments means each line of the stdout
|
|
117
|
+
// will contain the full commit sha and a commit summary
|
|
118
|
+
`--oneline`,
|
|
119
|
+
`--no-abbrev-commit`,
|
|
120
|
+
'--',
|
|
121
|
+
];
|
|
122
|
+
const options = {
|
|
123
|
+
expectedErrors: new Set([GitError.BadRevision]),
|
|
124
|
+
};
|
|
125
|
+
const result = await git(args, repository.path, 'getCommitsInRange', options);
|
|
126
|
+
if (result.gitError === GitError.BadRevision) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const lines = result.stdout.split('\n');
|
|
130
|
+
const commits = new Array();
|
|
131
|
+
const commitSummaryRe = /^([a-z0-9]{40}) (.*)$/;
|
|
132
|
+
for (const line of lines) {
|
|
133
|
+
const match = commitSummaryRe.exec(line);
|
|
134
|
+
if (match !== null && match.length === 3) {
|
|
135
|
+
const sha = match[1];
|
|
136
|
+
const summary = match[2];
|
|
137
|
+
commits.push({
|
|
138
|
+
sha,
|
|
139
|
+
summary,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return commits;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Determine if merge commits exist in history after given commit
|
|
147
|
+
* If commitRef is null, goes back to HEAD of branch.
|
|
148
|
+
*/
|
|
149
|
+
export async function doMergeCommitsExistAfterCommit(repository, commitRef) {
|
|
150
|
+
const revision = commitRef === null ? 'HEAD' : revRange(commitRef, 'HEAD');
|
|
151
|
+
const args = ['rev-list', '-1', '--merges', revision, '--'];
|
|
152
|
+
return git(args, repository.path, 'doMergeCommitsExistAfterCommit', {
|
|
153
|
+
// 128 here means there's no HEAD, i.e we're on an unborn branch
|
|
154
|
+
successExitCodes: new Set([0, 128]),
|
|
155
|
+
}).then(x => x.stdout.length > 0);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=rev-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rev-list.js","sourceRoot":"","sources":["../../src/git/rev-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAU,UAAU,EAAgB,MAAM,qBAAqB,CAAA;AAGtE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,EAAU;IAC/C,OAAO,GAAG,IAAI,KAAK,EAAE,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,EAAU;IACxD,OAAO,GAAG,IAAI,MAAM,EAAE,EAAE,CAAA;AAC1B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,EAAU;IAC7D,OAAO,GAAG,IAAI,MAAM,EAAE,EAAE,CAAA;AAC1B,CAAC;AAED,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAsB,EACtB,KAAa;IAEb,4EAA4E;IAC5E,sEAAsE;IACtE,6DAA6D;IAC7D,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,IAA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AI,CAAC,CAAA;QAExC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YACpB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YAExB,OAAO,CAAC,IAAI,CAAC;gBACX,GAAG;gBACH,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,UAAsB,EACtB,SAAwB;IAExB,MAAM,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAC1E,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;IAE3D,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,gCAAgC,EAAE;QAClE,gEAAgE;QAChE,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;KACpC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type RepositoryType = {
|
|
2
|
+
kind: 'bare';
|
|
3
|
+
} | {
|
|
4
|
+
kind: 'regular';
|
|
5
|
+
topLevelWorkingDirectory: string;
|
|
6
|
+
gitDir: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'missing';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'unsafe';
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Attempts to fulfill the work of isGitRepository and isBareRepository while
|
|
15
|
+
* requiring only one Git process to be spawned.
|
|
16
|
+
*
|
|
17
|
+
* Returns 'bare', 'regular', or 'missing' if the repository couldn't be
|
|
18
|
+
* found.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getRepositoryType(path: string): Promise<RepositoryType>;
|
|
21
|
+
export declare function getUpstreamRefForRef(path: string, ref?: string): Promise<string | null>;
|
|
22
|
+
export declare function getUpstreamRemoteNameForRef(path: string, ref?: string): Promise<string | null>;
|
|
23
|
+
export declare const getCurrentUpstreamRef: (path: string) => Promise<string | null>;
|
|
24
|
+
export declare const getCurrentUpstreamRemoteName: (path: string) => Promise<string | null>;
|