git-chopstick-core 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +324 -32
- package/dist/git/add.d.ts +9 -0
- package/dist/git/add.js +11 -0
- package/dist/git/add.js.map +1 -0
- package/dist/git/apply.d.ts +33 -0
- package/dist/git/apply.js +103 -0
- package/dist/git/apply.js.map +1 -0
- package/dist/git/authentication.d.ts +5 -0
- package/dist/git/authentication.js +19 -0
- package/dist/git/authentication.js.map +1 -0
- package/dist/git/branch.d.ts +43 -0
- package/dist/git/branch.js +150 -0
- package/dist/git/branch.js.map +1 -0
- package/dist/git/checkout-index.d.ts +19 -0
- package/{src/git/checkout-index.ts → dist/git/checkout-index.js} +11 -22
- package/dist/git/checkout-index.js.map +1 -0
- package/dist/git/checkout.d.ts +46 -0
- package/dist/git/checkout.js +126 -0
- package/dist/git/checkout.js.map +1 -0
- package/dist/git/cherry-pick.d.ts +82 -0
- package/dist/git/cherry-pick.js +371 -0
- package/dist/git/cherry-pick.js.map +1 -0
- package/dist/git/clean.d.ts +5 -0
- package/dist/git/clean.js +8 -0
- package/dist/git/clean.js.map +1 -0
- package/dist/git/clone.d.ts +22 -0
- package/dist/git/clone.js +58 -0
- package/dist/git/clone.js.map +1 -0
- package/dist/git/coerce-to-buffer.d.ts +1 -0
- package/dist/git/coerce-to-buffer.js +2 -0
- package/dist/git/coerce-to-buffer.js.map +1 -0
- package/dist/git/coerce-to-string.d.ts +1 -0
- package/dist/git/coerce-to-string.js +2 -0
- package/dist/git/coerce-to-string.js.map +1 -0
- package/dist/git/commit.d.ts +25 -0
- package/dist/git/commit.js +99 -0
- package/dist/git/commit.js.map +1 -0
- package/dist/git/config.d.ts +98 -0
- package/dist/git/config.js +249 -0
- package/dist/git/config.js.map +1 -0
- package/dist/git/core.d.ts +167 -0
- package/dist/git/core.js +368 -0
- package/dist/git/core.js.map +1 -0
- package/dist/git/create-tail-stream.d.ts +4 -0
- package/dist/git/create-tail-stream.js +30 -0
- package/dist/git/create-tail-stream.js.map +1 -0
- package/dist/git/credential.d.ts +5 -0
- package/dist/git/credential.js +64 -0
- package/dist/git/credential.js.map +1 -0
- package/dist/git/description.d.ts +5 -0
- package/dist/git/description.js +24 -0
- package/dist/git/description.js.map +1 -0
- package/dist/git/diff-check.d.ts +7 -0
- package/dist/git/diff-check.js +17 -0
- package/dist/git/diff-check.js.map +1 -0
- package/dist/git/diff-index.d.ts +31 -0
- package/dist/git/diff-index.js +76 -0
- package/dist/git/diff-index.js.map +1 -0
- package/dist/git/diff.d.ts +81 -0
- package/dist/git/diff.js +611 -0
- package/dist/git/diff.js.map +1 -0
- package/dist/git/environment.d.ts +51 -0
- package/dist/git/environment.js +97 -0
- package/dist/git/environment.js.map +1 -0
- package/dist/git/exec.d.ts +109 -0
- package/dist/git/exec.js +224 -0
- package/dist/git/exec.js.map +1 -0
- package/dist/git/fetch.d.ts +25 -0
- package/dist/git/fetch.js +100 -0
- package/dist/git/fetch.js.map +1 -0
- package/dist/git/for-each-ref.d.ts +13 -0
- package/dist/git/for-each-ref.js +114 -0
- package/dist/git/for-each-ref.js.map +1 -0
- package/dist/git/format-patch.d.ts +10 -0
- package/dist/git/format-patch.js +16 -0
- package/dist/git/format-patch.js.map +1 -0
- package/dist/git/git-delimiter-parser.d.ts +38 -0
- package/dist/git/git-delimiter-parser.js +79 -0
- package/dist/git/git-delimiter-parser.js.map +1 -0
- package/dist/git/gitignore.d.ts +26 -0
- package/dist/git/gitignore.js +124 -0
- package/dist/git/gitignore.js.map +1 -0
- package/dist/git/index.d.ts +46 -0
- package/dist/git/index.js +47 -0
- package/dist/git/index.js.map +1 -0
- package/dist/git/init.d.ts +2 -0
- package/dist/git/init.js +7 -0
- package/dist/git/init.js.map +1 -0
- package/{src/git/interpret-trailers.ts → dist/git/interpret-trailers.d.ts} +9 -97
- package/dist/git/interpret-trailers.js +130 -0
- package/dist/git/interpret-trailers.js.map +1 -0
- package/dist/git/lfs.d.ts +25 -0
- package/dist/git/lfs.js +73 -0
- package/dist/git/lfs.js.map +1 -0
- package/dist/git/log.d.ts +56 -0
- package/dist/git/log.js +258 -0
- package/dist/git/log.js.map +1 -0
- package/dist/git/merge-tree.d.ts +13 -0
- package/dist/git/merge-tree.js +24 -0
- package/dist/git/merge-tree.js.map +1 -0
- package/dist/git/merge.d.ts +50 -0
- package/dist/git/merge.js +111 -0
- package/dist/git/merge.js.map +1 -0
- package/dist/git/multi-operation-terminal-output.d.ts +20 -0
- package/dist/git/multi-operation-terminal-output.js +56 -0
- package/dist/git/multi-operation-terminal-output.js.map +1 -0
- package/dist/git/pull.d.ts +24 -0
- package/dist/git/pull.js +91 -0
- package/dist/git/pull.js.map +1 -0
- package/{src/git/push-terminal-chunk.ts → dist/git/push-terminal-chunk.d.ts} +1 -23
- package/dist/git/push-terminal-chunk.js +36 -0
- package/dist/git/push-terminal-chunk.js.map +1 -0
- package/dist/git/push.d.ts +42 -0
- package/dist/git/push.js +80 -0
- package/dist/git/push.js.map +1 -0
- package/dist/git/rebase.d.ts +119 -0
- package/dist/git/rebase.js +415 -0
- package/dist/git/rebase.js.map +1 -0
- package/dist/git/reflog.d.ts +14 -0
- package/dist/git/reflog.js +88 -0
- package/dist/git/reflog.js.map +1 -0
- package/dist/git/refs.d.ts +26 -0
- package/dist/git/refs.js +53 -0
- package/dist/git/refs.js.map +1 -0
- package/dist/git/remote.d.ts +31 -0
- package/dist/git/remote.js +81 -0
- package/dist/git/remote.js.map +1 -0
- package/dist/git/reorder.d.ts +23 -0
- package/dist/git/reorder.js +111 -0
- package/dist/git/reorder.js.map +1 -0
- package/dist/git/reset.d.ts +41 -0
- package/dist/git/reset.js +86 -0
- package/dist/git/reset.js.map +1 -0
- package/dist/git/rev-list.d.ts +67 -0
- package/dist/git/rev-list.js +157 -0
- package/dist/git/rev-list.js.map +1 -0
- package/dist/git/rev-parse.d.ts +24 -0
- package/dist/git/rev-parse.js +65 -0
- package/dist/git/rev-parse.js.map +1 -0
- package/dist/git/revert.d.ts +12 -0
- package/dist/git/revert.js +30 -0
- package/dist/git/revert.js.map +1 -0
- package/dist/git/rm.d.ts +12 -0
- package/dist/git/rm.js +22 -0
- package/dist/git/rm.js.map +1 -0
- package/dist/git/show.d.ts +42 -0
- package/{src/git/show.ts → dist/git/show.js} +17 -46
- package/dist/git/show.js.map +1 -0
- package/dist/git/spawn.d.ts +18 -0
- package/dist/git/spawn.js +16 -0
- package/dist/git/spawn.js.map +1 -0
- package/dist/git/squash.d.ts +28 -0
- package/dist/git/squash.js +127 -0
- package/dist/git/squash.js.map +1 -0
- package/dist/git/stage.d.ts +21 -0
- package/dist/git/stage.js +72 -0
- package/dist/git/stage.js.map +1 -0
- package/dist/git/stash.d.ts +53 -0
- package/dist/git/stash.js +204 -0
- package/dist/git/stash.js.map +1 -0
- package/dist/git/status.d.ts +39 -0
- package/dist/git/status.js +293 -0
- package/dist/git/status.js.map +1 -0
- package/dist/git/submodule.d.ts +20 -0
- package/dist/git/submodule.js +153 -0
- package/dist/git/submodule.js.map +1 -0
- package/dist/git/tag.d.ts +32 -0
- package/dist/git/tag.js +101 -0
- package/dist/git/tag.js.map +1 -0
- package/dist/git/update-index.d.ts +11 -0
- package/dist/git/update-index.js +99 -0
- package/dist/git/update-index.js.map +1 -0
- package/dist/git/update-ref.d.ts +23 -0
- package/{src/git/update-ref.ts → dist/git/update-ref.js} +10 -28
- package/dist/git/update-ref.js.map +1 -0
- package/dist/git/var.d.ts +18 -0
- package/{src/git/var.ts → dist/git/var.js} +16 -25
- package/dist/git/var.js.map +1 -0
- package/dist/git/worktree-include.d.ts +42 -0
- package/dist/git/worktree-include.js +109 -0
- package/dist/git/worktree-include.js.map +1 -0
- package/dist/git/worktree.d.ts +25 -0
- package/dist/git/worktree.js +139 -0
- package/dist/git/worktree.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +2 -0
- package/dist/lib/api.js +7 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/diff-parser.d.ts +20 -0
- package/dist/lib/diff-parser.js +184 -0
- package/dist/lib/diff-parser.js.map +1 -0
- package/dist/lib/directory-exists.d.ts +1 -0
- package/dist/lib/directory-exists.js +11 -0
- package/dist/lib/directory-exists.js.map +1 -0
- package/dist/lib/errno-exception.d.ts +6 -0
- package/dist/lib/errno-exception.js +6 -0
- package/dist/lib/errno-exception.js.map +1 -0
- package/dist/lib/fatal-error.d.ts +4 -0
- package/dist/lib/fatal-error.js +18 -0
- package/dist/lib/fatal-error.js.map +1 -0
- package/dist/lib/feature-flag.d.ts +14 -0
- package/dist/lib/feature-flag.js +25 -0
- package/dist/lib/feature-flag.js.map +1 -0
- package/dist/lib/file-system.d.ts +1 -0
- package/dist/lib/file-system.js +7 -0
- package/dist/lib/file-system.js.map +1 -0
- package/dist/lib/get-old-path.d.ts +2 -0
- package/dist/lib/get-old-path.js +9 -0
- package/dist/lib/get-old-path.js.map +1 -0
- package/dist/lib/git/environment.d.ts +3 -0
- package/dist/lib/git/environment.js +7 -0
- package/dist/lib/git/environment.js.map +1 -0
- package/dist/lib/git-perf.d.ts +1 -0
- package/dist/lib/git-perf.js +4 -0
- package/dist/lib/git-perf.js.map +1 -0
- package/dist/lib/helpers/default-branch.d.ts +1 -0
- package/dist/lib/helpers/default-branch.js +4 -0
- package/dist/lib/helpers/default-branch.js.map +1 -0
- package/dist/lib/helpers/path.d.ts +1 -0
- package/dist/lib/helpers/path.js +5 -0
- package/dist/lib/helpers/path.js.map +1 -0
- package/dist/lib/hooks/with-hooks-env.d.ts +3 -0
- package/dist/lib/hooks/with-hooks-env.js +4 -0
- package/dist/lib/hooks/with-hooks-env.js.map +1 -0
- package/dist/lib/merge.d.ts +1 -0
- package/dist/lib/merge.js +4 -0
- package/dist/lib/merge.js.map +1 -0
- package/dist/lib/noop.d.ts +1 -0
- package/dist/lib/noop.js +2 -0
- package/dist/lib/noop.js.map +1 -0
- package/dist/lib/patch-formatter.d.ts +5 -0
- package/dist/lib/patch-formatter.js +7 -0
- package/dist/lib/patch-formatter.js.map +1 -0
- package/dist/lib/path-exists.d.ts +1 -0
- package/dist/lib/path-exists.js +3 -0
- package/dist/lib/path-exists.js.map +1 -0
- package/dist/lib/progress/from-process.d.ts +2 -0
- package/dist/lib/progress/from-process.js +4 -0
- package/dist/lib/progress/from-process.js.map +1 -0
- package/dist/lib/progress/index.d.ts +49 -0
- package/dist/lib/progress/index.js +32 -0
- package/dist/lib/progress/index.js.map +1 -0
- package/dist/lib/progress/revert.d.ts +8 -0
- package/dist/lib/progress/revert.js +15 -0
- package/dist/lib/progress/revert.js.map +1 -0
- package/dist/lib/rebase.d.ts +1 -0
- package/dist/lib/rebase.js +4 -0
- package/dist/lib/rebase.js.map +1 -0
- package/dist/lib/remove-remote-prefix.d.ts +1 -0
- package/dist/lib/remove-remote-prefix.js +5 -0
- package/dist/lib/remove-remote-prefix.js.map +1 -0
- package/dist/lib/resolve-git-proxy.d.ts +1 -0
- package/dist/lib/resolve-git-proxy.js +4 -0
- package/dist/lib/resolve-git-proxy.js.map +1 -0
- package/dist/lib/round.d.ts +1 -0
- package/dist/lib/round.js +5 -0
- package/dist/lib/round.js.map +1 -0
- package/dist/lib/split-buffer.d.ts +1 -0
- package/dist/lib/split-buffer.js +15 -0
- package/dist/lib/split-buffer.js.map +1 -0
- package/dist/lib/status-parser.d.ts +19 -0
- package/dist/lib/status-parser.js +125 -0
- package/dist/lib/status-parser.js.map +1 -0
- package/dist/lib/stores/helpers/find-default-remote.d.ts +1 -0
- package/dist/lib/stores/helpers/find-default-remote.js +4 -0
- package/dist/lib/stores/helpers/find-default-remote.js.map +1 -0
- package/dist/lib/trampoline/trampoline-environment.d.ts +1 -0
- package/dist/lib/trampoline/trampoline-environment.js +4 -0
- package/dist/lib/trampoline/trampoline-environment.js.map +1 -0
- package/dist/models/branch.d.ts +44 -0
- package/dist/models/branch.js +59 -0
- package/dist/models/branch.js.map +1 -0
- package/dist/models/cherry-pick.d.ts +11 -0
- package/dist/models/cherry-pick.js +2 -0
- package/dist/models/cherry-pick.js.map +1 -0
- package/dist/models/clone-options.d.ts +6 -0
- package/dist/models/clone-options.js +2 -0
- package/dist/models/clone-options.js.map +1 -0
- package/dist/models/commit-identity.d.ts +9 -0
- package/dist/models/commit-identity.js +34 -0
- package/dist/models/commit-identity.js.map +1 -0
- package/dist/models/commit.d.ts +30 -0
- package/dist/models/commit.js +32 -0
- package/dist/models/commit.js.map +1 -0
- package/dist/models/computed-action.d.ts +6 -0
- package/dist/models/computed-action.js +8 -0
- package/dist/models/computed-action.js.map +1 -0
- package/dist/models/diff/diff-data.d.ts +53 -0
- package/dist/models/diff/diff-data.js +19 -0
- package/dist/models/diff/diff-data.js.map +1 -0
- package/dist/models/diff/diff-line.d.ts +18 -0
- package/dist/models/diff/diff-line.js +33 -0
- package/dist/models/diff/diff-line.js.map +1 -0
- package/dist/models/diff/diff-selection.d.ts +22 -0
- package/dist/models/diff/diff-selection.js +127 -0
- package/dist/models/diff/diff-selection.js.map +1 -0
- package/dist/models/diff/image-diff.d.ts +6 -0
- package/dist/models/diff/image-diff.js +8 -0
- package/dist/models/diff/image-diff.js.map +1 -0
- package/dist/models/diff/image.d.ts +7 -0
- package/dist/models/diff/image.js +13 -0
- package/dist/models/diff/image.js.map +1 -0
- package/dist/models/diff/index.d.ts +6 -0
- package/dist/models/diff/index.js +7 -0
- package/dist/models/diff/index.js.map +1 -0
- package/dist/models/diff/raw-diff.d.ts +32 -0
- package/dist/models/diff/raw-diff.js +38 -0
- package/dist/models/diff/raw-diff.js.map +1 -0
- package/dist/models/git-author.d.ts +7 -0
- package/dist/models/git-author.js +18 -0
- package/dist/models/git-author.js.map +1 -0
- package/dist/models/index.d.ts +21 -0
- package/dist/models/index.js +20 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/manual-conflict-resolution.d.ts +4 -0
- package/dist/models/manual-conflict-resolution.js +6 -0
- package/dist/models/manual-conflict-resolution.js.map +1 -0
- package/dist/models/merge.d.ts +6 -0
- package/dist/models/merge.js +2 -0
- package/dist/models/merge.js.map +1 -0
- package/dist/models/multi-commit-operation.d.ts +6 -0
- package/dist/models/multi-commit-operation.js +8 -0
- package/dist/models/multi-commit-operation.js.map +1 -0
- package/dist/models/progress.d.ts +41 -0
- package/dist/models/progress.js +7 -0
- package/dist/models/progress.js.map +1 -0
- package/dist/models/rebase.d.ts +17 -0
- package/dist/models/rebase.js +8 -0
- package/dist/models/rebase.js.map +1 -0
- package/dist/models/remote.d.ts +5 -0
- package/dist/models/remote.js +8 -0
- package/dist/models/remote.js.map +1 -0
- package/dist/models/repository.d.ts +7 -0
- package/dist/models/repository.js +15 -0
- package/dist/models/repository.js.map +1 -0
- package/dist/models/stash-entry.d.ts +20 -0
- package/dist/models/stash-entry.js +7 -0
- package/dist/models/stash-entry.js.map +1 -0
- package/dist/models/status.d.ts +166 -0
- package/dist/models/status.js +135 -0
- package/dist/models/status.js.map +1 -0
- package/dist/models/submodule.d.ts +12 -0
- package/dist/models/submodule.js +2 -0
- package/dist/models/submodule.js.map +1 -0
- package/dist/models/worktree.d.ts +10 -0
- package/dist/models/worktree.js +2 -0
- package/dist/models/worktree.js.map +1 -0
- package/package.json +44 -5
- package/examples/get-status.ts +0 -84
- package/src/git/add.ts +0 -16
- package/src/git/apply.ts +0 -154
- package/src/git/authentication.ts +0 -19
- package/src/git/branch.ts +0 -206
- package/src/git/checkout.ts +0 -235
- package/src/git/cherry-pick.ts +0 -504
- package/src/git/clean.ts +0 -9
- package/src/git/clone.ts +0 -86
- package/src/git/coerce-to-buffer.ts +0 -4
- package/src/git/coerce-to-string.ts +0 -4
- package/src/git/commit.ts +0 -136
- package/src/git/config.ts +0 -392
- package/src/git/core.ts +0 -625
- package/src/git/create-tail-stream.ts +0 -36
- package/src/git/credential.ts +0 -83
- package/src/git/description.ts +0 -33
- package/src/git/diff-check.ts +0 -27
- package/src/git/diff-index.ts +0 -116
- package/src/git/diff.ts +0 -880
- package/src/git/environment.ts +0 -116
- package/src/git/exec.ts +0 -285
- package/src/git/fetch.ts +0 -141
- package/src/git/for-each-ref.ts +0 -160
- package/src/git/format-patch.ts +0 -17
- package/src/git/git-delimiter-parser.ts +0 -95
- package/src/git/gitignore.ts +0 -157
- package/src/git/index.ts +0 -36
- package/src/git/init.ts +0 -11
- package/src/git/lfs.ts +0 -100
- package/src/git/log.ts +0 -376
- package/src/git/merge-tree.ts +0 -42
- package/src/git/merge.ts +0 -154
- package/src/git/multi-operation-terminal-output.ts +0 -68
- package/src/git/pull.ts +0 -130
- package/src/git/push.ts +0 -119
- package/src/git/rebase.ts +0 -627
- package/src/git/reflog.ts +0 -127
- package/src/git/refs.ts +0 -63
- package/src/git/remote.ts +0 -143
- package/src/git/reorder.ts +0 -153
- package/src/git/reset.ts +0 -101
- package/src/git/rev-list.ts +0 -201
- package/src/git/rev-parse.ts +0 -92
- package/src/git/revert.ts +0 -55
- package/src/git/rm.ts +0 -31
- package/src/git/spawn.ts +0 -38
- package/src/git/squash.ts +0 -173
- package/src/git/stage.ts +0 -97
- package/src/git/stash.ts +0 -302
- package/src/git/status.ts +0 -502
- package/src/git/submodule.ts +0 -212
- package/src/git/tag.ts +0 -134
- package/src/git/update-index.ts +0 -169
- package/src/git/worktree-include.ts +0 -146
- package/src/git/worktree.ts +0 -219
- package/src/index.ts +0 -23
- package/src/lib/api.ts +0 -7
- package/src/lib/diff-parser.ts +0 -249
- package/src/lib/directory-exists.ts +0 -10
- package/src/lib/errno-exception.ts +0 -12
- package/src/lib/fatal-error.ts +0 -23
- package/src/lib/feature-flag.ts +0 -29
- package/src/lib/file-system.ts +0 -7
- package/src/lib/get-old-path.ts +0 -11
- package/src/lib/git/environment.ts +0 -14
- package/src/lib/git-perf.ts +0 -3
- package/src/lib/helpers/default-branch.ts +0 -3
- package/src/lib/helpers/path.ts +0 -5
- package/src/lib/hooks/with-hooks-env.ts +0 -7
- package/src/lib/merge.ts +0 -3
- package/src/lib/noop.ts +0 -1
- package/src/lib/patch-formatter.ts +0 -18
- package/src/lib/path-exists.ts +0 -7
- package/src/lib/progress/from-process.ts +0 -10
- package/src/lib/progress/index.ts +0 -43
- package/src/lib/progress/revert.ts +0 -17
- package/src/lib/rebase.ts +0 -3
- package/src/lib/remove-remote-prefix.ts +0 -4
- package/src/lib/resolve-git-proxy.ts +0 -3
- package/src/lib/round.ts +0 -4
- package/src/lib/split-buffer.ts +0 -14
- package/src/lib/status-parser.ts +0 -188
- package/src/lib/stores/helpers/find-default-remote.ts +0 -3
- package/src/lib/trampoline/trampoline-environment.ts +0 -8
- package/src/models/branch.ts +0 -78
- package/src/models/cherry-pick.ts +0 -12
- package/src/models/clone-options.ts +0 -6
- package/src/models/commit-identity.ts +0 -35
- package/src/models/commit.ts +0 -44
- package/src/models/computed-action.ts +0 -6
- package/src/models/diff/diff-data.ts +0 -78
- package/src/models/diff/diff-line.ts +0 -36
- package/src/models/diff/diff-selection.ts +0 -165
- package/src/models/diff/image-diff.ts +0 -6
- package/src/models/diff/image.ts +0 -8
- package/src/models/diff/index.ts +0 -6
- package/src/models/diff/raw-diff.ts +0 -41
- package/src/models/git-author.ts +0 -16
- package/src/models/manual-conflict-resolution.ts +0 -4
- package/src/models/merge.ts +0 -6
- package/src/models/multi-commit-operation.ts +0 -6
- package/src/models/progress.ts +0 -67
- package/src/models/rebase.ts +0 -20
- package/src/models/remote.ts +0 -10
- package/src/models/repository.ts +0 -16
- package/src/models/stash-entry.ts +0 -25
- package/src/models/status.ts +0 -275
- package/src/models/submodule.ts +0 -13
- package/src/models/worktree.ts +0 -11
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { IStashEntry } from '../models/stash-entry.js';
|
|
3
|
+
import { WorkingDirectoryFileChange, CommittedFileChange } from '../models/status.js';
|
|
4
|
+
import { Branch } from '../models/branch.js';
|
|
5
|
+
export declare const DesktopStashEntryMarker = "!!GitHub_Desktop";
|
|
6
|
+
type StashResult = {
|
|
7
|
+
/** The stash entries created by Desktop */
|
|
8
|
+
readonly desktopEntries: ReadonlyArray<IStashEntry>;
|
|
9
|
+
/**
|
|
10
|
+
* The total amount of stash entries,
|
|
11
|
+
* i.e. stash entries created both by Desktop and outside of Desktop
|
|
12
|
+
*/
|
|
13
|
+
readonly stashEntryCount: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Get the list of stash entries created by Desktop in the current repository
|
|
17
|
+
* using the default ordering of refs (which is LIFO ordering),
|
|
18
|
+
* as well as the total amount of stash entries.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getStashes(repository: Repository): Promise<StashResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Moves a stash entry to a different branch by means of creating
|
|
23
|
+
* a new stash entry associated with the new branch and dropping the old
|
|
24
|
+
* stash entry.
|
|
25
|
+
*/
|
|
26
|
+
export declare function moveStashEntry(repository: Repository, { stashSha, parents, tree }: IStashEntry, branchName: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the last Desktop created stash entry for the given branch
|
|
29
|
+
*/
|
|
30
|
+
export declare function getLastDesktopStashEntryForBranch(repository: Repository, branch: Branch | string): Promise<IStashEntry | null>;
|
|
31
|
+
/** Creates a stash entry message that indicates the entry was created by Desktop */
|
|
32
|
+
export declare function createDesktopStashMessage(branchName: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Stash the working directory changes for the current branch
|
|
35
|
+
*/
|
|
36
|
+
export declare function createDesktopStashEntry(repository: Repository, branch: Branch | string, untrackedFilesToStage: ReadonlyArray<WorkingDirectoryFileChange>, selectedFiles: ReadonlyArray<string> | null): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Removes the given stash entry if it exists
|
|
39
|
+
*
|
|
40
|
+
* @param stashSha the SHA that identifies the stash entry
|
|
41
|
+
*/
|
|
42
|
+
export declare function dropDesktopStashEntry(repository: Repository, stashSha: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Pops the stash entry identified by matching `stashSha` to its commit hash.
|
|
45
|
+
*
|
|
46
|
+
* To see the commit hash of stash entry, run
|
|
47
|
+
* `git log -g refs/stash --pretty="%nentry: %gd%nsubject: %gs%nhash: %H%n"`
|
|
48
|
+
* in a repo with some stash entries.
|
|
49
|
+
*/
|
|
50
|
+
export declare function popStashEntry(repository: Repository, stashSha: string): Promise<void>;
|
|
51
|
+
/** Get the files that were changed in the given stash commit */
|
|
52
|
+
export declare function getStashedFiles(repository: Repository, stashSha: string): Promise<ReadonlyArray<CommittedFileChange>>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { GitError as DugiteError } from './exec.js';
|
|
2
|
+
import { git, GitError } from './core.js';
|
|
3
|
+
import { StashedChangesLoadStates, } from '../models/stash-entry.js';
|
|
4
|
+
import { parseRawLogWithNumstat } from './log.js';
|
|
5
|
+
import { stageFiles } from './update-index.js';
|
|
6
|
+
import { createLogParser } from './git-delimiter-parser.js';
|
|
7
|
+
import { coerceToString } from './coerce-to-string.js';
|
|
8
|
+
export const DesktopStashEntryMarker = '!!GitHub_Desktop';
|
|
9
|
+
/**
|
|
10
|
+
* RegEx for determining if a stash entry is created by Desktop
|
|
11
|
+
*
|
|
12
|
+
* This is done by looking for a magic string with the following
|
|
13
|
+
* format: `!!GitHub_Desktop<branch>`
|
|
14
|
+
*/
|
|
15
|
+
const desktopStashEntryMessageRe = /!!GitHub_Desktop<(.+)>$/;
|
|
16
|
+
/**
|
|
17
|
+
* Get the list of stash entries created by Desktop in the current repository
|
|
18
|
+
* using the default ordering of refs (which is LIFO ordering),
|
|
19
|
+
* as well as the total amount of stash entries.
|
|
20
|
+
*/
|
|
21
|
+
export async function getStashes(repository) {
|
|
22
|
+
const { formatArgs, parse } = createLogParser({
|
|
23
|
+
name: '%gD',
|
|
24
|
+
stashSha: '%H',
|
|
25
|
+
message: '%gs',
|
|
26
|
+
tree: '%T',
|
|
27
|
+
parents: '%P',
|
|
28
|
+
});
|
|
29
|
+
const result = await git(['log', '-g', ...formatArgs, 'refs/stash', '--'], repository.path, 'getStashEntries', { successExitCodes: new Set([0, 128]) });
|
|
30
|
+
// There's no refs/stashes reflog in the repository or it's not
|
|
31
|
+
// even a repository. In either case we don't care
|
|
32
|
+
if (result.exitCode === 128) {
|
|
33
|
+
return { desktopEntries: [], stashEntryCount: 0 };
|
|
34
|
+
}
|
|
35
|
+
const desktopEntries = [];
|
|
36
|
+
const files = { kind: StashedChangesLoadStates.NotLoaded };
|
|
37
|
+
const entries = parse(result.stdout);
|
|
38
|
+
for (const { name, message, stashSha, tree, parents } of entries) {
|
|
39
|
+
const branchName = extractBranchFromMessage(message);
|
|
40
|
+
if (branchName !== null) {
|
|
41
|
+
desktopEntries.push({
|
|
42
|
+
name,
|
|
43
|
+
stashSha,
|
|
44
|
+
branchName,
|
|
45
|
+
tree,
|
|
46
|
+
parents: parents.length > 0 ? parents.split(' ') : [],
|
|
47
|
+
files,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { desktopEntries, stashEntryCount: entries.length - 1 };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Moves a stash entry to a different branch by means of creating
|
|
55
|
+
* a new stash entry associated with the new branch and dropping the old
|
|
56
|
+
* stash entry.
|
|
57
|
+
*/
|
|
58
|
+
export async function moveStashEntry(repository, { stashSha, parents, tree }, branchName) {
|
|
59
|
+
const message = `On ${branchName}: ${createDesktopStashMessage(branchName)}`;
|
|
60
|
+
const parentArgs = parents.flatMap(p => ['-p', p]);
|
|
61
|
+
const { stdout: commitId } = await git(['commit-tree', ...parentArgs, '-m', message, '--no-gpg-sign', tree], repository.path, 'moveStashEntryToBranch');
|
|
62
|
+
await git(['stash', 'store', '-m', message, commitId.trim()], repository.path, 'moveStashEntryToBranch');
|
|
63
|
+
await dropDesktopStashEntry(repository, stashSha);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the last Desktop created stash entry for the given branch
|
|
67
|
+
*/
|
|
68
|
+
export async function getLastDesktopStashEntryForBranch(repository, branch) {
|
|
69
|
+
const stash = await getStashes(repository);
|
|
70
|
+
const branchName = typeof branch === 'string' ? branch : branch.name;
|
|
71
|
+
// Since stash objects are returned in a LIFO manner, the first
|
|
72
|
+
// entry found is guaranteed to be the last entry created
|
|
73
|
+
return (stash.desktopEntries.find(stash => stash.branchName === branchName) || null);
|
|
74
|
+
}
|
|
75
|
+
/** Creates a stash entry message that indicates the entry was created by Desktop */
|
|
76
|
+
export function createDesktopStashMessage(branchName) {
|
|
77
|
+
return `${DesktopStashEntryMarker}<${branchName}>`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Stash the working directory changes for the current branch
|
|
81
|
+
*/
|
|
82
|
+
export async function createDesktopStashEntry(repository, branch, untrackedFilesToStage, selectedFiles) {
|
|
83
|
+
// We must ensure that no untracked files are present before stashing
|
|
84
|
+
// See https://github.com/desktop/desktop/pull/8085
|
|
85
|
+
// First ensure that all changes in file are selected
|
|
86
|
+
// (in case the user has not explicitly checked the checkboxes for the untracked files)
|
|
87
|
+
const fullySelectedUntrackedFiles = untrackedFilesToStage
|
|
88
|
+
.filter(f => (selectedFiles ? selectedFiles.includes(f.path) : true))
|
|
89
|
+
.map(x => x.withIncludeAll(true));
|
|
90
|
+
await stageFiles(repository, fullySelectedUntrackedFiles);
|
|
91
|
+
const branchName = typeof branch === 'string' ? branch : branch.name;
|
|
92
|
+
const message = createDesktopStashMessage(branchName);
|
|
93
|
+
const args = ['stash', 'push', '-m', message];
|
|
94
|
+
if (selectedFiles) {
|
|
95
|
+
args.push(...selectedFiles);
|
|
96
|
+
}
|
|
97
|
+
const result = await git(args, repository.path, 'createStashEntry').catch(e => {
|
|
98
|
+
// Note: 2024: Here be dragons. As I converted this code to get rid of the
|
|
99
|
+
// successExitCode use I got curious about the assumptions made in the
|
|
100
|
+
// following logic. It assumes that as long as the exit code for `git
|
|
101
|
+
// stash push` is 1 and there are no lines beginning with "error: " then
|
|
102
|
+
// a stash was created. That didn't hold up to a quick read of the stash
|
|
103
|
+
// code. For example, running git stash push in an unborn repository will
|
|
104
|
+
// get you an exit code of 1 but no stash was created:
|
|
105
|
+
//
|
|
106
|
+
// % git stash push -m foo ; echo $?
|
|
107
|
+
// You do not have the initial commit yet
|
|
108
|
+
// 1
|
|
109
|
+
//
|
|
110
|
+
// I'm not going to mess with this now but I felt the need to document
|
|
111
|
+
// my findings should I or any other brave soul choose to tackle this in
|
|
112
|
+
// the future.
|
|
113
|
+
if (e instanceof GitError && e.result.exitCode === 1) {
|
|
114
|
+
// search for any line starting with `error:` - /m here to ensure this is
|
|
115
|
+
// applied to each line, without needing to split the text
|
|
116
|
+
const errorPrefixRe = /^error: /m;
|
|
117
|
+
const matches = errorPrefixRe.exec(coerceToString(e.result.stderr));
|
|
118
|
+
if (matches !== null && matches.length > 0) {
|
|
119
|
+
// rethrow, because these messages should prevent the stash from being created
|
|
120
|
+
return Promise.reject(e);
|
|
121
|
+
}
|
|
122
|
+
// if no error messages were emitted by Git, we should log but continue because
|
|
123
|
+
// a valid stash was created and this should not interfere with the checkout
|
|
124
|
+
console.info(`[createDesktopStashEntry] a stash was created successfully but exit code ${result.exitCode} reported. stderr: ${result.stderr}`);
|
|
125
|
+
return e.result;
|
|
126
|
+
}
|
|
127
|
+
return Promise.reject(e);
|
|
128
|
+
});
|
|
129
|
+
// Stash doesn't consider it an error that there aren't any local changes to save.
|
|
130
|
+
if (result.stdout === 'No local changes to save\n') {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
async function getStashEntryMatchingSha(repository, sha) {
|
|
136
|
+
const stash = await getStashes(repository);
|
|
137
|
+
return stash.desktopEntries.find(e => e.stashSha === sha) || null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Removes the given stash entry if it exists
|
|
141
|
+
*
|
|
142
|
+
* @param stashSha the SHA that identifies the stash entry
|
|
143
|
+
*/
|
|
144
|
+
export async function dropDesktopStashEntry(repository, stashSha) {
|
|
145
|
+
const entryToDelete = await getStashEntryMatchingSha(repository, stashSha);
|
|
146
|
+
if (entryToDelete !== null) {
|
|
147
|
+
const args = ['stash', 'drop', entryToDelete.name];
|
|
148
|
+
await git(args, repository.path, 'dropStashEntry');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Pops the stash entry identified by matching `stashSha` to its commit hash.
|
|
153
|
+
*
|
|
154
|
+
* To see the commit hash of stash entry, run
|
|
155
|
+
* `git log -g refs/stash --pretty="%nentry: %gd%nsubject: %gs%nhash: %H%n"`
|
|
156
|
+
* in a repo with some stash entries.
|
|
157
|
+
*/
|
|
158
|
+
export async function popStashEntry(repository, stashSha) {
|
|
159
|
+
// ignoring these git errors for now, this will change when we start
|
|
160
|
+
// implementing the stash conflict flow
|
|
161
|
+
const expectedErrors = new Set([DugiteError.MergeConflicts]);
|
|
162
|
+
const stashToPop = await getStashEntryMatchingSha(repository, stashSha);
|
|
163
|
+
if (stashToPop !== null) {
|
|
164
|
+
const args = ['stash', 'pop', '--quiet', `${stashToPop.name}`];
|
|
165
|
+
await git(args, repository.path, 'popStashEntry', {
|
|
166
|
+
expectedErrors,
|
|
167
|
+
}).catch(e => {
|
|
168
|
+
// popping a stashes that create conflicts in the working directory
|
|
169
|
+
// report an exit code of `1` and are not dropped after being applied.
|
|
170
|
+
// so, we check for this case and drop them manually unless there's
|
|
171
|
+
// anything in stderr as that could have prevented the stash from being
|
|
172
|
+
// popped. Not the greatest approach but stash isn't very communicative
|
|
173
|
+
if (e instanceof GitError &&
|
|
174
|
+
e.result.exitCode === 1 &&
|
|
175
|
+
e.result.stderr.length === 0) {
|
|
176
|
+
console.info(`[popStashEntry] a stash was popped successfully but exit code ${e.result.exitCode} reported.`);
|
|
177
|
+
// bye bye
|
|
178
|
+
return dropDesktopStashEntry(repository, stashSha);
|
|
179
|
+
}
|
|
180
|
+
return Promise.reject(e);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function extractBranchFromMessage(message) {
|
|
185
|
+
const match = desktopStashEntryMessageRe.exec(message);
|
|
186
|
+
return match === null || match[1].length === 0 ? null : match[1];
|
|
187
|
+
}
|
|
188
|
+
/** Get the files that were changed in the given stash commit */
|
|
189
|
+
export async function getStashedFiles(repository, stashSha) {
|
|
190
|
+
const args = [
|
|
191
|
+
'stash',
|
|
192
|
+
'show',
|
|
193
|
+
stashSha,
|
|
194
|
+
'--raw',
|
|
195
|
+
'--numstat',
|
|
196
|
+
'-z',
|
|
197
|
+
'--format=format:',
|
|
198
|
+
'--no-show-signature',
|
|
199
|
+
'--',
|
|
200
|
+
];
|
|
201
|
+
const { stdout } = await git(args, repository.path, 'getStashedFiles');
|
|
202
|
+
return parseRawLogWithNumstat(stdout, stashSha, `${stashSha}^`).files;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=stash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stash.js","sourceRoot":"","sources":["../../src/git/stash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAEL,wBAAwB,GAEzB,MAAM,0BAA0B,CAAA;AAKjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,yBAAyB,CA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AAC;gBACD,OAAO,CAAC,IAAI,CACV,iEAAiE,CAAC,CAAC,MAAM,CAAC,QAAQ,YAAY,CAC/F,CAAA;gBACD,UAAU;gBACV,OAAO,qBAAqB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YACpD,CAAC;YACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAe;IAC/C,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClE,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAAsB,EACtB,QAAgB;IAEhB,MAAM,IAAI,GAAG;QACX,OAAO;QACP,MAAM;QACN,QAAQ;QACR,OAAO;QACP,WAAW;QACX,IAAI;QACJ,kBAAkB;QAClB,qBAAqB;QACrB,IAAI;KACL,CAAA;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;IAEtE,OAAO,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAA;AACvE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { WorkingDirectoryStatus } from '../models/status.js';
|
|
2
|
+
import { Repository } from '../models/repository.js';
|
|
3
|
+
import { IAheadBehind } from '../models/branch.js';
|
|
4
|
+
import { RebaseInternalState } from '../models/rebase.js';
|
|
5
|
+
/** The encapsulation of the result from 'git status' */
|
|
6
|
+
export interface IStatusResult {
|
|
7
|
+
/** The name of the current branch */
|
|
8
|
+
readonly currentBranch?: string;
|
|
9
|
+
/** The name of the current upstream branch */
|
|
10
|
+
readonly currentUpstreamBranch?: string;
|
|
11
|
+
/** The SHA of the tip commit of the current branch */
|
|
12
|
+
readonly currentTip?: string;
|
|
13
|
+
/** How many commits ahead and behind
|
|
14
|
+
* the `currentBranch` is compared to the `currentUpstreamBranch`
|
|
15
|
+
*/
|
|
16
|
+
readonly branchAheadBehind?: IAheadBehind;
|
|
17
|
+
/** true if the repository exists at the given location */
|
|
18
|
+
readonly exists: boolean;
|
|
19
|
+
/** true if repository is in a conflicted state */
|
|
20
|
+
readonly mergeHeadFound: boolean;
|
|
21
|
+
/** true merge --squash operation started */
|
|
22
|
+
readonly squashMsgFound: boolean;
|
|
23
|
+
/** details about the rebase operation, if found */
|
|
24
|
+
readonly rebaseInternalState: RebaseInternalState | null;
|
|
25
|
+
/** true if repository is in cherry pick state */
|
|
26
|
+
readonly isCherryPickingHeadFound: boolean;
|
|
27
|
+
/** the absolute path to the repository's working directory */
|
|
28
|
+
readonly workingDirectory: WorkingDirectoryStatus;
|
|
29
|
+
/** whether conflicting files present on repository */
|
|
30
|
+
readonly doConflictedFilesExist: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieve the status for a given repository,
|
|
34
|
+
* and fail gracefully if the location is not a Git repository
|
|
35
|
+
*/
|
|
36
|
+
export declare function getStatus(repository: Repository): Promise<IStatusResult | null>;
|
|
37
|
+
export declare function getStatus(repository: Repository, includeUntracked: boolean): Promise<IStatusResult | null>;
|
|
38
|
+
export declare function getStatus(repository: Repository, includeUntracked: boolean, rejectOnError: true): Promise<IStatusResult>;
|
|
39
|
+
export declare function getStatus(repository: Repository, includeUntracked: boolean, rejectOnError: false): Promise<IStatusResult | null>;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { getFilesWithConflictMarkers } from './diff-check.js';
|
|
2
|
+
import { WorkingDirectoryStatus, WorkingDirectoryFileChange, GitStatusEntry, AppFileStatusKind, UnmergedEntrySummary, } from '../models/status.js';
|
|
3
|
+
import { parsePorcelainStatus, mapStatus, isStatusHeader, isStatusEntry, } from '../lib/status-parser.js';
|
|
4
|
+
import { DiffSelectionType, DiffSelection } from '../models/diff/index.js';
|
|
5
|
+
import { fatalError } from '../lib/fatal-error.js';
|
|
6
|
+
import { isMergeHeadSet, isSquashMsgSet } from './merge.js';
|
|
7
|
+
import { getBinaryPaths } from './diff.js';
|
|
8
|
+
import { getRebaseInternalState } from './rebase.js';
|
|
9
|
+
import { isCherryPickHeadFound } from './cherry-pick.js';
|
|
10
|
+
import { git } from './index.js';
|
|
11
|
+
function parseConflictedState(entry, path, conflictDetails) {
|
|
12
|
+
switch (entry.action) {
|
|
13
|
+
case UnmergedEntrySummary.BothAdded: {
|
|
14
|
+
const isBinary = conflictDetails.binaryFilePaths.includes(path);
|
|
15
|
+
if (!isBinary) {
|
|
16
|
+
return {
|
|
17
|
+
kind: AppFileStatusKind.Conflicted,
|
|
18
|
+
entry,
|
|
19
|
+
conflictMarkerCount: conflictDetails.conflictCountsByPath.get(path) || 0,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return {
|
|
24
|
+
kind: AppFileStatusKind.Conflicted,
|
|
25
|
+
entry,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
case UnmergedEntrySummary.BothModified: {
|
|
30
|
+
const isBinary = conflictDetails.binaryFilePaths.includes(path);
|
|
31
|
+
if (!isBinary) {
|
|
32
|
+
return {
|
|
33
|
+
kind: AppFileStatusKind.Conflicted,
|
|
34
|
+
entry,
|
|
35
|
+
conflictMarkerCount: conflictDetails.conflictCountsByPath.get(path) || 0,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return {
|
|
40
|
+
kind: AppFileStatusKind.Conflicted,
|
|
41
|
+
entry,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
default:
|
|
46
|
+
return {
|
|
47
|
+
kind: AppFileStatusKind.Conflicted,
|
|
48
|
+
entry,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function convertToAppStatus(path, entry, conflictDetails, oldPath) {
|
|
53
|
+
if (entry.kind === 'ordinary') {
|
|
54
|
+
switch (entry.type) {
|
|
55
|
+
case 'added':
|
|
56
|
+
return {
|
|
57
|
+
kind: AppFileStatusKind.New,
|
|
58
|
+
submoduleStatus: entry.submoduleStatus,
|
|
59
|
+
};
|
|
60
|
+
case 'modified':
|
|
61
|
+
return {
|
|
62
|
+
kind: AppFileStatusKind.Modified,
|
|
63
|
+
submoduleStatus: entry.submoduleStatus,
|
|
64
|
+
};
|
|
65
|
+
case 'deleted':
|
|
66
|
+
return {
|
|
67
|
+
kind: AppFileStatusKind.Deleted,
|
|
68
|
+
submoduleStatus: entry.submoduleStatus,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (entry.kind === 'copied' && oldPath != null) {
|
|
73
|
+
return {
|
|
74
|
+
kind: AppFileStatusKind.Copied,
|
|
75
|
+
oldPath,
|
|
76
|
+
submoduleStatus: entry.submoduleStatus,
|
|
77
|
+
renameIncludesModifications: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
else if (entry.kind === 'renamed' && oldPath != null) {
|
|
81
|
+
return {
|
|
82
|
+
kind: AppFileStatusKind.Renamed,
|
|
83
|
+
oldPath,
|
|
84
|
+
submoduleStatus: entry.submoduleStatus,
|
|
85
|
+
renameIncludesModifications: entry.workingTree === GitStatusEntry.Modified ||
|
|
86
|
+
(entry.renameOrCopyScore !== undefined &&
|
|
87
|
+
entry.renameOrCopyScore < 100),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
else if (entry.kind === 'untracked') {
|
|
91
|
+
return {
|
|
92
|
+
kind: AppFileStatusKind.Untracked,
|
|
93
|
+
submoduleStatus: entry.submoduleStatus,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
else if (entry.kind === 'conflicted') {
|
|
97
|
+
return parseConflictedState(entry, path, conflictDetails);
|
|
98
|
+
}
|
|
99
|
+
return fatalError(`Unknown file status ${status}`);
|
|
100
|
+
}
|
|
101
|
+
// List of known conflicted index entries for a file, extracted from mapStatus
|
|
102
|
+
// inside `app/src/lib/status-parser.ts` for convenience
|
|
103
|
+
const conflictStatusCodes = ['DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU'];
|
|
104
|
+
export async function getStatus(repository, includeUntracked = true, rejectOnError = false) {
|
|
105
|
+
const args = [
|
|
106
|
+
'--no-optional-locks',
|
|
107
|
+
'status',
|
|
108
|
+
...(includeUntracked ? ['--untracked-files=all'] : []),
|
|
109
|
+
'--branch',
|
|
110
|
+
'--porcelain=2',
|
|
111
|
+
'-z',
|
|
112
|
+
];
|
|
113
|
+
const { stdout, exitCode } = await git(args, repository.path, 'getStatus', {
|
|
114
|
+
successExitCodes: new Set(rejectOnError ? [0] : [0, 128]),
|
|
115
|
+
encoding: 'buffer',
|
|
116
|
+
});
|
|
117
|
+
if (exitCode === 128) {
|
|
118
|
+
console.debug(`'git status' returned 128 for '${repository.path}' and is likely missing its .git directory`);
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const parsed = parsePorcelainStatus(stdout);
|
|
122
|
+
const headers = parsed.filter(isStatusHeader);
|
|
123
|
+
const entries = parsed.filter(isStatusEntry);
|
|
124
|
+
const mergeHeadFound = await isMergeHeadSet(repository);
|
|
125
|
+
const conflictedFilesInIndex = entries.filter(e => conflictStatusCodes.includes(e.statusCode));
|
|
126
|
+
const rebaseInternalState = await getRebaseInternalState(repository);
|
|
127
|
+
const conflictDetails = await getConflictDetails(repository, mergeHeadFound, conflictedFilesInIndex, rebaseInternalState);
|
|
128
|
+
// Map of files keyed on their paths.
|
|
129
|
+
const files = entries.reduce((files, entry) => buildStatusMap(files, entry, conflictDetails), new Map());
|
|
130
|
+
const { currentBranch, currentUpstreamBranch, currentTip, branchAheadBehind, } = headers.reduce(parseStatusHeader, {
|
|
131
|
+
currentBranch: undefined,
|
|
132
|
+
currentUpstreamBranch: undefined,
|
|
133
|
+
currentTip: undefined,
|
|
134
|
+
branchAheadBehind: undefined,
|
|
135
|
+
match: null,
|
|
136
|
+
});
|
|
137
|
+
const workingDirectory = WorkingDirectoryStatus.fromFiles([...files.values()]);
|
|
138
|
+
const isCherryPickingHeadFound = await isCherryPickHeadFound(repository);
|
|
139
|
+
const squashMsgFound = await isSquashMsgSet(repository);
|
|
140
|
+
return {
|
|
141
|
+
currentBranch,
|
|
142
|
+
currentTip,
|
|
143
|
+
currentUpstreamBranch,
|
|
144
|
+
branchAheadBehind,
|
|
145
|
+
exists: true,
|
|
146
|
+
mergeHeadFound,
|
|
147
|
+
rebaseInternalState,
|
|
148
|
+
workingDirectory,
|
|
149
|
+
isCherryPickingHeadFound,
|
|
150
|
+
squashMsgFound,
|
|
151
|
+
doConflictedFilesExist: conflictedFilesInIndex.length > 0,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* Update map of working directory changes with a file status entry.
|
|
157
|
+
* Reducer(ish).
|
|
158
|
+
*
|
|
159
|
+
* (Map is used here to maintain insertion order.)
|
|
160
|
+
*/
|
|
161
|
+
function buildStatusMap(files, entry, conflictDetails) {
|
|
162
|
+
const status = mapStatus(entry.statusCode, entry.submoduleStatusCode, entry.renameOrCopyScore);
|
|
163
|
+
if (status.kind === 'ordinary') {
|
|
164
|
+
// when a file is added in the index but then removed in the working
|
|
165
|
+
// directory, the file won't be part of the commit, so we can skip
|
|
166
|
+
// displaying this entry in the changes list
|
|
167
|
+
if (status.index === GitStatusEntry.Added &&
|
|
168
|
+
status.workingTree === GitStatusEntry.Deleted) {
|
|
169
|
+
return files;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (status.kind === 'untracked') {
|
|
173
|
+
// when a delete has been staged, but an untracked file exists with the
|
|
174
|
+
// same path, we should ensure that we only draw one entry in the
|
|
175
|
+
// changes list - see if an entry already exists for this path and
|
|
176
|
+
// remove it if found
|
|
177
|
+
files.delete(entry.path);
|
|
178
|
+
}
|
|
179
|
+
// for now we just poke at the existing summary
|
|
180
|
+
const appStatus = convertToAppStatus(entry.path, status, conflictDetails, entry.oldPath);
|
|
181
|
+
const initialSelectionType = appStatus.kind === AppFileStatusKind.Modified &&
|
|
182
|
+
appStatus.submoduleStatus !== undefined &&
|
|
183
|
+
!appStatus.submoduleStatus.commitChanged
|
|
184
|
+
? DiffSelectionType.None
|
|
185
|
+
: DiffSelectionType.All;
|
|
186
|
+
const selection = DiffSelection.fromInitialSelection(initialSelectionType);
|
|
187
|
+
files.set(entry.path, new WorkingDirectoryFileChange(entry.path, appStatus, selection));
|
|
188
|
+
return files;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Update status header based on the current header entry.
|
|
192
|
+
* Reducer.
|
|
193
|
+
*/
|
|
194
|
+
function parseStatusHeader(results, header) {
|
|
195
|
+
let { currentBranch, currentUpstreamBranch, currentTip, branchAheadBehind, match, } = results;
|
|
196
|
+
const value = header.value;
|
|
197
|
+
// This intentionally does not match branch.oid initial
|
|
198
|
+
if ((match = value.match(/^branch\.oid ([a-f0-9]+)$/))) {
|
|
199
|
+
currentTip = match[1];
|
|
200
|
+
}
|
|
201
|
+
else if ((match = value.match(/^branch.head (.*)/))) {
|
|
202
|
+
if (match[1] !== '(detached)') {
|
|
203
|
+
currentBranch = match[1];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if ((match = value.match(/^branch.upstream (.*)/))) {
|
|
207
|
+
currentUpstreamBranch = match[1];
|
|
208
|
+
}
|
|
209
|
+
else if ((match = value.match(/^branch.ab \+(\d+) -(\d+)$/))) {
|
|
210
|
+
const ahead = parseInt(match[1], 10);
|
|
211
|
+
const behind = parseInt(match[2], 10);
|
|
212
|
+
if (!isNaN(ahead) && !isNaN(behind)) {
|
|
213
|
+
branchAheadBehind = { ahead, behind };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
currentBranch,
|
|
218
|
+
currentUpstreamBranch,
|
|
219
|
+
currentTip,
|
|
220
|
+
branchAheadBehind,
|
|
221
|
+
match,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
async function getMergeConflictDetails(repository, conflictedFilesInIndex) {
|
|
225
|
+
const conflictCountsByPath = await getFilesWithConflictMarkers(repository.path);
|
|
226
|
+
const binaryFilePaths = await getBinaryPaths(repository, 'MERGE_HEAD', conflictedFilesInIndex);
|
|
227
|
+
return {
|
|
228
|
+
conflictCountsByPath,
|
|
229
|
+
binaryFilePaths,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async function getRebaseConflictDetails(repository, conflictedFilesInIndex) {
|
|
233
|
+
const conflictCountsByPath = await getFilesWithConflictMarkers(repository.path);
|
|
234
|
+
const binaryFilePaths = await getBinaryPaths(repository, 'REBASE_HEAD', conflictedFilesInIndex);
|
|
235
|
+
return {
|
|
236
|
+
conflictCountsByPath,
|
|
237
|
+
binaryFilePaths,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* We need to do these operations to detect conflicts that were the result
|
|
242
|
+
* of popping a stash into the index
|
|
243
|
+
*/
|
|
244
|
+
async function getWorkingDirectoryConflictDetails(repository, conflictedFilesInIndex) {
|
|
245
|
+
const conflictCountsByPath = await getFilesWithConflictMarkers(repository.path);
|
|
246
|
+
let binaryFilePaths = [];
|
|
247
|
+
try {
|
|
248
|
+
// its totally fine if HEAD doesn't exist, which throws an error
|
|
249
|
+
binaryFilePaths = await getBinaryPaths(repository, 'HEAD', conflictedFilesInIndex);
|
|
250
|
+
}
|
|
251
|
+
catch (error) { }
|
|
252
|
+
return {
|
|
253
|
+
conflictCountsByPath,
|
|
254
|
+
binaryFilePaths,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* gets the conflicted files count and binary file paths in a given repository.
|
|
259
|
+
* for computing an `IStatusResult`.
|
|
260
|
+
*
|
|
261
|
+
* @param repository to get details from
|
|
262
|
+
* @param mergeHeadFound whether a merge conflict has been detected
|
|
263
|
+
* @param conflictedFilesInIndex all files marked as being conflicted in the
|
|
264
|
+
* index. Used to check for files using the binary
|
|
265
|
+
* merge driver and whether it looks like a stash
|
|
266
|
+
* has introduced conflicts
|
|
267
|
+
* @param rebaseInternalState details about the current rebase operation (if
|
|
268
|
+
* found)
|
|
269
|
+
*/
|
|
270
|
+
async function getConflictDetails(repository, mergeHeadFound, conflictedFilesInIndex, rebaseInternalState) {
|
|
271
|
+
try {
|
|
272
|
+
if (mergeHeadFound) {
|
|
273
|
+
return await getMergeConflictDetails(repository, conflictedFilesInIndex);
|
|
274
|
+
}
|
|
275
|
+
if (rebaseInternalState !== null) {
|
|
276
|
+
return await getRebaseConflictDetails(repository, conflictedFilesInIndex);
|
|
277
|
+
}
|
|
278
|
+
// If there's conflicted files in the index but we don't have a merge head
|
|
279
|
+
// or a rebase internal state, then we're likely in a situation where a
|
|
280
|
+
// stash has introduced conflicts
|
|
281
|
+
if (conflictedFilesInIndex.length > 0) {
|
|
282
|
+
return await getWorkingDirectoryConflictDetails(repository, conflictedFilesInIndex);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
console.error('Unexpected error from git operations in getConflictDetails', error);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
conflictCountsByPath: new Map(),
|
|
290
|
+
binaryFilePaths: new Array(),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/git/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAC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AC/C,UAAsB,EACtB,sBAAmD;IAEnD,MAAM,oBAAoB,GAAG,MAAM,2BAA2B,CAC5D,UAAU,CAAC,IAAI,CAChB,CAAA;IACD,IAAI,eAAe,GAA0B,EAAE,CAAA;IAC/C,IAAI,CAAC;QACH,gEAAgE;QAChE,eAAe,GAAG,MAAM,cAAc,CACpC,UAAU,EACV,MAAM,EACN,sBAAsB,CACvB,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC,CAAA,CAAC;IAElB,OAAO;QACL,oBAAoB;QACpB,eAAe;KAChB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,kBAAkB,CAC/B,UAAsB,EACtB,cAAuB,EACvB,sBAAmD,EACnD,mBAA+C;IAE/C,IAAI,CAAC;QACH,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,MAAM,uBAAuB,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAA;QAC1E,CAAC;QAED,IAAI,mBAAmB,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,MAAM,wBAAwB,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAA;QAC3E,CAAC;QAED,0EAA0E;QAC1E,uEAAuE;QACvE,iCAAiC;QACjC,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,OAAO,MAAM,kCAAkC,CAC7C,UAAU,EACV,sBAAsB,CACvB,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,4DAA4D,EAC5D,KAAK,CACN,CAAA;IACH,CAAC;IACD,OAAO;QACL,oBAAoB,EAAE,IAAI,GAAG,EAAkB;QAC/C,eAAe,EAAE,IAAI,KAAK,EAAU;KACrC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
import { SubmoduleEntry } from '../models/submodule.js';
|
|
3
|
+
import { IRemote } from '../models/remote.js';
|
|
4
|
+
import { Progress } from '../models/progress.js';
|
|
5
|
+
/**
|
|
6
|
+
* Update submodules after a git operation.
|
|
7
|
+
*
|
|
8
|
+
* @param repository - The repository in which to update submodules
|
|
9
|
+
* @param remote - The remote for environment setup (can be null)
|
|
10
|
+
* @param progressCallback - An optional function which will be invoked
|
|
11
|
+
* with information about the current progress
|
|
12
|
+
* of the submodule update operation.
|
|
13
|
+
* @param progressKind - The kind of progress event ('checkout', 'pull', etc.)
|
|
14
|
+
* @param title - The title to use for progress reporting
|
|
15
|
+
* @param targetOrRemote - The target (for checkout) or remote name (for pull)
|
|
16
|
+
* @param allowFileProtocol - Whether to allow file:// protocol for submodules
|
|
17
|
+
*/
|
|
18
|
+
export declare function updateSubmodulesAfterOperation<T extends Progress>(repository: Repository, remote: IRemote | null, progressCallback: ((progress: T) => void) | undefined, progressKind: T['kind'], title: string, targetOrRemote: string, allowFileProtocol: boolean): Promise<void>;
|
|
19
|
+
export declare function listSubmodules(repository: Repository): Promise<ReadonlyArray<SubmoduleEntry>>;
|
|
20
|
+
export declare function resetSubmodulePaths(repository: Repository, paths: ReadonlyArray<string>): Promise<void>;
|