git-chopstick-core 0.1.0 → 0.1.2
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/LICENSE +1 -1
- 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/dist/git/checkout-index.js +29 -0
- 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/dist/git/interpret-trailers.d.ts +88 -0
- 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/dist/git/push-terminal-chunk.d.ts +19 -0
- 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/dist/git/show.js +59 -0
- 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/dist/git/update-ref.js +32 -0
- package/dist/git/update-ref.js.map +1 -0
- package/dist/git/var.d.ts +18 -0
- package/dist/git/var.js +33 -0
- 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 +137 -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 +17 -2
- package/src/git/add.ts +3 -3
- package/src/git/apply.ts +8 -8
- package/src/git/authentication.ts +3 -2
- package/src/git/branch.ts +10 -10
- package/src/git/checkout-index.ts +2 -2
- package/src/git/checkout.ts +12 -12
- package/src/git/cherry-pick.ts +16 -16
- package/src/git/clean.ts +2 -2
- package/src/git/clone.ts +6 -6
- package/src/git/commit.ts +7 -7
- package/src/git/config.ts +2 -2
- package/src/git/core.ts +8 -8
- package/src/git/credential.ts +1 -1
- package/src/git/diff-check.ts +1 -1
- package/src/git/diff-index.ts +2 -2
- package/src/git/diff.ts +18 -18
- package/src/git/environment.ts +5 -5
- package/src/git/fetch.ts +7 -7
- package/src/git/for-each-ref.ts +5 -5
- package/src/git/format-patch.ts +3 -3
- package/src/git/git-delimiter-parser.ts +1 -1
- package/src/git/gitignore.ts +2 -2
- package/src/git/index.ts +46 -36
- package/src/git/init.ts +2 -2
- package/src/git/interpret-trailers.ts +3 -3
- package/src/git/lfs.ts +2 -2
- package/src/git/log.ts +8 -8
- package/src/git/merge-tree.ts +5 -5
- package/src/git/merge.ts +5 -5
- package/src/git/multi-operation-terminal-output.ts +3 -3
- package/src/git/pull.ts +7 -7
- package/src/git/push-terminal-chunk.ts +1 -1
- package/src/git/push.ts +7 -7
- package/src/git/rebase.ts +16 -16
- package/src/git/reflog.ts +2 -2
- package/src/git/refs.ts +2 -2
- package/src/git/remote.ts +6 -6
- package/src/git/reorder.ts +7 -7
- package/src/git/reset.ts +3 -3
- package/src/git/rev-list.ts +5 -5
- package/src/git/rev-parse.ts +2 -2
- package/src/git/revert.ts +8 -8
- package/src/git/rm.ts +3 -3
- package/src/git/show.ts +4 -4
- package/src/git/spawn.ts +3 -3
- package/src/git/squash.ts +7 -7
- package/src/git/stage.ts +7 -7
- package/src/git/stash.ts +10 -10
- package/src/git/status.ts +13 -13
- package/src/git/submodule.ts +9 -9
- package/src/git/tag.ts +4 -4
- package/src/git/update-index.ts +5 -5
- package/src/git/update-ref.ts +2 -2
- package/src/git/var.ts +3 -3
- package/src/git/worktree-include.ts +3 -3
- package/src/git/worktree.ts +4 -4
- package/src/index.ts +11 -0
- package/src/lib/diff-parser.ts +2 -2
- package/src/lib/get-old-path.ts +1 -1
- package/src/lib/git/environment.ts +1 -1
- package/src/lib/patch-formatter.ts +3 -3
- package/src/lib/progress/from-process.ts +1 -1
- package/src/lib/progress/index.ts +1 -1
- package/src/lib/status-parser.ts +2 -2
- package/src/models/branch.ts +1 -1
- package/src/models/cherry-pick.ts +2 -2
- package/src/models/commit.ts +1 -1
- package/src/models/diff/diff-data.ts +3 -3
- package/src/models/diff/index.ts +6 -6
- package/src/models/diff/raw-diff.ts +1 -1
- package/src/models/index.ts +36 -0
- package/src/models/rebase.ts +2 -2
- package/src/models/stash-entry.ts +1 -1
- package/src/models/status.ts +1 -1
- package/examples/get-status.ts +0 -84
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { IRemote } from '../models/remote.js';
|
|
3
|
+
/**
|
|
4
|
+
* For many remote operations it's well known what the primary remote
|
|
5
|
+
* url is (clone, push, fetch etc). But in some cases it's not as easy.
|
|
6
|
+
*
|
|
7
|
+
* Two examples are checkout, and revert where neither would need to
|
|
8
|
+
* hit the network in vanilla Git usage but do need to when LFS gets
|
|
9
|
+
* involved.
|
|
10
|
+
*
|
|
11
|
+
* What's the primary url when using LFS then? Most likely it's gonna
|
|
12
|
+
* be on the same as the default remote but it could theoretically
|
|
13
|
+
* be on a different server as well. That's too advanced for our usage
|
|
14
|
+
* at the moment though so we'll just need to figure out some reasonable
|
|
15
|
+
* url to fall back on.
|
|
16
|
+
*
|
|
17
|
+
* @param branchName If the operation we're about to undertake is related to a
|
|
18
|
+
* local ref (i.e branch) then we can use that to resolve its
|
|
19
|
+
* upstream tracking branch (and thereby its remote) and use
|
|
20
|
+
* that as the probable url to resolve a proxy for.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getFallbackUrlForProxyResolve(_repository: Repository, currentRemote: IRemote | null): string;
|
|
23
|
+
/**
|
|
24
|
+
* Create a set of environment variables to use when invoking a Git
|
|
25
|
+
* subcommand that needs to communicate with a remote (i.e. fetch, clone,
|
|
26
|
+
* push, pull, ls-remote, etc etc).
|
|
27
|
+
*
|
|
28
|
+
* The environment variables deal with setting up sane defaults, configuring
|
|
29
|
+
* authentication, and resolving proxy urls if necessary.
|
|
30
|
+
*
|
|
31
|
+
* @param account The authentication information (if available) to provide
|
|
32
|
+
* to Git for use when connecting to the remote
|
|
33
|
+
* @param remoteUrl The primary remote URL for this operation. Note that Git
|
|
34
|
+
* might connect to other remotes in order to fulfill the
|
|
35
|
+
* operation. As an example, a clone of
|
|
36
|
+
* https://github.com/desktop/desktop could contain a submodule
|
|
37
|
+
* pointing to another host entirely. Used to resolve which
|
|
38
|
+
* proxy (if any) should be used for the operation.
|
|
39
|
+
*/
|
|
40
|
+
export declare function envForRemoteOperation(remoteUrl: string | null): Promise<Record<string, string | undefined>>;
|
|
41
|
+
/**
|
|
42
|
+
* Not intended to be used directly. Exported only in order to
|
|
43
|
+
* allow for testing.
|
|
44
|
+
*
|
|
45
|
+
* @param remoteUrl The remote url to resolve a proxy for.
|
|
46
|
+
* @param env The current environment variables, defaults
|
|
47
|
+
* to `process.env`
|
|
48
|
+
* @param resolve The method to use when resolving the proxy url,
|
|
49
|
+
* defaults to `resolveGitProxy`
|
|
50
|
+
*/
|
|
51
|
+
export declare function envForProxy(remoteUrl: string, env?: NodeJS.ProcessEnv, resolve?: (url: string) => Promise<string | undefined>): Promise<Record<string, string | undefined> | undefined>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { envForAuthentication } from './authentication.js';
|
|
2
|
+
import { resolveGitProxy as resolveGitProxyFn } from '../lib/resolve-git-proxy.js';
|
|
3
|
+
/**
|
|
4
|
+
* For many remote operations it's well known what the primary remote
|
|
5
|
+
* url is (clone, push, fetch etc). But in some cases it's not as easy.
|
|
6
|
+
*
|
|
7
|
+
* Two examples are checkout, and revert where neither would need to
|
|
8
|
+
* hit the network in vanilla Git usage but do need to when LFS gets
|
|
9
|
+
* involved.
|
|
10
|
+
*
|
|
11
|
+
* What's the primary url when using LFS then? Most likely it's gonna
|
|
12
|
+
* be on the same as the default remote but it could theoretically
|
|
13
|
+
* be on a different server as well. That's too advanced for our usage
|
|
14
|
+
* at the moment though so we'll just need to figure out some reasonable
|
|
15
|
+
* url to fall back on.
|
|
16
|
+
*
|
|
17
|
+
* @param branchName If the operation we're about to undertake is related to a
|
|
18
|
+
* local ref (i.e branch) then we can use that to resolve its
|
|
19
|
+
* upstream tracking branch (and thereby its remote) and use
|
|
20
|
+
* that as the probable url to resolve a proxy for.
|
|
21
|
+
*/
|
|
22
|
+
export function getFallbackUrlForProxyResolve(_repository, currentRemote) {
|
|
23
|
+
if (currentRemote) {
|
|
24
|
+
return currentRemote.url;
|
|
25
|
+
}
|
|
26
|
+
return 'https://github.com';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a set of environment variables to use when invoking a Git
|
|
30
|
+
* subcommand that needs to communicate with a remote (i.e. fetch, clone,
|
|
31
|
+
* push, pull, ls-remote, etc etc).
|
|
32
|
+
*
|
|
33
|
+
* The environment variables deal with setting up sane defaults, configuring
|
|
34
|
+
* authentication, and resolving proxy urls if necessary.
|
|
35
|
+
*
|
|
36
|
+
* @param account The authentication information (if available) to provide
|
|
37
|
+
* to Git for use when connecting to the remote
|
|
38
|
+
* @param remoteUrl The primary remote URL for this operation. Note that Git
|
|
39
|
+
* might connect to other remotes in order to fulfill the
|
|
40
|
+
* operation. As an example, a clone of
|
|
41
|
+
* https://github.com/desktop/desktop could contain a submodule
|
|
42
|
+
* pointing to another host entirely. Used to resolve which
|
|
43
|
+
* proxy (if any) should be used for the operation.
|
|
44
|
+
*/
|
|
45
|
+
export async function envForRemoteOperation(remoteUrl) {
|
|
46
|
+
return {
|
|
47
|
+
...envForAuthentication(),
|
|
48
|
+
...(await envForProxy(remoteUrl ?? 'https://github.com')),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Not intended to be used directly. Exported only in order to
|
|
53
|
+
* allow for testing.
|
|
54
|
+
*
|
|
55
|
+
* @param remoteUrl The remote url to resolve a proxy for.
|
|
56
|
+
* @param env The current environment variables, defaults
|
|
57
|
+
* to `process.env`
|
|
58
|
+
* @param resolve The method to use when resolving the proxy url,
|
|
59
|
+
* defaults to `resolveGitProxy`
|
|
60
|
+
*/
|
|
61
|
+
export async function envForProxy(remoteUrl, env = process.env, resolve = async (url) => resolveGitProxyFn() ?? undefined) {
|
|
62
|
+
const protocolMatch = /^(https?):\/\//i.exec(remoteUrl);
|
|
63
|
+
// We can only resolve and use a proxy for the protocols where cURL
|
|
64
|
+
// would be involved (i.e http and https). git:// relies on ssh.
|
|
65
|
+
if (protocolMatch === null) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Note that HTTPS here doesn't mean that the proxy is HTTPS, only
|
|
69
|
+
// that all requests to HTTPS protocols should be proxied. The
|
|
70
|
+
// proxy protocol is defined by the url returned by `this.resolve()`
|
|
71
|
+
const proto = protocolMatch[1].toLowerCase(); // http or https
|
|
72
|
+
// We'll play it safe and say that if the user has configured
|
|
73
|
+
// the ALL_PROXY environment variable they probably know what
|
|
74
|
+
// they're doing and wouldn't want us to override it with a
|
|
75
|
+
// protocol-specific proxy. cURL supports both lower and upper
|
|
76
|
+
// case, see:
|
|
77
|
+
// https://github.com/curl/curl/blob/14916a82e/lib/url.c#L2180-L2185
|
|
78
|
+
if ('ALL_PROXY' in env || 'all_proxy' in env) {
|
|
79
|
+
console.info(`proxy url not resolved, ALL_PROXY already set`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Lower case environment variables due to
|
|
83
|
+
// https://ec.haxx.se/usingcurl/usingcurl-proxies#http_proxy-in-lower-case-only
|
|
84
|
+
const envKey = `${proto}_proxy`; // http_proxy or https_proxy
|
|
85
|
+
// If the user has already configured a proxy in the environment
|
|
86
|
+
// for the protocol we're not gonna override it.
|
|
87
|
+
if (envKey in env || (proto === 'https' && 'HTTPS_PROXY' in env)) {
|
|
88
|
+
console.info(`proxy url not resolved, ${envKey} already set`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const proxyUrl = await resolve(remoteUrl).catch(err => {
|
|
92
|
+
console.error('Failed resolving Git proxy', err);
|
|
93
|
+
return undefined;
|
|
94
|
+
});
|
|
95
|
+
return proxyUrl === undefined ? undefined : { [envKey]: proxyUrl };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/git/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qB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E,MAAM,MAAM,GAAG,GAAG,KAAK,QAAQ,CAAA,CAAC,4BAA4B;IAE5D,gEAAgE;IAChE,gDAAgD;IAChD,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,KAAK,OAAO,IAAI,aAAa,IAAI,GAAG,CAAC,EAAE,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,2BAA2B,MAAM,cAAc,CAAC,CAAA;QAC7D,OAAM;IACR,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACpD,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;QAChD,OAAO,SAAS,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { SpawnOptions } from 'child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Git error types parsed from stderr output.
|
|
4
|
+
* This is a simplified version of dugite's GitError enum.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum GitError {
|
|
7
|
+
SSHAuthenticationFailed = "SSHAuthenticationFailed",
|
|
8
|
+
SSHPermissionDenied = "SSHPermissionDenied",
|
|
9
|
+
HTTPSAuthenticationFailed = "HTTPSAuthenticationFailed",
|
|
10
|
+
SSHKeyAuditUnverified = "SSHKeyAuditUnverified",
|
|
11
|
+
RemoteDisconnection = "RemoteDisconnection",
|
|
12
|
+
HostDown = "HostDown",
|
|
13
|
+
HTTPSRepositoryNotFound = "HTTPSRepositoryNotFound",
|
|
14
|
+
SSHRepositoryNotFound = "SSHRepositoryNotFound",
|
|
15
|
+
PushNotFastForward = "PushNotFastForward",
|
|
16
|
+
PushWithFileSizeExceedingLimit = "PushWithFileSizeExceedingLimit",
|
|
17
|
+
PushWithPrivateEmail = "PushWithPrivateEmail",
|
|
18
|
+
PushWithSecretDetected = "PushWithSecretDetected",
|
|
19
|
+
ForcePushRejected = "ForcePushRejected",
|
|
20
|
+
ProtectedBranchForcePush = "ProtectedBranchForcePush",
|
|
21
|
+
ProtectedBranchRequiresReview = "ProtectedBranchRequiresReview",
|
|
22
|
+
ProtectedBranchDeleteRejected = "ProtectedBranchDeleteRejected",
|
|
23
|
+
ProtectedBranchRequiredStatus = "ProtectedBranchRequiredStatus",
|
|
24
|
+
BranchDeletionFailed = "BranchDeletionFailed",
|
|
25
|
+
DefaultBranchDeletionFailed = "DefaultBranchDeletionFailed",
|
|
26
|
+
BranchAlreadyExists = "BranchAlreadyExists",
|
|
27
|
+
BranchRenameFailed = "BranchRenameFailed",
|
|
28
|
+
HexBranchNameRejected = "HexBranchNameRejected",
|
|
29
|
+
InvalidRefLength = "InvalidRefLength",
|
|
30
|
+
MergeConflicts = "MergeConflicts",
|
|
31
|
+
RebaseConflicts = "RebaseConflicts",
|
|
32
|
+
MergeWithLocalChanges = "MergeWithLocalChanges",
|
|
33
|
+
RebaseWithLocalChanges = "RebaseWithLocalChanges",
|
|
34
|
+
InvalidMerge = "InvalidMerge",
|
|
35
|
+
InvalidRebase = "InvalidRebase",
|
|
36
|
+
NonFastForwardMergeIntoEmptyHead = "NonFastForwardMergeIntoEmptyHead",
|
|
37
|
+
CannotMergeUnrelatedHistories = "CannotMergeUnrelatedHistories",
|
|
38
|
+
NoMergeToAbort = "NoMergeToAbort",
|
|
39
|
+
RevertConflicts = "RevertConflicts",
|
|
40
|
+
EmptyRebasePatch = "EmptyRebasePatch",
|
|
41
|
+
NothingToCommit = "NothingToCommit",
|
|
42
|
+
GPGFailedToSignData = "GPGFailedToSignData",
|
|
43
|
+
BadConfigValue = "BadConfigValue",
|
|
44
|
+
ConfigLockFileAlreadyExists = "ConfigLockFileAlreadyExists",
|
|
45
|
+
NotAGitRepository = "NotAGitRepository",
|
|
46
|
+
BadRevision = "BadRevision",
|
|
47
|
+
LocalPermissionDenied = "LocalPermissionDenied",
|
|
48
|
+
NoMatchingRemoteBranch = "NoMatchingRemoteBranch",
|
|
49
|
+
NoExistingRemoteBranch = "NoExistingRemoteBranch",
|
|
50
|
+
PatchDoesNotApply = "PatchDoesNotApply",
|
|
51
|
+
NoSubmoduleMapping = "NoSubmoduleMapping",
|
|
52
|
+
SubmoduleRepositoryDoesNotExist = "SubmoduleRepositoryDoesNotExist",
|
|
53
|
+
InvalidSubmoduleSHA = "InvalidSubmoduleSHA",
|
|
54
|
+
LockFileAlreadyExists = "LockFileAlreadyExists",
|
|
55
|
+
UnresolvedConflicts = "UnresolvedConflicts",
|
|
56
|
+
LocalChangesOverwritten = "LocalChangesOverwritten",
|
|
57
|
+
RemoteAlreadyExists = "RemoteAlreadyExists",
|
|
58
|
+
TagAlreadyExists = "TagAlreadyExists",
|
|
59
|
+
PathDoesNotExist = "PathDoesNotExist",
|
|
60
|
+
InvalidObjectName = "InvalidObjectName",
|
|
61
|
+
OutsideRepository = "OutsideRepository",
|
|
62
|
+
ConflictModifyDeletedInBranch = "ConflictModifyDeletedInBranch",
|
|
63
|
+
MergeCommitNoMainlineOption = "MergeCommitNoMainlineOption",
|
|
64
|
+
UnsafeDirectory = "UnsafeDirectory",
|
|
65
|
+
PathExistsButNotInRef = "PathExistsButNotInRef",
|
|
66
|
+
LFSAttributeDoesNotMatch = "LFSAttributeDoesNotMatch"
|
|
67
|
+
}
|
|
68
|
+
export declare class ExecError extends Error {
|
|
69
|
+
readonly code: string;
|
|
70
|
+
readonly stdout: string | Buffer;
|
|
71
|
+
readonly stderr: string | Buffer;
|
|
72
|
+
readonly cause?: Error;
|
|
73
|
+
constructor(message: string, stdout: string | Buffer, stderr: string | Buffer, cause?: Error);
|
|
74
|
+
}
|
|
75
|
+
export interface IGitResult {
|
|
76
|
+
readonly stdout: string | Buffer;
|
|
77
|
+
readonly stderr: string | Buffer;
|
|
78
|
+
readonly exitCode: number;
|
|
79
|
+
}
|
|
80
|
+
export interface IGitExecutionOptions {
|
|
81
|
+
readonly env?: Record<string, string | undefined>;
|
|
82
|
+
readonly cwd?: string;
|
|
83
|
+
readonly stdin?: string;
|
|
84
|
+
readonly maxBuffer?: number;
|
|
85
|
+
readonly processCallback?: (process: any) => void;
|
|
86
|
+
readonly encoding?: BufferEncoding;
|
|
87
|
+
}
|
|
88
|
+
export interface IGitSpawnOptions extends SpawnOptions {
|
|
89
|
+
readonly stdin?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Execute a git command and return the result.
|
|
93
|
+
*/
|
|
94
|
+
export declare function exec(args: string[], path: string, options?: IGitExecutionOptions): Promise<IGitResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Spawn a git process, returning the ChildProcess for streaming access.
|
|
97
|
+
*/
|
|
98
|
+
export declare function spawnGit(args: string[], path: string, options?: IGitSpawnOptions): import("child_process").ChildProcess;
|
|
99
|
+
/**
|
|
100
|
+
* Parse git stderr output into a GitError enum value.
|
|
101
|
+
*/
|
|
102
|
+
export declare function parseError(stderr: string): GitError | null;
|
|
103
|
+
/**
|
|
104
|
+
* Parse information about a bad config value error.
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseBadConfigValueErrorInfo(stderr: string): {
|
|
107
|
+
key: string;
|
|
108
|
+
value: string;
|
|
109
|
+
} | null;
|
package/dist/git/exec.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Git error types parsed from stderr output.
|
|
4
|
+
* This is a simplified version of dugite's GitError enum.
|
|
5
|
+
*/
|
|
6
|
+
export var GitError;
|
|
7
|
+
(function (GitError) {
|
|
8
|
+
// Authentication
|
|
9
|
+
GitError["SSHAuthenticationFailed"] = "SSHAuthenticationFailed";
|
|
10
|
+
GitError["SSHPermissionDenied"] = "SSHPermissionDenied";
|
|
11
|
+
GitError["HTTPSAuthenticationFailed"] = "HTTPSAuthenticationFailed";
|
|
12
|
+
GitError["SSHKeyAuditUnverified"] = "SSHKeyAuditUnverified";
|
|
13
|
+
// Remote
|
|
14
|
+
GitError["RemoteDisconnection"] = "RemoteDisconnection";
|
|
15
|
+
GitError["HostDown"] = "HostDown";
|
|
16
|
+
GitError["HTTPSRepositoryNotFound"] = "HTTPSRepositoryNotFound";
|
|
17
|
+
GitError["SSHRepositoryNotFound"] = "SSHRepositoryNotFound";
|
|
18
|
+
// Push / Pull
|
|
19
|
+
GitError["PushNotFastForward"] = "PushNotFastForward";
|
|
20
|
+
GitError["PushWithFileSizeExceedingLimit"] = "PushWithFileSizeExceedingLimit";
|
|
21
|
+
GitError["PushWithPrivateEmail"] = "PushWithPrivateEmail";
|
|
22
|
+
GitError["PushWithSecretDetected"] = "PushWithSecretDetected";
|
|
23
|
+
GitError["ForcePushRejected"] = "ForcePushRejected";
|
|
24
|
+
GitError["ProtectedBranchForcePush"] = "ProtectedBranchForcePush";
|
|
25
|
+
GitError["ProtectedBranchRequiresReview"] = "ProtectedBranchRequiresReview";
|
|
26
|
+
GitError["ProtectedBranchDeleteRejected"] = "ProtectedBranchDeleteRejected";
|
|
27
|
+
GitError["ProtectedBranchRequiredStatus"] = "ProtectedBranchRequiredStatus";
|
|
28
|
+
// Branch
|
|
29
|
+
GitError["BranchDeletionFailed"] = "BranchDeletionFailed";
|
|
30
|
+
GitError["DefaultBranchDeletionFailed"] = "DefaultBranchDeletionFailed";
|
|
31
|
+
GitError["BranchAlreadyExists"] = "BranchAlreadyExists";
|
|
32
|
+
GitError["BranchRenameFailed"] = "BranchRenameFailed";
|
|
33
|
+
GitError["HexBranchNameRejected"] = "HexBranchNameRejected";
|
|
34
|
+
GitError["InvalidRefLength"] = "InvalidRefLength";
|
|
35
|
+
// Merge / Rebase
|
|
36
|
+
GitError["MergeConflicts"] = "MergeConflicts";
|
|
37
|
+
GitError["RebaseConflicts"] = "RebaseConflicts";
|
|
38
|
+
GitError["MergeWithLocalChanges"] = "MergeWithLocalChanges";
|
|
39
|
+
GitError["RebaseWithLocalChanges"] = "RebaseWithLocalChanges";
|
|
40
|
+
GitError["InvalidMerge"] = "InvalidMerge";
|
|
41
|
+
GitError["InvalidRebase"] = "InvalidRebase";
|
|
42
|
+
GitError["NonFastForwardMergeIntoEmptyHead"] = "NonFastForwardMergeIntoEmptyHead";
|
|
43
|
+
GitError["CannotMergeUnrelatedHistories"] = "CannotMergeUnrelatedHistories";
|
|
44
|
+
GitError["NoMergeToAbort"] = "NoMergeToAbort";
|
|
45
|
+
GitError["RevertConflicts"] = "RevertConflicts";
|
|
46
|
+
// Rebase
|
|
47
|
+
GitError["EmptyRebasePatch"] = "EmptyRebasePatch";
|
|
48
|
+
// Commit
|
|
49
|
+
GitError["NothingToCommit"] = "NothingToCommit";
|
|
50
|
+
GitError["GPGFailedToSignData"] = "GPGFailedToSignData";
|
|
51
|
+
// Bad config
|
|
52
|
+
GitError["BadConfigValue"] = "BadConfigValue";
|
|
53
|
+
GitError["ConfigLockFileAlreadyExists"] = "ConfigLockFileAlreadyExists";
|
|
54
|
+
// Misc
|
|
55
|
+
GitError["NotAGitRepository"] = "NotAGitRepository";
|
|
56
|
+
GitError["BadRevision"] = "BadRevision";
|
|
57
|
+
GitError["LocalPermissionDenied"] = "LocalPermissionDenied";
|
|
58
|
+
GitError["NoMatchingRemoteBranch"] = "NoMatchingRemoteBranch";
|
|
59
|
+
GitError["NoExistingRemoteBranch"] = "NoExistingRemoteBranch";
|
|
60
|
+
GitError["PatchDoesNotApply"] = "PatchDoesNotApply";
|
|
61
|
+
GitError["NoSubmoduleMapping"] = "NoSubmoduleMapping";
|
|
62
|
+
GitError["SubmoduleRepositoryDoesNotExist"] = "SubmoduleRepositoryDoesNotExist";
|
|
63
|
+
GitError["InvalidSubmoduleSHA"] = "InvalidSubmoduleSHA";
|
|
64
|
+
GitError["LockFileAlreadyExists"] = "LockFileAlreadyExists";
|
|
65
|
+
GitError["UnresolvedConflicts"] = "UnresolvedConflicts";
|
|
66
|
+
GitError["LocalChangesOverwritten"] = "LocalChangesOverwritten";
|
|
67
|
+
GitError["RemoteAlreadyExists"] = "RemoteAlreadyExists";
|
|
68
|
+
GitError["TagAlreadyExists"] = "TagAlreadyExists";
|
|
69
|
+
GitError["PathDoesNotExist"] = "PathDoesNotExist";
|
|
70
|
+
GitError["InvalidObjectName"] = "InvalidObjectName";
|
|
71
|
+
GitError["OutsideRepository"] = "OutsideRepository";
|
|
72
|
+
GitError["ConflictModifyDeletedInBranch"] = "ConflictModifyDeletedInBranch";
|
|
73
|
+
GitError["MergeCommitNoMainlineOption"] = "MergeCommitNoMainlineOption";
|
|
74
|
+
GitError["UnsafeDirectory"] = "UnsafeDirectory";
|
|
75
|
+
GitError["PathExistsButNotInRef"] = "PathExistsButNotInRef";
|
|
76
|
+
GitError["LFSAttributeDoesNotMatch"] = "LFSAttributeDoesNotMatch";
|
|
77
|
+
})(GitError || (GitError = {}));
|
|
78
|
+
export class ExecError extends Error {
|
|
79
|
+
code;
|
|
80
|
+
stdout;
|
|
81
|
+
stderr;
|
|
82
|
+
cause;
|
|
83
|
+
constructor(message, stdout, stderr, cause) {
|
|
84
|
+
super(message);
|
|
85
|
+
this.name = 'ExecError';
|
|
86
|
+
this.code = 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER';
|
|
87
|
+
this.stdout = stdout;
|
|
88
|
+
this.stderr = stderr;
|
|
89
|
+
this.cause = cause;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Execute a git command and return the result.
|
|
94
|
+
*/
|
|
95
|
+
export async function exec(args, path, options) {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
const child = spawn('git', args, {
|
|
98
|
+
cwd: path,
|
|
99
|
+
env: {
|
|
100
|
+
...process.env,
|
|
101
|
+
TERM: 'dumb',
|
|
102
|
+
...options?.env,
|
|
103
|
+
},
|
|
104
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
105
|
+
});
|
|
106
|
+
const stdoutChunks = [];
|
|
107
|
+
const stderrChunks = [];
|
|
108
|
+
child.stdout?.on('data', (chunk) => stdoutChunks.push(chunk));
|
|
109
|
+
child.stderr?.on('data', (chunk) => stderrChunks.push(chunk));
|
|
110
|
+
if (options?.processCallback) {
|
|
111
|
+
options.processCallback(child);
|
|
112
|
+
}
|
|
113
|
+
if (options?.stdin) {
|
|
114
|
+
child.stdin?.write(options.stdin);
|
|
115
|
+
child.stdin?.end();
|
|
116
|
+
}
|
|
117
|
+
child.on('close', (exitCode) => {
|
|
118
|
+
const stdoutBuf = Buffer.concat(stdoutChunks);
|
|
119
|
+
const stderrBuf = Buffer.concat(stderrChunks);
|
|
120
|
+
const enc = options?.encoding;
|
|
121
|
+
const isBuffer = enc === 'buffer';
|
|
122
|
+
resolve({
|
|
123
|
+
stdout: isBuffer ? stdoutBuf : stdoutBuf.toString(options?.encoding || 'utf-8'),
|
|
124
|
+
stderr: isBuffer ? stderrBuf : stderrBuf.toString(options?.encoding || 'utf-8'),
|
|
125
|
+
exitCode: exitCode ?? -1,
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
child.on('error', (err) => {
|
|
129
|
+
reject(err);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Spawn a git process, returning the ChildProcess for streaming access.
|
|
135
|
+
*/
|
|
136
|
+
export function spawnGit(args, path, options) {
|
|
137
|
+
return spawn('git', args, {
|
|
138
|
+
...options,
|
|
139
|
+
cwd: path,
|
|
140
|
+
env: {
|
|
141
|
+
...process.env,
|
|
142
|
+
TERM: 'dumb',
|
|
143
|
+
...options?.env,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Parse git stderr output into a GitError enum value.
|
|
149
|
+
*/
|
|
150
|
+
export function parseError(stderr) {
|
|
151
|
+
if (!stderr)
|
|
152
|
+
return null;
|
|
153
|
+
// Authentication errors
|
|
154
|
+
if (stderr.includes('Permission denied (publickey)'))
|
|
155
|
+
return GitError.SSHPermissionDenied;
|
|
156
|
+
if (stderr.includes('fatal: Could not read from remote repository'))
|
|
157
|
+
return GitError.SSHAuthenticationFailed;
|
|
158
|
+
if (stderr.includes('Authentication failed'))
|
|
159
|
+
return GitError.HTTPSAuthenticationFailed;
|
|
160
|
+
// Merge conflicts
|
|
161
|
+
if (stderr.includes('Automatic merge failed'))
|
|
162
|
+
return GitError.MergeConflicts;
|
|
163
|
+
if (stderr.includes('merge failed'))
|
|
164
|
+
return GitError.MergeConflicts;
|
|
165
|
+
if (stderr.includes('conflict'))
|
|
166
|
+
return GitError.MergeConflicts;
|
|
167
|
+
// Rebase
|
|
168
|
+
if (stderr.includes('could not apply'))
|
|
169
|
+
return GitError.RebaseConflicts;
|
|
170
|
+
if (stderr.includes('interactive rebase already started'))
|
|
171
|
+
return GitError.RebaseConflicts;
|
|
172
|
+
// Push
|
|
173
|
+
if (stderr.includes('push is not fast forward') || stderr.includes('[rejected]'))
|
|
174
|
+
return GitError.PushNotFastForward;
|
|
175
|
+
if (stderr.includes('failed to push'))
|
|
176
|
+
return GitError.PushNotFastForward;
|
|
177
|
+
// Remote
|
|
178
|
+
if (stderr.includes('Could not resolve host'))
|
|
179
|
+
return GitError.RemoteDisconnection;
|
|
180
|
+
if (stderr.includes('host down'))
|
|
181
|
+
return GitError.HostDown;
|
|
182
|
+
if (stderr.includes('Repository not found'))
|
|
183
|
+
return GitError.HTTPSRepositoryNotFound;
|
|
184
|
+
if (stderr.includes('not found'))
|
|
185
|
+
return GitError.HTTPSRepositoryNotFound;
|
|
186
|
+
// Branch
|
|
187
|
+
if (stderr.includes('branch .* already exists'))
|
|
188
|
+
return GitError.BranchAlreadyExists;
|
|
189
|
+
if (stderr.includes('not a valid branch'))
|
|
190
|
+
return GitError.BranchDeletionFailed;
|
|
191
|
+
if (stderr.includes('could not delete'))
|
|
192
|
+
return GitError.BranchDeletionFailed;
|
|
193
|
+
// Config
|
|
194
|
+
if (stderr.includes('bad config value'))
|
|
195
|
+
return GitError.BadConfigValue;
|
|
196
|
+
if (stderr.includes('bad numeric config value'))
|
|
197
|
+
return GitError.BadConfigValue;
|
|
198
|
+
if (stderr.includes('config file lock'))
|
|
199
|
+
return GitError.ConfigLockFileAlreadyExists;
|
|
200
|
+
// Misc
|
|
201
|
+
if (stderr.includes('fatal: not a git repository'))
|
|
202
|
+
return GitError.NotAGitRepository;
|
|
203
|
+
if (stderr.includes('bad revision'))
|
|
204
|
+
return GitError.BadRevision;
|
|
205
|
+
if (stderr.includes('nothing to commit'))
|
|
206
|
+
return GitError.NothingToCommit;
|
|
207
|
+
if (stderr.includes('Permission denied'))
|
|
208
|
+
return GitError.LocalPermissionDenied;
|
|
209
|
+
if (stderr.includes('pathspec .* did not match'))
|
|
210
|
+
return GitError.PathDoesNotExist;
|
|
211
|
+
if (stderr.includes('did not match any files'))
|
|
212
|
+
return GitError.PathDoesNotExist;
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Parse information about a bad config value error.
|
|
217
|
+
*/
|
|
218
|
+
export function parseBadConfigValueErrorInfo(stderr) {
|
|
219
|
+
const match = stderr.match(/bad config value for '([^']+)' in ([^:]+):?\s*(.*)/);
|
|
220
|
+
if (!match)
|
|
221
|
+
return null;
|
|
222
|
+
return { key: match[1], value: match[3]?.trim() || '' };
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/git/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAA;AAEnD;;;GAGG;AACH,MAAM,CAAN,IAAY,QA8EX;AA9ED,WAAY,QAAQ;IAClB,iBAAiB;IACjB,+DAAmD,CAAA;IACnD,uDAA2C,CAAA;IAC3C,mEAAuD,CAAA;IACvD,2DAA+C,C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B,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QACtC,OAAO,QAAQ,CAAC,eAAe,CAAA;IACjC,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QACtC,OAAO,QAAQ,CAAC,qBAAqB,CAAA;IACvC,IAAI,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAC9C,OAAO,QAAQ,CAAC,gBAAgB,CAAA;IAClC,IAAI,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QAC5C,OAAO,QAAQ,CAAC,gBAAgB,CAAA;IAElC,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAAc;IAEd,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CACxB,oDAAoD,CACrD,CAAA;IACD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { IFetchProgress } from '../models/progress.js';
|
|
3
|
+
import { IRemote } from '../models/remote.js';
|
|
4
|
+
import { ITrackingBranch } from '../models/branch.js';
|
|
5
|
+
/**
|
|
6
|
+
* Fetch from the given remote.
|
|
7
|
+
*
|
|
8
|
+
* @param repository - The repository to fetch into
|
|
9
|
+
*
|
|
10
|
+
* @param account - The account to use when authenticating with the remote
|
|
11
|
+
*
|
|
12
|
+
* @param remote - The remote to fetch from
|
|
13
|
+
*
|
|
14
|
+
* @param progressCallback - An optional function which will be invoked
|
|
15
|
+
* with information about the current progress
|
|
16
|
+
* of the fetch operation. When provided this enables
|
|
17
|
+
* the '--progress' command line flag for
|
|
18
|
+
* 'git fetch'.
|
|
19
|
+
* @param isBackgroundTask - Whether the fetch is being performed as a
|
|
20
|
+
* background task as opposed to being user initiated
|
|
21
|
+
*/
|
|
22
|
+
export declare function fetch(repository: Repository, remote: IRemote, progressCallback?: (progress: IFetchProgress) => void, isBackgroundTask?: boolean): Promise<void>;
|
|
23
|
+
/** Fetch a given refspec from the given remote. */
|
|
24
|
+
export declare function fetchRefspec(repository: Repository, remote: IRemote, refspec: string): Promise<void>;
|
|
25
|
+
export declare function fastForwardBranches(repository: Repository, branches: ReadonlyArray<ITrackingBranch>): Promise<void>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { FetchProgressParser, executionOptionsWithProgress } from '../lib/progress/index.js';
|
|
3
|
+
import { envForRemoteOperation } from './environment.js';
|
|
4
|
+
async function getFetchArgs(remote, progressCallback) {
|
|
5
|
+
return [
|
|
6
|
+
'fetch',
|
|
7
|
+
...(progressCallback ? ['--progress'] : []),
|
|
8
|
+
'--prune',
|
|
9
|
+
'--recurse-submodules=on-demand',
|
|
10
|
+
remote,
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Fetch from the given remote.
|
|
15
|
+
*
|
|
16
|
+
* @param repository - The repository to fetch into
|
|
17
|
+
*
|
|
18
|
+
* @param account - The account to use when authenticating with the remote
|
|
19
|
+
*
|
|
20
|
+
* @param remote - The remote to fetch from
|
|
21
|
+
*
|
|
22
|
+
* @param progressCallback - An optional function which will be invoked
|
|
23
|
+
* with information about the current progress
|
|
24
|
+
* of the fetch operation. When provided this enables
|
|
25
|
+
* the '--progress' command line flag for
|
|
26
|
+
* 'git fetch'.
|
|
27
|
+
* @param isBackgroundTask - Whether the fetch is being performed as a
|
|
28
|
+
* background task as opposed to being user initiated
|
|
29
|
+
*/
|
|
30
|
+
export async function fetch(repository, remote, progressCallback, isBackgroundTask = false) {
|
|
31
|
+
let opts = {
|
|
32
|
+
successExitCodes: new Set([0]),
|
|
33
|
+
env: await envForRemoteOperation(remote.url),
|
|
34
|
+
};
|
|
35
|
+
if (progressCallback) {
|
|
36
|
+
const title = `Fetching ${remote.name}`;
|
|
37
|
+
const kind = 'fetch';
|
|
38
|
+
opts = await executionOptionsWithProgress({ ...opts, trackLFSProgress: true, isBackgroundTask }, new FetchProgressParser(), progress => {
|
|
39
|
+
// In addition to progress output from the remote end and from
|
|
40
|
+
// git itself, the stderr output from pull contains information
|
|
41
|
+
// about ref updates. We don't need to bring those into the progress
|
|
42
|
+
// stream so we'll just punt on anything we don't know about for now.
|
|
43
|
+
if (progress.kind === 'context') {
|
|
44
|
+
if (!progress.text.startsWith('remote: Counting objects')) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const description = progress.kind === 'progress' ? progress.details.text : progress.text;
|
|
49
|
+
const value = progress.percent;
|
|
50
|
+
progressCallback({
|
|
51
|
+
kind,
|
|
52
|
+
title,
|
|
53
|
+
description,
|
|
54
|
+
value,
|
|
55
|
+
remote: remote.name,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
// Initial progress
|
|
59
|
+
progressCallback({ kind, title, value: 0, remote: remote.name });
|
|
60
|
+
}
|
|
61
|
+
const args = await getFetchArgs(remote.name, progressCallback);
|
|
62
|
+
await git(args, repository.path, 'fetch', opts);
|
|
63
|
+
}
|
|
64
|
+
/** Fetch a given refspec from the given remote. */
|
|
65
|
+
export async function fetchRefspec(repository, remote, refspec) {
|
|
66
|
+
await git(['fetch', remote.name, refspec], repository.path, 'fetchRefspec', {
|
|
67
|
+
successExitCodes: new Set([0, 128]),
|
|
68
|
+
env: await envForRemoteOperation(remote.url),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export async function fastForwardBranches(repository, branches) {
|
|
72
|
+
if (branches.length === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const refPairs = branches.map(branch => `${branch.upstreamRef}:${branch.ref}`);
|
|
76
|
+
await git([
|
|
77
|
+
'fetch',
|
|
78
|
+
'.',
|
|
79
|
+
// Make sure we don't try to update branches that can't be fast-forwarded
|
|
80
|
+
// even if the user disabled this via the git config option
|
|
81
|
+
// `fetch.showForcedUpdates`
|
|
82
|
+
'--show-forced-updates',
|
|
83
|
+
// Prevent `git fetch` from touching the `FETCH_HEAD`
|
|
84
|
+
'--no-write-fetch-head',
|
|
85
|
+
// Take branch refs from stdin to circumvent shell max line length
|
|
86
|
+
// limitations (mainly on Windows)
|
|
87
|
+
'--stdin',
|
|
88
|
+
], repository.path, 'fastForwardBranches', {
|
|
89
|
+
// Fetch exits with an exit code of 1 if one or more refs failed to update
|
|
90
|
+
// which is what we expect will happen
|
|
91
|
+
successExitCodes: new Set([0, 1]),
|
|
92
|
+
env: {
|
|
93
|
+
// This will make sure the reflog entries are correct after
|
|
94
|
+
// fast-forwarding the branches.
|
|
95
|
+
GIT_REFLOG_ACTION: 'pull',
|
|
96
|
+
},
|
|
97
|
+
stdin: refPairs.join('\n'),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/git/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA8B,MAAM,WAAW,CAAA;AAG3D,OAAO,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAG5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,KAAK,UAAU,YAAY,CACzB,MAAc,EACd,gBAAqD;IAErD,OAAO;QACL,OAAO;QACP,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,SAAS;QACT,gCAAgC;QAChC,MAAM;KACP,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,KAA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C,iBAAiB,EAAE,MAAM;SAC1B;QACD,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;KAC3B,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { Branch, ITrackingBranch } from '../models/branch.js';
|
|
3
|
+
/** Get all the branches. */
|
|
4
|
+
export declare function getBranches(repository: Repository, ...prefixes: string[]): Promise<ReadonlyArray<Branch>>;
|
|
5
|
+
/**
|
|
6
|
+
* Gets all branches that differ from their upstream (i.e. they're ahead,
|
|
7
|
+
* behind or both), excluding the current branch.
|
|
8
|
+
* Useful to narrow down a list of branches that could potentially be fast
|
|
9
|
+
* forwarded.
|
|
10
|
+
*
|
|
11
|
+
* @param repository Repository to get the branches from.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getBranchesDifferingFromUpstream(repository: Repository): Promise<ReadonlyArray<ITrackingBranch>>;
|