git-chopstick-core 0.1.1 → 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/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 +13 -4
- 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 +9 -21
- 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,98 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
/**
|
|
3
|
+
* Look up a config value by name in the repository.
|
|
4
|
+
*
|
|
5
|
+
* @param onlyLocal Whether or not the value to be retrieved should stick to
|
|
6
|
+
* the local repository settings. It is false by default. This
|
|
7
|
+
* is equivalent to using the `--local` argument in the
|
|
8
|
+
* `git config` invocation.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getConfigValue(repository: Repository, name: string, onlyLocal?: boolean): Promise<string | null>;
|
|
11
|
+
/** Look up a global config value by name. */
|
|
12
|
+
export declare function getGlobalConfigValue(name: string, env?: {
|
|
13
|
+
HOME: string;
|
|
14
|
+
}): Promise<string | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Look up a config value by name.
|
|
17
|
+
*
|
|
18
|
+
* Treats the returned value as a boolean as per Git's
|
|
19
|
+
* own definition of a boolean configuration value (i.e.
|
|
20
|
+
* 0 -> false, "off" -> false, "yes" -> true etc)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getBooleanConfigValue(repository: Repository, name: string, onlyLocal?: boolean, env?: {
|
|
23
|
+
HOME: string;
|
|
24
|
+
}): Promise<boolean | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Look up a global config value by name.
|
|
27
|
+
*
|
|
28
|
+
* Treats the returned value as a boolean as per Git's
|
|
29
|
+
* own definition of a boolean configuration value (i.e.
|
|
30
|
+
* 0 -> false, "off" -> false, "yes" -> true etc)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getGlobalBooleanConfigValue(name: string, env?: {
|
|
33
|
+
HOME: string;
|
|
34
|
+
}): Promise<boolean | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the path to the global git config
|
|
37
|
+
*
|
|
38
|
+
* Note: this uses git config --edit which will automatically create the global
|
|
39
|
+
* config file if it doesn't exist yet. The primary purpose behind this method
|
|
40
|
+
* is to support opening the global git config for editing.
|
|
41
|
+
*/
|
|
42
|
+
export declare const getGlobalConfigPath: (env?: {
|
|
43
|
+
HOME: string;
|
|
44
|
+
}) => Promise<string>;
|
|
45
|
+
/** Set the local config value by name. */
|
|
46
|
+
export declare function setConfigValue(repository: Repository, name: string, value: string, env?: {
|
|
47
|
+
HOME: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/** Set the global config value by name. */
|
|
50
|
+
export declare function setGlobalConfigValue(name: string, value: string, env?: {
|
|
51
|
+
HOME: string;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
/** Set the global config value by name. */
|
|
54
|
+
export declare function addGlobalConfigValue(name: string, value: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Adds a path to the `safe.directories` configuration variable if it's not
|
|
57
|
+
* already present. Adding a path to `safe.directory` will cause Git to ignore
|
|
58
|
+
* if the path is owner by a different user than the current.
|
|
59
|
+
*/
|
|
60
|
+
export declare function addSafeDirectory(path: string): Promise<void>;
|
|
61
|
+
/** Set the global config value by name. */
|
|
62
|
+
export declare function addGlobalConfigValueIfMissing(name: string, value: string): Promise<void>;
|
|
63
|
+
/** Remove the local config value by name. */
|
|
64
|
+
export declare function removeConfigValue(repository: Repository, name: string, env?: {
|
|
65
|
+
HOME: string;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
/** Remove the global config value by name. */
|
|
68
|
+
export declare function removeGlobalConfigValue(name: string, env?: {
|
|
69
|
+
HOME: string;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
export interface IConfigValueOrigin {
|
|
72
|
+
readonly value: string;
|
|
73
|
+
readonly scope: string;
|
|
74
|
+
readonly origin: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Look up a config value along with its source file and scope.
|
|
78
|
+
* Requires Git 2.26+ for --show-scope.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getConfigValueWithOrigin(repository: Repository, name: string): Promise<IConfigValueOrigin | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Extract the file path from a config value origin, stripping the `file:` prefix.
|
|
83
|
+
* When repositoryPath is provided, relative paths (e.g. `.git/config` for local
|
|
84
|
+
* scope) are resolved to absolute paths.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getOriginFilePath(origin: IConfigValueOrigin, repositoryPath?: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Check whether a global-scoped config value comes from a conditionally
|
|
89
|
+
* included file (via includeIf directive) rather than a standard location.
|
|
90
|
+
*/
|
|
91
|
+
export declare function isConditionalInclude(origin: IConfigValueOrigin): boolean;
|
|
92
|
+
/** Format a human-readable scope description for a config value origin. */
|
|
93
|
+
export declare function formatConfigScope(origin: IConfigValueOrigin): string;
|
|
94
|
+
/**
|
|
95
|
+
* Format the file path for a config value origin.
|
|
96
|
+
* For local/worktree scope, displays the path with a `<repo>` prefix.
|
|
97
|
+
*/
|
|
98
|
+
export declare function formatConfigPath(origin: IConfigValueOrigin, repositoryPath: string): string;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { normalize } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Look up a config value by name in the repository.
|
|
5
|
+
*
|
|
6
|
+
* @param onlyLocal Whether or not the value to be retrieved should stick to
|
|
7
|
+
* the local repository settings. It is false by default. This
|
|
8
|
+
* is equivalent to using the `--local` argument in the
|
|
9
|
+
* `git config` invocation.
|
|
10
|
+
*/
|
|
11
|
+
export function getConfigValue(repository, name, onlyLocal = false) {
|
|
12
|
+
return getConfigValueInPath(name, repository.path, onlyLocal);
|
|
13
|
+
}
|
|
14
|
+
/** Look up a global config value by name. */
|
|
15
|
+
export function getGlobalConfigValue(name, env) {
|
|
16
|
+
return getConfigValueInPath(name, null, false, undefined, env);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Look up a config value by name.
|
|
20
|
+
*
|
|
21
|
+
* Treats the returned value as a boolean as per Git's
|
|
22
|
+
* own definition of a boolean configuration value (i.e.
|
|
23
|
+
* 0 -> false, "off" -> false, "yes" -> true etc)
|
|
24
|
+
*/
|
|
25
|
+
export async function getBooleanConfigValue(repository, name, onlyLocal = false, env) {
|
|
26
|
+
const value = await getConfigValueInPath(name, repository.path, onlyLocal, 'bool', env);
|
|
27
|
+
return value === null ? null : value !== 'false';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Look up a global config value by name.
|
|
31
|
+
*
|
|
32
|
+
* Treats the returned value as a boolean as per Git's
|
|
33
|
+
* own definition of a boolean configuration value (i.e.
|
|
34
|
+
* 0 -> false, "off" -> false, "yes" -> true etc)
|
|
35
|
+
*/
|
|
36
|
+
export async function getGlobalBooleanConfigValue(name, env) {
|
|
37
|
+
const value = await getConfigValueInPath(name, null, false, 'bool', env);
|
|
38
|
+
return value === null ? null : value !== 'false';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Look up a config value by name
|
|
42
|
+
*
|
|
43
|
+
* @param path The path to execute the `git` command in. If null
|
|
44
|
+
* we'll use the global configuration (i.e. --global)
|
|
45
|
+
* and execute the Git call from the same location that
|
|
46
|
+
* GitHub Desktop is installed in.
|
|
47
|
+
* @param onlyLocal Whether or not the value to be retrieved should stick to
|
|
48
|
+
* the local repository settings (if a path is specified). It
|
|
49
|
+
* is false by default. It is equivalent to using the `--local`
|
|
50
|
+
* argument in the `git config` invocation.
|
|
51
|
+
* @param type Canonicalize configuration values according to the
|
|
52
|
+
* expected type (i.e. 0 -> false, "on" -> true etc).
|
|
53
|
+
* See `--type` documentation in `git config`
|
|
54
|
+
*/
|
|
55
|
+
async function getConfigValueInPath(name, path, onlyLocal = false, type, env) {
|
|
56
|
+
const flags = ['config', '-z'];
|
|
57
|
+
if (!path) {
|
|
58
|
+
flags.push('--global');
|
|
59
|
+
}
|
|
60
|
+
else if (onlyLocal) {
|
|
61
|
+
flags.push('--local');
|
|
62
|
+
}
|
|
63
|
+
if (type !== undefined) {
|
|
64
|
+
flags.push('--type', type);
|
|
65
|
+
}
|
|
66
|
+
flags.push(name);
|
|
67
|
+
const result = await git(flags, path || __dirname, 'getConfigValueInPath', {
|
|
68
|
+
successExitCodes: new Set([0, 1]),
|
|
69
|
+
env,
|
|
70
|
+
});
|
|
71
|
+
// Git exits with 1 if the value isn't found. That's OK.
|
|
72
|
+
if (result.exitCode === 1) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const output = result.stdout;
|
|
76
|
+
const pieces = output.split('\0');
|
|
77
|
+
return pieces[0];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the path to the global git config
|
|
81
|
+
*
|
|
82
|
+
* Note: this uses git config --edit which will automatically create the global
|
|
83
|
+
* config file if it doesn't exist yet. The primary purpose behind this method
|
|
84
|
+
* is to support opening the global git config for editing.
|
|
85
|
+
*/
|
|
86
|
+
export const getGlobalConfigPath = (env) => git(['config', '--edit', '--global'], __dirname, 'getGlobalConfigPath', {
|
|
87
|
+
// We're using printf instead of echo because echo could attempt to decode
|
|
88
|
+
// escape sequences like \n which would be bad in a case like
|
|
89
|
+
// c:\Users\niik\.gitconfig
|
|
90
|
+
// ^^
|
|
91
|
+
env: { ...env, GIT_EDITOR: 'printf %s' },
|
|
92
|
+
}).then(x => normalize(x.stdout));
|
|
93
|
+
/** Set the local config value by name. */
|
|
94
|
+
export async function setConfigValue(repository, name, value, env) {
|
|
95
|
+
return setConfigValueInPath(name, value, repository.path, env);
|
|
96
|
+
}
|
|
97
|
+
/** Set the global config value by name. */
|
|
98
|
+
export async function setGlobalConfigValue(name, value, env) {
|
|
99
|
+
return setConfigValueInPath(name, value, null, env);
|
|
100
|
+
}
|
|
101
|
+
/** Set the global config value by name. */
|
|
102
|
+
export async function addGlobalConfigValue(name, value) {
|
|
103
|
+
await git(['config', '--global', '--add', name, value], __dirname, 'addGlobalConfigValue');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Adds a path to the `safe.directories` configuration variable if it's not
|
|
107
|
+
* already present. Adding a path to `safe.directory` will cause Git to ignore
|
|
108
|
+
* if the path is owner by a different user than the current.
|
|
109
|
+
*/
|
|
110
|
+
export async function addSafeDirectory(path) {
|
|
111
|
+
// UNC-paths on Windows need to be prefixed with `%(prefix)/`, see
|
|
112
|
+
// https://github.com/git-for-windows/git/commit/e394a16023cbb62784e380f70ad8a833fb960d68
|
|
113
|
+
if (process.platform === 'win32' && path[0] === '/') {
|
|
114
|
+
path = `%(prefix)/${path}`;
|
|
115
|
+
}
|
|
116
|
+
await addGlobalConfigValueIfMissing('safe.directory', path);
|
|
117
|
+
}
|
|
118
|
+
/** Set the global config value by name. */
|
|
119
|
+
export async function addGlobalConfigValueIfMissing(name, value) {
|
|
120
|
+
const { stdout, exitCode } = await git(['config', '--global', '-z', '--get-all', name, value], __dirname, 'addGlobalConfigValue', { successExitCodes: new Set([0, 1]) });
|
|
121
|
+
if (exitCode === 1 || !stdout.split('\0').includes(value)) {
|
|
122
|
+
await addGlobalConfigValue(name, value);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Set config value by name
|
|
127
|
+
*
|
|
128
|
+
* @param path The path to execute the `git` command in. If null
|
|
129
|
+
* we'll use the global configuration (i.e. --global)
|
|
130
|
+
* and execute the Git call from the same location that
|
|
131
|
+
* GitHub Desktop is installed in.
|
|
132
|
+
*/
|
|
133
|
+
async function setConfigValueInPath(name, value, path, env) {
|
|
134
|
+
const options = env ? { env } : undefined;
|
|
135
|
+
const flags = ['config'];
|
|
136
|
+
if (!path) {
|
|
137
|
+
flags.push('--global');
|
|
138
|
+
}
|
|
139
|
+
flags.push('--replace-all', name, value);
|
|
140
|
+
await git(flags, path || __dirname, 'setConfigValueInPath', options);
|
|
141
|
+
}
|
|
142
|
+
/** Remove the local config value by name. */
|
|
143
|
+
export async function removeConfigValue(repository, name, env) {
|
|
144
|
+
return removeConfigValueInPath(name, repository.path, env);
|
|
145
|
+
}
|
|
146
|
+
/** Remove the global config value by name. */
|
|
147
|
+
export async function removeGlobalConfigValue(name, env) {
|
|
148
|
+
return removeConfigValueInPath(name, null, env);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Remove config value by name
|
|
152
|
+
*
|
|
153
|
+
* @param path The path to execute the `git` command in. If null
|
|
154
|
+
* we'll use the global configuration (i.e. --global)
|
|
155
|
+
* and execute the Git call from the same location that
|
|
156
|
+
* GitHub Desktop is installed in.
|
|
157
|
+
*/
|
|
158
|
+
async function removeConfigValueInPath(name, path, env) {
|
|
159
|
+
const options = env ? { env } : undefined;
|
|
160
|
+
const flags = ['config'];
|
|
161
|
+
if (!path) {
|
|
162
|
+
flags.push('--global');
|
|
163
|
+
}
|
|
164
|
+
flags.push('--unset-all', name);
|
|
165
|
+
await git(flags, path || __dirname, 'removeConfigValueInPath', options);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Look up a config value along with its source file and scope.
|
|
169
|
+
* Requires Git 2.26+ for --show-scope.
|
|
170
|
+
*/
|
|
171
|
+
export async function getConfigValueWithOrigin(repository, name) {
|
|
172
|
+
const result = await git(['config', '--show-origin', '--show-scope', '-z', name], repository.path, 'getConfigValueWithOrigin',
|
|
173
|
+
// 0 = found, 1 = key not set, 128 = not a git repo or git error
|
|
174
|
+
{ successExitCodes: new Set([0, 1, 128]) });
|
|
175
|
+
if (result.exitCode !== 0) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const parts = result.stdout.split('\0');
|
|
179
|
+
if (parts.length >= 3) {
|
|
180
|
+
return {
|
|
181
|
+
scope: parts[0],
|
|
182
|
+
origin: parts[1],
|
|
183
|
+
value: parts[2],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Extract the file path from a config value origin, stripping the `file:` prefix.
|
|
190
|
+
* When repositoryPath is provided, relative paths (e.g. `.git/config` for local
|
|
191
|
+
* scope) are resolved to absolute paths.
|
|
192
|
+
*/
|
|
193
|
+
export function getOriginFilePath(origin, repositoryPath) {
|
|
194
|
+
const filePath = origin.origin.replace(/^file:/, '');
|
|
195
|
+
// Git returns relative paths for local/worktree scope (e.g. `.git/config`)
|
|
196
|
+
if (repositoryPath && !/^([a-zA-Z]:|[/\\])/.test(filePath)) {
|
|
197
|
+
const base = repositoryPath.replace(/[\\/]+$/, '');
|
|
198
|
+
return `${base}/${filePath}`;
|
|
199
|
+
}
|
|
200
|
+
return filePath;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Check whether a global-scoped config value comes from a conditionally
|
|
204
|
+
* included file (via includeIf directive) rather than a standard location.
|
|
205
|
+
*/
|
|
206
|
+
export function isConditionalInclude(origin) {
|
|
207
|
+
if (origin.scope !== 'global') {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
const filePath = getOriginFilePath(origin);
|
|
211
|
+
return (!/[/\\]\.gitconfig$/i.test(filePath) &&
|
|
212
|
+
!/[/\\]\.config[/\\]git[/\\]config$/i.test(filePath));
|
|
213
|
+
}
|
|
214
|
+
/** Format a human-readable scope description for a config value origin. */
|
|
215
|
+
export function formatConfigScope(origin) {
|
|
216
|
+
if (origin.scope === 'local') {
|
|
217
|
+
return 'local';
|
|
218
|
+
}
|
|
219
|
+
else if (origin.scope === 'system') {
|
|
220
|
+
return 'system';
|
|
221
|
+
}
|
|
222
|
+
else if (origin.scope === 'worktree') {
|
|
223
|
+
return 'worktree';
|
|
224
|
+
}
|
|
225
|
+
else if (origin.scope === 'global') {
|
|
226
|
+
return isConditionalInclude(origin) ? 'global, via [includeIf]' : 'global';
|
|
227
|
+
}
|
|
228
|
+
return origin.scope;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Format the file path for a config value origin.
|
|
232
|
+
* For local/worktree scope, displays the path with a `<repo>` prefix.
|
|
233
|
+
*/
|
|
234
|
+
export function formatConfigPath(origin, repositoryPath) {
|
|
235
|
+
const rawPath = origin.origin.replace(/^file:/, '');
|
|
236
|
+
if (origin.scope === 'local' || origin.scope === 'worktree') {
|
|
237
|
+
// Git returns relative paths for local scope (e.g. `.git/config`)
|
|
238
|
+
if (!/^([a-zA-Z]:|[/\\])/.test(rawPath)) {
|
|
239
|
+
return '<repo>/' + rawPath;
|
|
240
|
+
}
|
|
241
|
+
// Absolute path — strip repo prefix
|
|
242
|
+
const normalized = repositoryPath.replace(/[\\/]+$/, '');
|
|
243
|
+
if (rawPath.toLowerCase().startsWith(normalized.toLowerCase())) {
|
|
244
|
+
return '<repo>' + rawPath.slice(normalized.length);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return rawPath;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/git/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAsB,EACtB,IAAY,EACZ,YAAqB,KAAK;IAE1B,OAAO,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AAC/D,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,GAEC;IAED,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,CAAA;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAsB,EACtB,IAAY,EACZ,YAAqB,KAAK,EAC1B,GAEC;IAED,MAAM,KAAK,GAAG,MAAM,oBAAoB,CACtC,IAAI,EACJ,UAAU,CAAC,IAAI,EACf,SAAS,EACT,MAAM,EACN,GAAG,CACJ,CAAA;IACD,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,K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ExecError } from './exec.js';
|
|
2
|
+
export declare const isMaxBufferExceededError: (error: unknown) => error is ExecError & {
|
|
3
|
+
code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
4
|
+
};
|
|
5
|
+
export type TerminalOutput = string | Buffer | Buffer[];
|
|
6
|
+
export type TerminalOutputListener = (cb: (chunk: TerminalOutput) => void) => {
|
|
7
|
+
unsubscribe: () => void;
|
|
8
|
+
};
|
|
9
|
+
export type TerminalOutputCallback = (subscribe: TerminalOutputListener) => void;
|
|
10
|
+
export type HookProgress = {
|
|
11
|
+
readonly hookName: string;
|
|
12
|
+
} & ({
|
|
13
|
+
readonly status: 'started';
|
|
14
|
+
readonly abort: () => void;
|
|
15
|
+
} | {
|
|
16
|
+
readonly status: 'finished' | 'failed';
|
|
17
|
+
});
|
|
18
|
+
export type HookCallbackOptions = {
|
|
19
|
+
readonly onHookProgress?: (progress: HookProgress) => void;
|
|
20
|
+
readonly onHookFailure?: (hookName: string, terminalOutput: TerminalOutput) => Promise<'abort' | 'ignore'>;
|
|
21
|
+
readonly onTerminalOutputAvailable?: TerminalOutputCallback;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* An extension of the execution options in dugite that
|
|
25
|
+
* allows us to piggy-back our own configuration options in the
|
|
26
|
+
* same object.
|
|
27
|
+
*/
|
|
28
|
+
export interface IGitExecutionOptions extends HookCallbackOptions {
|
|
29
|
+
readonly env?: Record<string, string | undefined>;
|
|
30
|
+
readonly stdin?: string;
|
|
31
|
+
readonly maxBuffer?: number;
|
|
32
|
+
readonly processCallback?: (process: any) => void;
|
|
33
|
+
readonly encoding?: BufferEncoding;
|
|
34
|
+
/**
|
|
35
|
+
* The exit codes which indicate success to the
|
|
36
|
+
* caller. Unexpected exit codes will be logged and an
|
|
37
|
+
* error thrown. Defaults to 0 if undefined.
|
|
38
|
+
*/
|
|
39
|
+
readonly successExitCodes?: ReadonlySet<number>;
|
|
40
|
+
/**
|
|
41
|
+
* The git errors which are expected by the caller. Unexpected errors will
|
|
42
|
+
* be logged and an error thrown.
|
|
43
|
+
*/
|
|
44
|
+
readonly expectedErrors?: ReadonlySet<DugiteError>;
|
|
45
|
+
/** Should it track & report LFS progress? */
|
|
46
|
+
readonly trackLFSProgress?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the command about to run is part of a background task or not.
|
|
49
|
+
* This affects error handling and UI such as credential prompts.
|
|
50
|
+
*/
|
|
51
|
+
readonly isBackgroundTask?: boolean;
|
|
52
|
+
readonly interceptHooks?: string[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The result of using `git`. This wraps dugite's results to provide
|
|
56
|
+
* the parsed error if one occurs.
|
|
57
|
+
*/
|
|
58
|
+
export interface IGitResult {
|
|
59
|
+
readonly stdout: string;
|
|
60
|
+
readonly stderr: string;
|
|
61
|
+
readonly exitCode: number;
|
|
62
|
+
/**
|
|
63
|
+
* The parsed git error. This will be null when the exit code is included in
|
|
64
|
+
* the `successExitCodes`, or when dugite was unable to parse the
|
|
65
|
+
* error.
|
|
66
|
+
*/
|
|
67
|
+
readonly gitError: DugiteError | null;
|
|
68
|
+
/** The human-readable error description, based on `gitError`. */
|
|
69
|
+
readonly gitErrorDescription: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* The path that the Git command was executed from, i.e. the
|
|
72
|
+
* process working directory (not to be confused with the Git
|
|
73
|
+
* working directory which is... super confusing, I know)
|
|
74
|
+
*/
|
|
75
|
+
readonly path: string;
|
|
76
|
+
}
|
|
77
|
+
/** The result of shelling out to git using a string encoding (default) */
|
|
78
|
+
export interface IGitStringResult extends IGitResult {
|
|
79
|
+
/** The standard output from git. */
|
|
80
|
+
readonly stdout: string;
|
|
81
|
+
/** The standard error output from git. */
|
|
82
|
+
readonly stderr: string;
|
|
83
|
+
}
|
|
84
|
+
export interface IGitStringExecutionOptions extends IGitExecutionOptions {
|
|
85
|
+
readonly encoding?: BufferEncoding;
|
|
86
|
+
}
|
|
87
|
+
export interface IGitBufferExecutionOptions extends Omit<IGitExecutionOptions, 'encoding'> {
|
|
88
|
+
readonly encoding: 'buffer';
|
|
89
|
+
}
|
|
90
|
+
/** The result of shelling out to git using a buffer encoding */
|
|
91
|
+
export interface IGitBufferResult extends Omit<IGitResult, 'stdout' | 'stderr'> {
|
|
92
|
+
/** The standard output from git. */
|
|
93
|
+
readonly stdout: Buffer;
|
|
94
|
+
/** The standard error output from git. */
|
|
95
|
+
readonly stderr: Buffer;
|
|
96
|
+
}
|
|
97
|
+
export interface IGitFullResult extends IGitResult {
|
|
98
|
+
readonly stdout: string;
|
|
99
|
+
readonly stderr: string;
|
|
100
|
+
readonly exitCode: number;
|
|
101
|
+
readonly gitError: DugiteError | null;
|
|
102
|
+
readonly gitErrorDescription: string | null;
|
|
103
|
+
readonly path: string;
|
|
104
|
+
}
|
|
105
|
+
export declare class GitError extends Error {
|
|
106
|
+
/** The result from the failed command. */
|
|
107
|
+
readonly result: IGitResult;
|
|
108
|
+
/** The args for the failed command. */
|
|
109
|
+
readonly args: ReadonlyArray<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Whether or not the error message is just the raw output of the git command.
|
|
112
|
+
*/
|
|
113
|
+
readonly isRawMessage: boolean;
|
|
114
|
+
constructor(result: IGitResult, args: ReadonlyArray<string>, terminalOutput: string);
|
|
115
|
+
}
|
|
116
|
+
export declare const isGitError: (e: unknown, parsedError?: DugiteError) => e is GitError;
|
|
117
|
+
/**
|
|
118
|
+
* Shell out to git with the given arguments, at the given path.
|
|
119
|
+
*
|
|
120
|
+
* @param args The arguments to pass to `git`.
|
|
121
|
+
*
|
|
122
|
+
* @param path The working directory path for the execution of the
|
|
123
|
+
* command.
|
|
124
|
+
*
|
|
125
|
+
* @param name The name for the command based on its caller's
|
|
126
|
+
* context. This will be used for performance
|
|
127
|
+
* measurements and debugging.
|
|
128
|
+
*
|
|
129
|
+
* @param options Configuration options for the execution of git,
|
|
130
|
+
* see IGitExecutionOptions for more information.
|
|
131
|
+
*
|
|
132
|
+
* Returns the result. If the command exits with a code not in
|
|
133
|
+
* `successExitCodes` or an error not in `expectedErrors`, a `GitError` will be
|
|
134
|
+
* thrown.
|
|
135
|
+
*/
|
|
136
|
+
export declare function git(args: string[], path: string, name: string, options?: IGitStringExecutionOptions): Promise<IGitStringResult>;
|
|
137
|
+
export declare function git(args: string[], path: string, name: string, options?: IGitBufferExecutionOptions): Promise<IGitBufferResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Determine whether the provided `error` is an authentication failure
|
|
140
|
+
* as per our definition. Note that this is not an exhaustive list of
|
|
141
|
+
* authentication failures, only a collection of errors that we treat
|
|
142
|
+
* equally in terms of error message and presentation to the user.
|
|
143
|
+
*/
|
|
144
|
+
export declare function isAuthFailureError(error: DugiteError): error is DugiteError.SSHAuthenticationFailed | DugiteError.SSHPermissionDenied | DugiteError.HTTPSAuthenticationFailed;
|
|
145
|
+
/**
|
|
146
|
+
* Determine whether the provided `error` is an error from Git indicating
|
|
147
|
+
* that a configuration file write failed due to a lock file already
|
|
148
|
+
* existing for that config file.
|
|
149
|
+
*/
|
|
150
|
+
export declare function isConfigFileLockError(error: Error): error is GitError;
|
|
151
|
+
/**
|
|
152
|
+
* If the `result` is associated with an config lock file error (as determined
|
|
153
|
+
* by `isConfigFileLockError`) this method will attempt to extract an absolute
|
|
154
|
+
* path (i.e. rooted) to the configuration lock file in question from the Git
|
|
155
|
+
* output.
|
|
156
|
+
*/
|
|
157
|
+
export declare function parseConfigLockFilePathFromError(result: IGitResult): string | null;
|
|
158
|
+
export declare function getDescriptionForError(error: DugiteError, stderr: string): string | null;
|
|
159
|
+
/**
|
|
160
|
+
* Returns the arguments to use on any git operation that can end up
|
|
161
|
+
* triggering a rebase.
|
|
162
|
+
*/
|
|
163
|
+
export declare function gitRebaseArguments(): string[];
|
|
164
|
+
/**
|
|
165
|
+
* Returns the SHA of the passed in IGitResult
|
|
166
|
+
*/
|
|
167
|
+
export declare function parseCommitSHA(result: IGitStringResult): string;
|