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,130 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { getConfigValue } from './config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gets a value indicating whether the trailer token is
|
|
5
|
+
* Co-Authored-By. Does not validate the token value.
|
|
6
|
+
*/
|
|
7
|
+
export function isCoAuthoredByTrailer(trailer) {
|
|
8
|
+
return trailer.token.toLowerCase() === 'co-authored-by';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse a string containing only unfolded trailers produced by
|
|
12
|
+
* git-interpret-trailers --only-input --only-trailers --unfold or
|
|
13
|
+
* a derivative such as git log --format="%(trailers:only,unfold)"
|
|
14
|
+
*
|
|
15
|
+
* @param trailers A string containing one well formed trailer per
|
|
16
|
+
* line
|
|
17
|
+
*
|
|
18
|
+
* @param separators A string containing all characters to use when
|
|
19
|
+
* attempting to find the separator between token
|
|
20
|
+
* and value in a trailer. See the configuration
|
|
21
|
+
* option trailer.separators for more information
|
|
22
|
+
*
|
|
23
|
+
* Also see getTrailerSeparatorCharacters.
|
|
24
|
+
*/
|
|
25
|
+
export function parseRawUnfoldedTrailers(trailers, separators) {
|
|
26
|
+
const lines = trailers.split('\n');
|
|
27
|
+
const parsedTrailers = new Array();
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
const trailer = parseSingleUnfoldedTrailer(line, separators);
|
|
30
|
+
if (trailer) {
|
|
31
|
+
parsedTrailers.push(trailer);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return parsedTrailers;
|
|
35
|
+
}
|
|
36
|
+
export function parseSingleUnfoldedTrailer(line, separators) {
|
|
37
|
+
for (const separator of separators) {
|
|
38
|
+
const ix = line.indexOf(separator);
|
|
39
|
+
if (ix > 0) {
|
|
40
|
+
return {
|
|
41
|
+
token: line.substring(0, ix).trim(),
|
|
42
|
+
value: line.substring(ix + 1).trim(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get a string containing the characters that may be used in this repository
|
|
50
|
+
* separate tokens from values in commit message trailers. If no specific
|
|
51
|
+
* trailer separator is configured the default separator (:) will be returned.
|
|
52
|
+
*/
|
|
53
|
+
export async function getTrailerSeparatorCharacters(repository) {
|
|
54
|
+
return (await getConfigValue(repository, 'trailer.separators')) || ':';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Extract commit message trailers from a commit message.
|
|
58
|
+
*
|
|
59
|
+
* The trailers returned here are unfolded, i.e. they've had their
|
|
60
|
+
* whitespace continuation removed and are all on one line. See the
|
|
61
|
+
* documentation for --unfold in the help for `git interpret-trailers`
|
|
62
|
+
*
|
|
63
|
+
* @param repository The repository in which to run the interpret-
|
|
64
|
+
* trailers command. Although not intuitive this
|
|
65
|
+
* does matter as there are configuration options
|
|
66
|
+
* available for the format, position, etc of commit
|
|
67
|
+
* message trailers. See the manpage for
|
|
68
|
+
* git-interpret-trailers for more information.
|
|
69
|
+
*
|
|
70
|
+
* @param commitMessage A commit message from where to attempt to extract
|
|
71
|
+
* commit message trailers.
|
|
72
|
+
*
|
|
73
|
+
* @returns An array of zero or more parsed trailers
|
|
74
|
+
*/
|
|
75
|
+
export async function parseTrailers(repository, commitMessage) {
|
|
76
|
+
const result = await git(['interpret-trailers', '--parse'], repository.path, 'parseTrailers', {
|
|
77
|
+
stdin: commitMessage,
|
|
78
|
+
});
|
|
79
|
+
const trailers = result.stdout;
|
|
80
|
+
if (trailers.length === 0) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const separators = await getTrailerSeparatorCharacters(repository);
|
|
84
|
+
return parseRawUnfoldedTrailers(result.stdout, separators);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Merge one or more commit message trailers into a commit message.
|
|
88
|
+
*
|
|
89
|
+
* If no trailers are given this method will simply try to ensure that
|
|
90
|
+
* any trailers that happen to be part of the raw message are formatted
|
|
91
|
+
* in accordance with the configuration options set for trailers in
|
|
92
|
+
* the given repository.
|
|
93
|
+
*
|
|
94
|
+
* Note that configuration may be set so that duplicate trailers are
|
|
95
|
+
* kept or discarded.
|
|
96
|
+
*
|
|
97
|
+
* @param repository The repository in which to run the interpret-
|
|
98
|
+
* trailers command. Although not intuitive this
|
|
99
|
+
* does matter as there are configuration options
|
|
100
|
+
* available for the format, position, etc of commit
|
|
101
|
+
* message trailers. See the manpage for
|
|
102
|
+
* git-interpret-trailers for more information.
|
|
103
|
+
*
|
|
104
|
+
* @param commitMessage A commit message with or without existing commit
|
|
105
|
+
* message trailers into which to merge the trailers
|
|
106
|
+
* given in the trailers parameter
|
|
107
|
+
*
|
|
108
|
+
* @param trailers Zero or more trailers to merge into the commit message
|
|
109
|
+
*
|
|
110
|
+
* @returns A commit message string where the provided trailers (if)
|
|
111
|
+
* any have been merged into the commit message using the
|
|
112
|
+
* configuration settings for trailers in the provided
|
|
113
|
+
* repository.
|
|
114
|
+
*/
|
|
115
|
+
export async function mergeTrailers(repository, commitMessage, trailers, unfold = false) {
|
|
116
|
+
const args = ['interpret-trailers'];
|
|
117
|
+
// See https://github.com/git/git/blob/ebf3c04b262aa/Documentation/git-interpret-trailers.txt#L129-L132
|
|
118
|
+
args.push('--no-divider');
|
|
119
|
+
if (unfold) {
|
|
120
|
+
args.push('--unfold');
|
|
121
|
+
}
|
|
122
|
+
for (const trailer of trailers) {
|
|
123
|
+
args.push('--trailer', `${trailer.token}=${trailer.value}`);
|
|
124
|
+
}
|
|
125
|
+
const result = await git(args, repository.path, 'mergeTrailers', {
|
|
126
|
+
stdin: commitMessage,
|
|
127
|
+
});
|
|
128
|
+
return result.stdout;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=interpret-trailers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpret-trailers.js","sourceRoot":"","sources":["../../src/git/interpret-trailers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,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MAAM,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Repository } from '../models/repository.js';
|
|
2
|
+
/** Install the global LFS filters. */
|
|
3
|
+
export declare function installGlobalLFSFilters(force: boolean): Promise<void>;
|
|
4
|
+
/** Install LFS hooks in the repository. */
|
|
5
|
+
export declare function installLFSHooks(repository: Repository, force: boolean): Promise<void>;
|
|
6
|
+
/** Is the repository configured to track any paths with LFS? */
|
|
7
|
+
export declare function isUsingLFS(repository: Repository): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Check if a provided file path is being tracked by Git LFS
|
|
10
|
+
*
|
|
11
|
+
* This uses the Git plumbing to read the .gitattributes file
|
|
12
|
+
* for any LFS-related rules that are set for the file
|
|
13
|
+
*
|
|
14
|
+
* @param repository repository with
|
|
15
|
+
* @param path relative file path in the repository
|
|
16
|
+
*/
|
|
17
|
+
export declare function isTrackedByLFS(repository: Repository, path: string): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Query a Git repository and filter the set of provided relative paths to see
|
|
20
|
+
* which are not covered by the current Git LFS configuration.
|
|
21
|
+
*
|
|
22
|
+
* @param repository
|
|
23
|
+
* @param filePaths List of relative paths in the repository
|
|
24
|
+
*/
|
|
25
|
+
export declare function filesNotTrackedByLFS(repository: Repository, filePaths: ReadonlyArray<string>): Promise<ReadonlyArray<string>>;
|
package/dist/git/lfs.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
/** Install the global LFS filters. */
|
|
3
|
+
export async function installGlobalLFSFilters(force) {
|
|
4
|
+
const args = ['lfs', 'install', '--skip-repo'];
|
|
5
|
+
if (force) {
|
|
6
|
+
args.push('--force');
|
|
7
|
+
}
|
|
8
|
+
await git(args, __dirname, 'installGlobalLFSFilter');
|
|
9
|
+
}
|
|
10
|
+
/** Install LFS hooks in the repository. */
|
|
11
|
+
export async function installLFSHooks(repository, force) {
|
|
12
|
+
const args = ['lfs', 'install'];
|
|
13
|
+
if (force) {
|
|
14
|
+
args.push('--force');
|
|
15
|
+
}
|
|
16
|
+
await git(args, repository.path, 'installLFSHooks');
|
|
17
|
+
}
|
|
18
|
+
/** Is the repository configured to track any paths with LFS? */
|
|
19
|
+
export async function isUsingLFS(repository) {
|
|
20
|
+
const env = {
|
|
21
|
+
GIT_LFS_TRACK_NO_INSTALL_HOOKS: '1',
|
|
22
|
+
};
|
|
23
|
+
const result = await git(['lfs', 'track'], repository.path, 'isUsingLFS', {
|
|
24
|
+
env,
|
|
25
|
+
});
|
|
26
|
+
return result.stdout.length > 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if a provided file path is being tracked by Git LFS
|
|
30
|
+
*
|
|
31
|
+
* This uses the Git plumbing to read the .gitattributes file
|
|
32
|
+
* for any LFS-related rules that are set for the file
|
|
33
|
+
*
|
|
34
|
+
* @param repository repository with
|
|
35
|
+
* @param path relative file path in the repository
|
|
36
|
+
*/
|
|
37
|
+
export async function isTrackedByLFS(repository, path) {
|
|
38
|
+
const { stdout } = await git(['check-attr', 'filter', path], repository.path, 'checkAttrForLFS');
|
|
39
|
+
// "git check-attr -a" will output every filter it can find in .gitattributes
|
|
40
|
+
// and it looks like this:
|
|
41
|
+
//
|
|
42
|
+
// README.md: diff: lfs
|
|
43
|
+
// README.md: merge: lfs
|
|
44
|
+
// README.md: text: unset
|
|
45
|
+
// README.md: filter: lfs
|
|
46
|
+
//
|
|
47
|
+
// To verify git-lfs this test will just focus on that last row, "filter",
|
|
48
|
+
// and the value associated with it. If nothing is found in .gitattributes
|
|
49
|
+
// the output will look like this
|
|
50
|
+
//
|
|
51
|
+
// README.md: filter: unspecified
|
|
52
|
+
const lfsFilterRegex = /: filter: lfs/;
|
|
53
|
+
const match = lfsFilterRegex.exec(stdout);
|
|
54
|
+
return match !== null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Query a Git repository and filter the set of provided relative paths to see
|
|
58
|
+
* which are not covered by the current Git LFS configuration.
|
|
59
|
+
*
|
|
60
|
+
* @param repository
|
|
61
|
+
* @param filePaths List of relative paths in the repository
|
|
62
|
+
*/
|
|
63
|
+
export async function filesNotTrackedByLFS(repository, filePaths) {
|
|
64
|
+
const filesNotTrackedByGitLFS = new Array();
|
|
65
|
+
for (const file of filePaths) {
|
|
66
|
+
const isTracked = await isTrackedByLFS(repository, file);
|
|
67
|
+
if (!isTracked) {
|
|
68
|
+
filesNotTrackedByGitLFS.push(file);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return filesNotTrackedByGitLFS;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=lfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lfs.js","sourceRoot":"","sources":["../../src/git/lfs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAG/B,sCAAsC;AACtC,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,KAAc;IAC1D,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;IAC9C,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACtB,CAAC;IAED,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,wBAAwB,CAAC,CAAA;AACtD,CAAC;AAED,2CAA2C;AAC3C,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAAsB,EACtB,KAAc;IAEd,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAC/B,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACtB,CAAC;IAED,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;AACrD,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC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AC;IAED,OAAO,uBAAuB,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CommittedFileChange } from '../models/status.js';
|
|
2
|
+
import { Repository } from '../models/repository.js';
|
|
3
|
+
import { Commit } from '../models/commit.js';
|
|
4
|
+
import { CommitIdentity } from '../models/commit-identity.js';
|
|
5
|
+
/**
|
|
6
|
+
* Get the repository's commits using `revisionRange` and limited to `limit`
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCommits(repository: Repository, revisionRange?: string, limit?: number, skip?: number, additionalArgs?: ReadonlyArray<string>): Promise<ReadonlyArray<Commit>>;
|
|
9
|
+
/** This interface contains information of a changeset. */
|
|
10
|
+
export interface IChangesetData {
|
|
11
|
+
/** Files changed in the changeset. */
|
|
12
|
+
readonly files: ReadonlyArray<CommittedFileChange>;
|
|
13
|
+
/** Number of lines added in the changeset. */
|
|
14
|
+
readonly linesAdded: number;
|
|
15
|
+
/** Number of lines deleted in the changeset. */
|
|
16
|
+
readonly linesDeleted: number;
|
|
17
|
+
}
|
|
18
|
+
/** Get the files that were changed in the given commit. */
|
|
19
|
+
export declare function getChangedFiles(repository: Repository, sha: string): Promise<IChangesetData>;
|
|
20
|
+
/**
|
|
21
|
+
* Parses output of diff flags -z --raw --numstat.
|
|
22
|
+
*
|
|
23
|
+
* Given the -z flag the new lines are separated by \0 character (left them as
|
|
24
|
+
* new lines below for ease of reading)
|
|
25
|
+
*
|
|
26
|
+
* For modified, added, deleted, untracked:
|
|
27
|
+
* 100644 100644 5716ca5 db3c77d M
|
|
28
|
+
* file_one_path
|
|
29
|
+
* :100644 100644 0835e4f 28096ea M
|
|
30
|
+
* file_two_path
|
|
31
|
+
* 1 0 file_one_path
|
|
32
|
+
* 1 0 file_two_path
|
|
33
|
+
*
|
|
34
|
+
* For copied or renamed:
|
|
35
|
+
* 100644 100644 5716ca5 db3c77d M
|
|
36
|
+
* file_one_original_path
|
|
37
|
+
* file_one_new_path
|
|
38
|
+
* :100644 100644 0835e4f 28096ea M
|
|
39
|
+
* file_two_original_path
|
|
40
|
+
* file_two_new_path
|
|
41
|
+
* 1 0
|
|
42
|
+
* file_one_original_path
|
|
43
|
+
* file_one_new_path
|
|
44
|
+
* 1 0
|
|
45
|
+
* file_two_original_path
|
|
46
|
+
* file_two_new_path
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseRawLogWithNumstat(stdout: string, sha: string, parentCommitish: string): {
|
|
49
|
+
files: CommittedFileChange[];
|
|
50
|
+
linesAdded: number;
|
|
51
|
+
linesDeleted: number;
|
|
52
|
+
};
|
|
53
|
+
/** Get the commit for the given ref. */
|
|
54
|
+
export declare function getCommit(repository: Repository, ref: string): Promise<Commit | null>;
|
|
55
|
+
/** Get the author identity for the given shas */
|
|
56
|
+
export declare function getAuthors(repository: Repository, shas: string[]): Promise<CommitIdentity[]>;
|
package/dist/git/log.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { git } from './core.js';
|
|
2
|
+
import { CommittedFileChange, AppFileStatusKind, } from '../models/status.js';
|
|
3
|
+
import { Commit } from '../models/commit.js';
|
|
4
|
+
import { CommitIdentity } from '../models/commit-identity.js';
|
|
5
|
+
import { parseRawUnfoldedTrailers } from './interpret-trailers.js';
|
|
6
|
+
import { createLogParser } from './git-delimiter-parser.js';
|
|
7
|
+
import { forceUnwrap } from '../lib/fatal-error.js';
|
|
8
|
+
import assert from 'assert';
|
|
9
|
+
// File mode 160000 is used by git specifically for submodules:
|
|
10
|
+
// https://github.com/git/git/blob/v2.37.3/cache.h#L62-L69
|
|
11
|
+
const SubmoduleFileMode = '160000';
|
|
12
|
+
function mapSubmoduleStatusFileModes(status, srcMode, dstMode) {
|
|
13
|
+
return srcMode === SubmoduleFileMode &&
|
|
14
|
+
dstMode === SubmoduleFileMode &&
|
|
15
|
+
status === 'M'
|
|
16
|
+
? {
|
|
17
|
+
commitChanged: true,
|
|
18
|
+
untrackedChanges: false,
|
|
19
|
+
modifiedChanges: false,
|
|
20
|
+
}
|
|
21
|
+
: (srcMode === SubmoduleFileMode && status === 'D') ||
|
|
22
|
+
(dstMode === SubmoduleFileMode && status === 'A')
|
|
23
|
+
? {
|
|
24
|
+
commitChanged: false,
|
|
25
|
+
untrackedChanges: false,
|
|
26
|
+
modifiedChanges: false,
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Map the raw status text from Git to an app-friendly value
|
|
32
|
+
* shamelessly borrowed from GitHub Desktop (Windows)
|
|
33
|
+
*/
|
|
34
|
+
function mapStatus(rawStatus, oldPath, srcMode, dstMode) {
|
|
35
|
+
const status = rawStatus.trim();
|
|
36
|
+
const submoduleStatus = mapSubmoduleStatusFileModes(status, srcMode, dstMode);
|
|
37
|
+
if (status === 'M') {
|
|
38
|
+
return { kind: AppFileStatusKind.Modified, submoduleStatus };
|
|
39
|
+
} // modified
|
|
40
|
+
if (status === 'A') {
|
|
41
|
+
return { kind: AppFileStatusKind.New, submoduleStatus };
|
|
42
|
+
} // added
|
|
43
|
+
if (status === '?') {
|
|
44
|
+
return { kind: AppFileStatusKind.Untracked, submoduleStatus };
|
|
45
|
+
} // untracked
|
|
46
|
+
if (status === 'D') {
|
|
47
|
+
return { kind: AppFileStatusKind.Deleted, submoduleStatus };
|
|
48
|
+
} // deleted
|
|
49
|
+
if (status === 'R' && oldPath != null) {
|
|
50
|
+
return {
|
|
51
|
+
kind: AppFileStatusKind.Renamed,
|
|
52
|
+
oldPath,
|
|
53
|
+
submoduleStatus,
|
|
54
|
+
renameIncludesModifications: false,
|
|
55
|
+
};
|
|
56
|
+
} // renamed
|
|
57
|
+
if (status === 'C' && oldPath != null) {
|
|
58
|
+
return {
|
|
59
|
+
kind: AppFileStatusKind.Copied,
|
|
60
|
+
oldPath,
|
|
61
|
+
submoduleStatus,
|
|
62
|
+
renameIncludesModifications: false,
|
|
63
|
+
};
|
|
64
|
+
} // copied
|
|
65
|
+
// git log -M --name-status will return a RXXX - where XXX is a percentage
|
|
66
|
+
if (status.match(/R[0-9]+/) && oldPath != null) {
|
|
67
|
+
return {
|
|
68
|
+
kind: AppFileStatusKind.Renamed,
|
|
69
|
+
oldPath,
|
|
70
|
+
submoduleStatus,
|
|
71
|
+
renameIncludesModifications: status !== 'R100',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// git log -C --name-status will return a CXXX - where XXX is a percentage
|
|
75
|
+
if (status.match(/C[0-9]+/) && oldPath != null) {
|
|
76
|
+
return {
|
|
77
|
+
kind: AppFileStatusKind.Copied,
|
|
78
|
+
oldPath,
|
|
79
|
+
submoduleStatus,
|
|
80
|
+
renameIncludesModifications: false,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { kind: AppFileStatusKind.Modified, submoduleStatus };
|
|
84
|
+
}
|
|
85
|
+
const isCopyOrRename = (status) => status.kind === AppFileStatusKind.Copied ||
|
|
86
|
+
status.kind === AppFileStatusKind.Renamed;
|
|
87
|
+
/**
|
|
88
|
+
* Get the repository's commits using `revisionRange` and limited to `limit`
|
|
89
|
+
*/
|
|
90
|
+
export async function getCommits(repository, revisionRange, limit, skip, additionalArgs = []) {
|
|
91
|
+
const { formatArgs, parse } = createLogParser({
|
|
92
|
+
sha: '%H', // SHA
|
|
93
|
+
shortSha: '%h', // short SHA
|
|
94
|
+
summary: '%s', // summary
|
|
95
|
+
body: '%b', // body
|
|
96
|
+
// author identity string, matching format of GIT_AUTHOR_IDENT.
|
|
97
|
+
// author name <author email> <author date>
|
|
98
|
+
// author date format dependent on --date arg, should be raw
|
|
99
|
+
author: '%an <%ae> %ad',
|
|
100
|
+
committer: '%cn <%ce> %cd',
|
|
101
|
+
parents: '%P', // parent SHAs,
|
|
102
|
+
trailers: '%(trailers:unfold,only)',
|
|
103
|
+
refs: '%D',
|
|
104
|
+
});
|
|
105
|
+
const args = ['log'];
|
|
106
|
+
if (revisionRange !== undefined) {
|
|
107
|
+
args.push(revisionRange);
|
|
108
|
+
}
|
|
109
|
+
args.push('--date=raw');
|
|
110
|
+
if (limit !== undefined) {
|
|
111
|
+
args.push(`--max-count=${limit}`);
|
|
112
|
+
}
|
|
113
|
+
if (skip !== undefined) {
|
|
114
|
+
args.push(`--skip=${skip}`);
|
|
115
|
+
}
|
|
116
|
+
args.push(...formatArgs, '--no-show-signature', '--no-color', ...additionalArgs, '--');
|
|
117
|
+
const result = await git(args, repository.path, 'getCommits', {
|
|
118
|
+
successExitCodes: new Set([0, 128]),
|
|
119
|
+
encoding: 'buffer',
|
|
120
|
+
});
|
|
121
|
+
// if the repository has an unborn HEAD, return an empty history of commits
|
|
122
|
+
if (result.exitCode === 128) {
|
|
123
|
+
return new Array();
|
|
124
|
+
}
|
|
125
|
+
const parsed = parse(result.stdout);
|
|
126
|
+
return parsed.map(commit => {
|
|
127
|
+
// Ref is of the format: (HEAD -> master, tag: some-tag-name, tag: some-other-tag,with-a-comma, origin/master, origin/HEAD)
|
|
128
|
+
// Refs are comma separated, but some like tags can also contain commas in the name, so we split on the pattern ", " and then
|
|
129
|
+
// check each ref for the tag prefix. We used to use the regex /tag: ([^\s,]+)/g)`, but will clip a tag with a comma short.
|
|
130
|
+
const tags = commit.refs
|
|
131
|
+
.toString()
|
|
132
|
+
.split(', ')
|
|
133
|
+
.flatMap(ref => (ref.startsWith('tag: ') ? ref.substring(5) : []));
|
|
134
|
+
return new Commit(commit.sha.toString(), commit.shortSha.toString(), commit.summary.subarray(0, 100 * 1024).toString(), commit.body.subarray(0, 100 * 1024).toString(), CommitIdentity.parseIdentity(commit.author.toString()), CommitIdentity.parseIdentity(commit.committer.toString()), commit.parents.length > 0 ? commit.parents.toString().split(' ') : [],
|
|
135
|
+
// We know for sure that the trailer separator will be ':' since we got
|
|
136
|
+
// them from %(trailers:unfold) above, see `git help log`:
|
|
137
|
+
//
|
|
138
|
+
// "key_value_separator=<SEP>: specify a separator inserted between
|
|
139
|
+
// trailer lines. When this option is not given each trailer key-value
|
|
140
|
+
// pair is separated by ": ". Otherwise it shares the same semantics as
|
|
141
|
+
// separator=<SEP> above."
|
|
142
|
+
parseRawUnfoldedTrailers(commit.trailers.toString(), ':'), tags);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** Get the files that were changed in the given commit. */
|
|
146
|
+
export async function getChangedFiles(repository, sha) {
|
|
147
|
+
// opt-in for rename detection (-M) and copies detection (-C)
|
|
148
|
+
// this is equivalent to the user configuring 'diff.renames' to 'copies'
|
|
149
|
+
// NOTE: order here matters - doing -M before -C means copies aren't detected
|
|
150
|
+
const args = [
|
|
151
|
+
'log',
|
|
152
|
+
sha,
|
|
153
|
+
'-C',
|
|
154
|
+
'-M',
|
|
155
|
+
'-m',
|
|
156
|
+
'-1',
|
|
157
|
+
'--no-show-signature',
|
|
158
|
+
'--first-parent',
|
|
159
|
+
'--raw',
|
|
160
|
+
'--format=format:',
|
|
161
|
+
'--numstat',
|
|
162
|
+
'-z',
|
|
163
|
+
'--',
|
|
164
|
+
];
|
|
165
|
+
const { stdout } = await git(args, repository.path, 'getChangesFiles');
|
|
166
|
+
return parseRawLogWithNumstat(stdout, sha, `${sha}^`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Parses output of diff flags -z --raw --numstat.
|
|
170
|
+
*
|
|
171
|
+
* Given the -z flag the new lines are separated by \0 character (left them as
|
|
172
|
+
* new lines below for ease of reading)
|
|
173
|
+
*
|
|
174
|
+
* For modified, added, deleted, untracked:
|
|
175
|
+
* 100644 100644 5716ca5 db3c77d M
|
|
176
|
+
* file_one_path
|
|
177
|
+
* :100644 100644 0835e4f 28096ea M
|
|
178
|
+
* file_two_path
|
|
179
|
+
* 1 0 file_one_path
|
|
180
|
+
* 1 0 file_two_path
|
|
181
|
+
*
|
|
182
|
+
* For copied or renamed:
|
|
183
|
+
* 100644 100644 5716ca5 db3c77d M
|
|
184
|
+
* file_one_original_path
|
|
185
|
+
* file_one_new_path
|
|
186
|
+
* :100644 100644 0835e4f 28096ea M
|
|
187
|
+
* file_two_original_path
|
|
188
|
+
* file_two_new_path
|
|
189
|
+
* 1 0
|
|
190
|
+
* file_one_original_path
|
|
191
|
+
* file_one_new_path
|
|
192
|
+
* 1 0
|
|
193
|
+
* file_two_original_path
|
|
194
|
+
* file_two_new_path
|
|
195
|
+
*/
|
|
196
|
+
export function parseRawLogWithNumstat(stdout, sha, parentCommitish) {
|
|
197
|
+
const files = new Array();
|
|
198
|
+
let linesAdded = 0;
|
|
199
|
+
let linesDeleted = 0;
|
|
200
|
+
let numStatCount = 0;
|
|
201
|
+
const lines = stdout.split('\0');
|
|
202
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
203
|
+
const line = lines[i];
|
|
204
|
+
if (line.startsWith(':')) {
|
|
205
|
+
const lineComponents = line.split(' ');
|
|
206
|
+
const srcMode = forceUnwrap('Invalid log output (srcMode)', lineComponents[0]?.replace(':', ''));
|
|
207
|
+
const dstMode = forceUnwrap('Invalid log output (dstMode)', lineComponents[1]);
|
|
208
|
+
const status = forceUnwrap('Invalid log output (status)', lineComponents.at(-1));
|
|
209
|
+
const oldPath = /^R|C/.test(status)
|
|
210
|
+
? forceUnwrap('Missing old path', lines.at(++i))
|
|
211
|
+
: undefined;
|
|
212
|
+
const path = forceUnwrap('Missing path', lines.at(++i));
|
|
213
|
+
files.push(new CommittedFileChange(path, mapStatus(status, oldPath, srcMode, dstMode), sha, parentCommitish));
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const match = /^(\d+|-)\t(\d+|-)\t/.exec(line);
|
|
217
|
+
const [, added, deleted] = forceUnwrap('Invalid numstat line', match);
|
|
218
|
+
linesAdded += added === '-' ? 0 : parseInt(added, 10);
|
|
219
|
+
linesDeleted += deleted === '-' ? 0 : parseInt(deleted, 10);
|
|
220
|
+
// If this entry denotes a rename or copy the old and new paths are on
|
|
221
|
+
// two separate fields (separated by \0). Otherwise they're on the same
|
|
222
|
+
// line as the added and deleted lines.
|
|
223
|
+
if (isCopyOrRename(files[numStatCount].status)) {
|
|
224
|
+
i += 2;
|
|
225
|
+
}
|
|
226
|
+
numStatCount++;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return { files, linesAdded, linesDeleted };
|
|
230
|
+
}
|
|
231
|
+
/** Get the commit for the given ref. */
|
|
232
|
+
export async function getCommit(repository, ref) {
|
|
233
|
+
const commits = await getCommits(repository, ref, 1);
|
|
234
|
+
if (commits.length < 1) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return commits[0];
|
|
238
|
+
}
|
|
239
|
+
/** Get the author identity for the given shas */
|
|
240
|
+
export async function getAuthors(repository, shas) {
|
|
241
|
+
if (shas.length === 0) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
const { stdout } = await git([
|
|
245
|
+
'log',
|
|
246
|
+
'--format=format:%an <%ae> %ad',
|
|
247
|
+
'--no-walk=unsorted',
|
|
248
|
+
'--date=raw',
|
|
249
|
+
'-z',
|
|
250
|
+
'--stdin',
|
|
251
|
+
], repository.path, 'getAuthors', { stdin: shas.join('\n') });
|
|
252
|
+
const authors = stdout.split('\0').map(CommitIdentity.parseIdentity);
|
|
253
|
+
// This can happen if there are duplicate shas in the input, git log will only
|
|
254
|
+
// return the author once for each sha.
|
|
255
|
+
assert.equal(authors.length, shas.length, 'Commit to author mismatch');
|
|
256
|
+
return authors;
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/git/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAMlB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,wBAAwB,EAAE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AAC,IAAI,CAAC,EAAE,CAC3B,CAAA;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;IAEpE,8EAA8E;IAC9E,uCAAuC;IACvC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAA;IAEtE,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Branch } from '../models/branch.js';
|
|
2
|
+
import { ComputedAction } from '../models/computed-action.js';
|
|
3
|
+
import { Repository } from '../models/repository.js';
|
|
4
|
+
type MergeTreeResult = {
|
|
5
|
+
kind: ComputedAction.Clean;
|
|
6
|
+
} | {
|
|
7
|
+
kind: ComputedAction.Conflicts;
|
|
8
|
+
conflictedFiles: number;
|
|
9
|
+
} | {
|
|
10
|
+
kind: ComputedAction.Invalid;
|
|
11
|
+
};
|
|
12
|
+
export declare function determineMergeability(repository: Repository, ours: Branch, theirs: Branch): Promise<MergeTreeResult>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComputedAction } from '../models/computed-action.js';
|
|
2
|
+
import { git, isGitError } from './core.js';
|
|
3
|
+
import { GitError } from './exec.js';
|
|
4
|
+
export async function determineMergeability(repository, ours, theirs) {
|
|
5
|
+
return git([
|
|
6
|
+
'merge-tree',
|
|
7
|
+
'--write-tree',
|
|
8
|
+
'--name-only',
|
|
9
|
+
'--no-messages',
|
|
10
|
+
'-z',
|
|
11
|
+
ours.tip.sha,
|
|
12
|
+
theirs.tip.sha,
|
|
13
|
+
], repository.path, 'determineMergeability', { successExitCodes: new Set([0, 1]) })
|
|
14
|
+
.then(({ stdout }) => {
|
|
15
|
+
const conflictedFiles = (stdout.match(/\0/g)?.length ?? 0) - 1;
|
|
16
|
+
return conflictedFiles > 0
|
|
17
|
+
? { kind: ComputedAction.Conflicts, conflictedFiles }
|
|
18
|
+
: { kind: ComputedAction.Clean };
|
|
19
|
+
})
|
|
20
|
+
.catch(e => isGitError(e, GitError.CannotMergeUnrelatedHistories)
|
|
21
|
+
? Promise.resolve({ kind: ComputedAction.Invalid })
|
|
22
|
+
: Promise.reject(e));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=merge-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-tree.js","sourceRoot":"","sources":["../../src/git/merge-tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAE7D,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAOpC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAsB,EACtB,IAAY,EACZ,MAAc;IAEd,OAAO,GAAG,CACR;QACE,YAAY;QACZ,cAAc;QACd,aAAa;QACb,eAAe;QACf,IAAI;QACJ,IAAI,CAAC,GAAG,CAAC,GAAG;QACZ,MAAM,CAAC,GAAG,CAAC,GAAG;KACf,EACD,UAAU,CAAC,IAAI,EACf,uBAAuB,EACvB,EAAE,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACtC;SACE,IAAI,CAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACpC,MAAM,eAAe,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QAC9D,OAAO,eAAe,GAAG,CAAC;YACxB,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE;YACrD,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,CAAA;IACpC,CAAC,CAAC;SACD,KAAK,CAAkB,CAAC,CAAC,EAAE,CAC1B,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,6BAA6B,CAAC;QACnD,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC;QACnD,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CACtB,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { HookCallbackOptions } from './core.js';
|
|
2
|
+
import { Repository } from '../models/repository.js';
|
|
3
|
+
export declare enum MergeResult {
|
|
4
|
+
/** The merge completed successfully */
|
|
5
|
+
Success = 0,
|
|
6
|
+
/**
|
|
7
|
+
* The merge was a noop since the current branch
|
|
8
|
+
* was already up to date with the target branch.
|
|
9
|
+
*/
|
|
10
|
+
AlreadyUpToDate = 1,
|
|
11
|
+
/**
|
|
12
|
+
* The merge failed, likely due to conflicts.
|
|
13
|
+
*/
|
|
14
|
+
Failed = 2
|
|
15
|
+
}
|
|
16
|
+
export type MergeOptions = {
|
|
17
|
+
/** Whether to perform a squash merge */
|
|
18
|
+
readonly squash?: boolean;
|
|
19
|
+
/** Whether to bypass pre-merge and post-merge hooks */
|
|
20
|
+
readonly noVerify?: boolean;
|
|
21
|
+
} & HookCallbackOptions;
|
|
22
|
+
/** Merge the named branch into the current branch. */
|
|
23
|
+
export declare function merge(repository: Repository, branch: string, options?: MergeOptions): Promise<MergeResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Find the base commit between two commit-ish identifiers
|
|
26
|
+
*
|
|
27
|
+
* @returns the commit id of the merge base, or null if the two commit-ish
|
|
28
|
+
* identifiers do not have a common base
|
|
29
|
+
*/
|
|
30
|
+
export declare function getMergeBase(repository: Repository, firstCommitish: string, secondCommitish: string): Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Abort a mid-flight (conflicted) merge
|
|
33
|
+
*
|
|
34
|
+
* @param repository where to abort the merge
|
|
35
|
+
*/
|
|
36
|
+
export declare function abortMerge(repository: Repository): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Check the `.git/MERGE_HEAD` file exists in a repository to confirm
|
|
39
|
+
* that it is in a conflicted state.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isMergeHeadSet(repository: Repository): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Check the `.git/SQUASH_MSG` file exists in a repository
|
|
44
|
+
* This would indicate we did a merge --squash and have not committed.. indicating
|
|
45
|
+
* we have detected a conflict.
|
|
46
|
+
*
|
|
47
|
+
* Note: If we abort the merge, this doesn't get cleared automatically which
|
|
48
|
+
* could lead to this being erroneously available in a non merge --squashing scenario.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isSquashMsgSet(repository: Repository): Promise<boolean>;
|