@statewalker/vcs-commands 0.7.0 → 0.9.0
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/dist/commands/add-command.d.ts +70 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +102 -1
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/am/index.d.ts +1 -0
- package/dist/commands/am/index.d.ts.map +1 -1
- package/dist/commands/am/mailsplit.d.ts +88 -0
- package/dist/commands/am/mailsplit.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-command.d.ts +2 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +303 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/branch-command.d.ts +148 -18
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-info-command.d.ts +55 -0
- package/dist/commands/branch-info-command.d.ts.map +1 -0
- package/dist/commands/branch-tracking.d.ts +106 -17
- package/dist/commands/branch-tracking.d.ts.map +1 -1
- package/dist/commands/branch-upstream-command.d.ts +83 -0
- package/dist/commands/branch-upstream-command.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +26 -3
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +82 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +44 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +116 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +239 -5
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/commit-reuse.d.ts +33 -0
- package/dist/commands/commit-reuse.d.ts.map +1 -0
- package/dist/commands/config-command.d.ts +236 -0
- package/dist/commands/config-command.d.ts.map +1 -0
- package/dist/commands/config-value-types.d.ts +91 -0
- package/dist/commands/config-value-types.d.ts.map +1 -0
- package/dist/commands/core-config.d.ts +20 -0
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +73 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts +369 -10
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +80 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/fmt-merge-msg-command.d.ts +124 -0
- package/dist/commands/fmt-merge-msg-command.d.ts.map +1 -0
- package/dist/commands/fork-point.d.ts +38 -0
- package/dist/commands/fork-point.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +69 -3
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fetch-fsck.d.ts +51 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +8 -0
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +81 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +50 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/grep/grep-command.d.ts +210 -0
- package/dist/commands/grep/grep-command.d.ts.map +1 -0
- package/dist/commands/grep/grep-engine.d.ts +218 -0
- package/dist/commands/grep/grep-engine.d.ts.map +1 -0
- package/dist/commands/grep/index.d.ts +3 -0
- package/dist/commands/grep/index.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +13 -2
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +38 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +5 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/interpret-trailers-command.d.ts +90 -0
- package/dist/commands/interpret-trailers-command.d.ts.map +1 -0
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +36 -5
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +527 -13
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +30 -3
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +199 -6
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts +2 -0
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +53 -0
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-base-command.d.ts +60 -0
- package/dist/commands/merge-base-command.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +23 -0
- package/dist/commands/merge-bases.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +147 -10
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +2 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +10 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts +4 -0
- package/dist/commands/mv-command.d.ts.map +1 -1
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +136 -0
- package/dist/commands/name-rev.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts.map +1 -1
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +16 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +58 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/pathspec-file.d.ts +39 -0
- package/dist/commands/pathspec-file.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +3 -0
- package/dist/commands/pathspec.d.ts.map +1 -1
- package/dist/commands/pretty-format.d.ts +43 -3
- package/dist/commands/pretty-format.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +186 -32
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +225 -9
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +20 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +189 -8
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +121 -0
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/index.d.ts +8 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts +88 -0
- package/dist/commands/ref-filter/ref-atoms.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts +178 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-format.d.ts +222 -0
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts +56 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-quote.d.ts +20 -0
- package/dist/commands/ref-filter/ref-quote.d.ts.map +1 -0
- package/dist/commands/ref-filter/version-compare.d.ts +20 -0
- package/dist/commands/ref-filter/version-compare.d.ts.map +1 -0
- package/dist/commands/reflog-command.d.ts +120 -0
- package/dist/commands/reflog-command.d.ts.map +1 -1
- package/dist/commands/reflog-walk.d.ts +72 -0
- package/dist/commands/reflog-walk.d.ts.map +1 -0
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +179 -29
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/remote-transport.d.ts +7 -1
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +21 -4
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +9 -3
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-filter/commit-filter.d.ts +95 -0
- package/dist/commands/rev-filter/commit-filter.d.ts.map +1 -0
- package/dist/commands/rev-filter/commit-grep.d.ts +91 -0
- package/dist/commands/rev-filter/commit-grep.d.ts.map +1 -0
- package/dist/commands/rev-filter/index.d.ts +3 -0
- package/dist/commands/rev-filter/index.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +226 -2
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +54 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +34 -1
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +15 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/rm-command.d.ts +70 -2
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +186 -5
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +12 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +7 -0
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/show-command.d.ts +130 -0
- package/dist/commands/show-command.d.ts.map +1 -0
- package/dist/commands/show-commit.d.ts +11 -0
- package/dist/commands/show-commit.d.ts.map +1 -0
- package/dist/commands/signature-check.d.ts +164 -0
- package/dist/commands/signature-check.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +160 -0
- package/dist/commands/signing.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -1
- package/dist/commands/sparse-index-view.d.ts +45 -0
- package/dist/commands/sparse-index-view.d.ts.map +1 -0
- package/dist/commands/ssh-signer.d.ts +29 -0
- package/dist/commands/ssh-signer.d.ts.map +1 -0
- package/dist/commands/ssh-verifier.d.ts +42 -0
- package/dist/commands/ssh-verifier.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +5 -0
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-branch-command.d.ts +34 -0
- package/dist/commands/stash-branch-command.d.ts.map +1 -0
- package/dist/commands/stash-create-command.d.ts +17 -0
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-info.d.ts +93 -0
- package/dist/commands/stash-info.d.ts.map +1 -0
- package/dist/commands/stash-list-command.d.ts +16 -0
- package/dist/commands/stash-list-command.d.ts.map +1 -1
- package/dist/commands/stash-pop-command.d.ts +39 -0
- package/dist/commands/stash-pop-command.d.ts.map +1 -0
- package/dist/commands/stash-show-command.d.ts +48 -0
- package/dist/commands/stash-show-command.d.ts.map +1 -0
- package/dist/commands/stash-store-command.d.ts +29 -0
- package/dist/commands/stash-store-command.d.ts.map +1 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +31 -2
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-header.d.ts +5 -0
- package/dist/commands/status-header.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +89 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -0
- package/dist/commands/submodule-auth.d.ts +90 -0
- package/dist/commands/submodule-auth.d.ts.map +1 -0
- package/dist/commands/submodule-commands.d.ts +463 -0
- package/dist/commands/submodule-commands.d.ts.map +1 -0
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +296 -0
- package/dist/commands/submodule-model.d.ts.map +1 -0
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +206 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -0
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +259 -10
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/trailers.d.ts +218 -17
- package/dist/commands/trailers.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +7 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +92 -0
- package/dist/commands/verify-command.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +79 -7
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/commands/worktree-path-rules.d.ts +66 -0
- package/dist/commands/worktree-path-rules.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +10 -3
- package/dist/commands/worktree-remove-command.d.ts.map +1 -1
- package/dist/commands/worktree-repair-command.d.ts +15 -2
- package/dist/commands/worktree-repair-command.d.ts.map +1 -1
- package/dist/commands/worktree-support.d.ts +5 -0
- package/dist/commands/worktree-support.d.ts.map +1 -1
- package/dist/{commands-DIJ91NnD.js → commands-CNvli5bl.js} +49442 -54941
- package/dist/errors/checkout-errors.d.ts +19 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts +25 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +85 -3
- package/dist/errors/ref-errors.d.ts +19 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +6 -1
- package/dist/errors/worktree-errors.d.ts.map +1 -1
- package/dist/fsck-CPeDh9fh.js +5138 -0
- package/dist/git-command.d.ts +58 -2
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +363 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +82 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +55 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-CCmBadm-.js +1606 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +3 -0
- package/dist/results/combined-diff.d.ts.map +1 -1
- package/dist/results/diff-check.d.ts +38 -0
- package/dist/results/diff-check.d.ts.map +1 -0
- package/dist/results/diff-color.d.ts +135 -0
- package/dist/results/diff-color.d.ts.map +1 -0
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +103 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-pickaxe.d.ts +67 -0
- package/dist/results/diff-pickaxe.d.ts.map +1 -0
- package/dist/results/diff-words.d.ts +55 -0
- package/dist/results/diff-words.d.ts.map +1 -0
- package/dist/results/fetch-result.d.ts +12 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +6 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +8 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +12 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +2 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +6 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BDuEgdLU.js +46847 -0
- package/dist/transport-command.d.ts +14 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/dist/whitespace/index.d.ts +2 -0
- package/dist/whitespace/index.d.ts.map +1 -0
- package/dist/whitespace/whitespace-rule.d.ts +94 -0
- package/dist/whitespace/whitespace-rule.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/commands/add-command.ts +293 -17
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +20 -2
- package/src/commands/am/am-command.ts +400 -46
- package/src/commands/am/index.ts +1 -0
- package/src/commands/am/mailsplit.ts +326 -0
- package/src/commands/apply/apply-command.ts +58 -15
- package/src/commands/apply/apply-engine.ts +1 -1
- package/src/commands/apply/apply-parse.ts +17 -8
- package/src/commands/apply/index.ts +8 -1
- package/src/commands/bisect/bisect-command.ts +18 -5
- package/src/commands/blame-command.ts +1450 -51
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/branch-command.ts +528 -53
- package/src/commands/branch-info-command.ts +150 -0
- package/src/commands/branch-tracking.ts +335 -60
- package/src/commands/branch-upstream-command.ts +218 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/checkout-command.ts +166 -55
- package/src/commands/checkout-paths.ts +28 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +185 -1
- package/src/commands/clean-command.ts +126 -15
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +598 -45
- package/src/commands/commit-command.ts +925 -74
- package/src/commands/commit-reuse.ts +94 -0
- package/src/commands/config-command.ts +1256 -0
- package/src/commands/config-value-types.ts +358 -0
- package/src/commands/core-config.ts +40 -0
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-color-config.ts +274 -0
- package/src/commands/diff-command.ts +1619 -99
- package/src/commands/fetch-command.ts +495 -14
- package/src/commands/fetch-multiple-command.ts +665 -0
- package/src/commands/fmt-merge-msg-command.ts +715 -0
- package/src/commands/fork-point.ts +63 -0
- package/src/commands/format-patch-command.ts +496 -116
- package/src/commands/fsck/fetch-fsck.ts +172 -18
- package/src/commands/gc-command.ts +31 -1
- package/src/commands/git-describe.ts +460 -201
- package/src/commands/git-hooks.ts +123 -3
- package/src/commands/grep/grep-command.ts +1077 -0
- package/src/commands/grep/grep-engine.ts +1024 -0
- package/src/commands/grep/index.ts +2 -0
- package/src/commands/index-adder.ts +46 -7
- package/src/commands/index.ts +43 -0
- package/src/commands/init-command.ts +603 -49
- package/src/commands/interpret-trailers-command.ts +256 -0
- package/src/commands/line-log.ts +931 -0
- package/src/commands/local-transport.ts +109 -10
- package/src/commands/log-command.ts +2599 -326
- package/src/commands/log-graph.ts +129 -29
- package/src/commands/log-output.ts +449 -27
- package/src/commands/ls-remote-command.ts +5 -0
- package/src/commands/mailmap.ts +155 -0
- package/src/commands/merge-base-command.ts +170 -0
- package/src/commands/merge-bases.ts +63 -8
- package/src/commands/merge-command.ts +601 -95
- package/src/commands/merge-drivers.ts +3 -0
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +115 -22
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/mv-command.ts +6 -3
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +762 -0
- package/src/commands/notes-command.ts +11 -1
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +41 -7
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id.ts +109 -0
- package/src/commands/pathspec-file.ts +72 -0
- package/src/commands/pathspec.ts +14 -2
- package/src/commands/pretty-format.ts +103 -19
- package/src/commands/promisor-remote.ts +10 -1
- package/src/commands/pull-command.ts +734 -221
- package/src/commands/push-command.ts +1035 -68
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +102 -4
- package/src/commands/rebase-command.ts +1074 -194
- package/src/commands/ref-filter/for-each-ref-command.ts +298 -0
- package/src/commands/ref-filter/index.ts +7 -0
- package/src/commands/ref-filter/ref-atoms.ts +581 -0
- package/src/commands/ref-filter/ref-filter.ts +651 -0
- package/src/commands/ref-filter/ref-format.ts +1070 -0
- package/src/commands/ref-filter/ref-listing-command.ts +421 -0
- package/src/commands/ref-filter/ref-quote.ts +69 -0
- package/src/commands/ref-filter/version-compare.ts +177 -0
- package/src/commands/reflog-command.ts +492 -2
- package/src/commands/reflog-walk.ts +234 -0
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +537 -69
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/remote-transport.ts +9 -1
- package/src/commands/reset-command.ts +114 -34
- package/src/commands/restore-command.ts +27 -41
- package/src/commands/rev-filter/commit-filter.ts +159 -0
- package/src/commands/rev-filter/commit-grep.ts +444 -0
- package/src/commands/rev-filter/index.ts +2 -0
- package/src/commands/rev-list-command.ts +578 -15
- package/src/commands/revert-command.ts +123 -1
- package/src/commands/revision-range.ts +207 -5
- package/src/commands/revision-resolver.ts +23 -8
- package/src/commands/rm-command.ts +282 -21
- package/src/commands/sequencer-pick.ts +818 -111
- package/src/commands/sequencer-support.ts +184 -4
- package/src/commands/serve-repository.ts +18 -3
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-command.ts +491 -0
- package/src/commands/show-commit.ts +24 -0
- package/src/commands/signature-check.ts +657 -0
- package/src/commands/signing.ts +385 -0
- package/src/commands/sparse-checkout-command.ts +2 -9
- package/src/commands/sparse-checkout-support.ts +2 -2
- package/src/commands/sparse-index-view.ts +135 -0
- package/src/commands/ssh-signer.ts +199 -0
- package/src/commands/ssh-verifier.ts +523 -0
- package/src/commands/stash-apply-command.ts +16 -4
- package/src/commands/stash-branch-command.ts +88 -0
- package/src/commands/stash-create-command.ts +28 -0
- package/src/commands/stash-info.ts +243 -0
- package/src/commands/stash-list-command.ts +33 -0
- package/src/commands/stash-pop-command.ts +83 -0
- package/src/commands/stash-show-command.ts +141 -0
- package/src/commands/stash-store-command.ts +82 -0
- package/src/commands/stash-working-tree.ts +2 -2
- package/src/commands/status-command.ts +120 -27
- package/src/commands/status-format.ts +1 -1
- package/src/commands/status-header.ts +41 -7
- package/src/commands/submodule-add-command.ts +509 -0
- package/src/commands/submodule-auth.ts +276 -0
- package/src/commands/submodule-commands.ts +1835 -0
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +938 -0
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +1126 -0
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +12 -1
- package/src/commands/tag-command.ts +876 -64
- package/src/commands/trailers.ts +837 -100
- package/src/commands/tree-restore.ts +44 -11
- package/src/commands/verify-command.ts +235 -0
- package/src/commands/worktree-add-command.ts +268 -24
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/commands/worktree-path-rules.ts +183 -0
- package/src/commands/worktree-remove-command.ts +39 -5
- package/src/commands/worktree-repair-command.ts +52 -5
- package/src/commands/worktree-support.ts +22 -1
- package/src/errors/checkout-errors.ts +29 -0
- package/src/errors/command-errors.ts +37 -1
- package/src/errors/ref-errors.ts +23 -0
- package/src/errors/worktree-errors.ts +8 -1
- package/src/git-command.ts +153 -2
- package/src/git.ts +550 -1
- package/src/guarded-transport-command.ts +171 -0
- package/src/index.ts +1 -0
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +101 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/clone-result.ts +6 -0
- package/src/results/combined-diff.ts +38 -18
- package/src/results/diff-check.ts +185 -0
- package/src/results/diff-color.ts +868 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +1 -0
- package/src/results/diff-output.ts +322 -32
- package/src/results/diff-pickaxe.ts +304 -0
- package/src/results/diff-words.ts +395 -0
- package/src/results/fetch-result.ts +12 -1
- package/src/results/index.ts +6 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +9 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +12 -0
- package/src/results/rebase-result.ts +3 -0
- package/src/results/stash-result.ts +7 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +34 -3
- package/src/whitespace/index.ts +1 -0
- package/src/{commands/apply/whitespace.ts → whitespace/whitespace-rule.ts} +173 -23
- package/dist/commands/apply/whitespace.d.ts +0 -58
- package/dist/commands/apply/whitespace.d.ts.map +0 -1
- package/dist/git-command-BGiOJ8Zk.js +0 -7246
- package/dist/results-WVlBhVb1.js +0 -2935
package/src/commands/trailers.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* trailer,
|
|
5
|
-
*
|
|
2
|
+
* git's trailer engine (trailer.c): finding the trailer block of a message, formatting it
|
|
3
|
+
* (`%(trailers)` of a pretty format), adding and editing trailers (`git interpret-trailers`,
|
|
4
|
+
* the `--trailer` of commit, tag, merge, rebase and cherry-pick) with the `trailer.*`
|
|
5
|
+
* configuration, and sequencer.c's sign-off (`append_signoff`).
|
|
6
|
+
*
|
|
7
|
+
* The block is the last paragraph when every line of it is a trailer, or when it has a
|
|
8
|
+
* git-generated one (`Signed-off-by: `, `(cherry picked from commit `) or a configured one
|
|
9
|
+
* and at least a quarter of its lines are trailers, continuation lines folded in.
|
|
6
10
|
*
|
|
7
11
|
* @example
|
|
8
12
|
* ```typescript
|
|
9
13
|
* const message = "Fix\n\nBody.\n\nSigned-off-by: A <a@b>\nAcked-by: C <c@d>\n";
|
|
10
14
|
* formatTrailersOf(message, { onlyTrailers: true, valueOnly: true, separator: ", " });
|
|
11
15
|
* // "A <a@b>, C <c@d>"
|
|
16
|
+
*
|
|
17
|
+
* const { output } = await interpretTrailers("Fix\n", { trailers: ["Reviewed-by: R <r@x>"] });
|
|
18
|
+
* // "Fix\n\nReviewed-by: R <r@x>\n"
|
|
12
19
|
* ```
|
|
13
20
|
*
|
|
14
21
|
* @module
|
|
@@ -16,20 +23,72 @@
|
|
|
16
23
|
|
|
17
24
|
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
18
25
|
|
|
26
|
+
import { GitApiError } from "../errors/index.js";
|
|
19
27
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
20
28
|
import { commentPrefixOf } from "./message-cleanup.js";
|
|
21
29
|
|
|
22
|
-
/**
|
|
30
|
+
/** Where a new trailer goes (`--where`, `trailer.where`, `trailer.<key>.where`). */
|
|
31
|
+
export type TrailerWhere = "end" | "after" | "before" | "start";
|
|
32
|
+
/** What to do when a trailer of the key exists (`--if-exists`, `trailer.ifexists`). */
|
|
33
|
+
export type TrailerIfExists =
|
|
34
|
+
| "addIfDifferentNeighbor"
|
|
35
|
+
| "addIfDifferent"
|
|
36
|
+
| "add"
|
|
37
|
+
| "replace"
|
|
38
|
+
| "doNothing";
|
|
39
|
+
/** What to do when no trailer of the key exists (`--if-missing`, `trailer.ifmissing`). */
|
|
40
|
+
export type TrailerIfMissing = "add" | "doNothing";
|
|
41
|
+
|
|
42
|
+
/** One `trailer.<name>.*` section (git's `conf_info`). */
|
|
43
|
+
export interface TrailerItemConfig {
|
|
44
|
+
/** `<name>`, the key alias (`--trailer <name>=<value>`) */
|
|
45
|
+
name: string;
|
|
46
|
+
/** `trailer.<name>.key`: the key written for the trailer */
|
|
47
|
+
key?: string;
|
|
48
|
+
/**
|
|
49
|
+
* `trailer.<name>.command` (deprecated): a shell command, its first `$ARG` replaced by the
|
|
50
|
+
* value, whose output is the value; also adds the trailer to every message
|
|
51
|
+
*/
|
|
52
|
+
command?: string;
|
|
53
|
+
/** `trailer.<name>.cmd`: a shell command given the value as `$1`, whose output is the value */
|
|
54
|
+
cmd?: string;
|
|
55
|
+
/** `trailer.<name>.where` (default `trailer.where`) */
|
|
56
|
+
where?: TrailerWhere;
|
|
57
|
+
/** `trailer.<name>.ifexists` (default `trailer.ifexists`) */
|
|
58
|
+
ifExists?: TrailerIfExists;
|
|
59
|
+
/** `trailer.<name>.ifmissing` (default `trailer.ifmissing`) */
|
|
60
|
+
ifMissing?: TrailerIfMissing;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The configuration trailers are read and written with (`trailer.*`, `core.commentChar`). */
|
|
23
64
|
export interface TrailerConfig {
|
|
24
65
|
/** `trailer.separators`: the characters that end a trailer's key (default `:`) */
|
|
25
66
|
separators?: string;
|
|
26
67
|
/** `core.commentChar` / `core.commentString` (default `#`) */
|
|
27
68
|
commentString?: string;
|
|
69
|
+
/** `trailer.where` (default `end`) */
|
|
70
|
+
where?: TrailerWhere;
|
|
71
|
+
/** `trailer.ifexists` (default `addIfDifferentNeighbor`) */
|
|
72
|
+
ifExists?: TrailerIfExists;
|
|
73
|
+
/** `trailer.ifmissing` (default `add`) */
|
|
74
|
+
ifMissing?: TrailerIfMissing;
|
|
28
75
|
/**
|
|
29
|
-
* The `trailer.<name>.*` sections in the configuration's order
|
|
30
|
-
* a name (or its `key`) is recognized, and shown with the `key`
|
|
76
|
+
* The `trailer.<name>.*` sections in the configuration's order (names without case): a
|
|
77
|
+
* trailer whose key starts a name (or its `key`) is recognized, and shown with the `key`
|
|
31
78
|
*/
|
|
32
|
-
items?: readonly
|
|
79
|
+
items?: readonly TrailerItemConfig[];
|
|
80
|
+
/**
|
|
81
|
+
* git's warnings reading the configuration (`warning: unknown value 'x' for key
|
|
82
|
+
* 'trailer.where'`, `warning: more than one trailer.a.key`), each a line
|
|
83
|
+
*/
|
|
84
|
+
warnings?: readonly string[];
|
|
85
|
+
/**
|
|
86
|
+
* The git version whose behaviour to follow where versions differ (default `2.56`): git
|
|
87
|
+
* 2.43 takes `https://x` for a trailer (2.45+ refuses a `://` right after the key), its
|
|
88
|
+
* `--trim-empty` also drops the non-trailer lines of a block that are empty, and its
|
|
89
|
+
* `interpret-trailers` reads an input without a final line end as it is (2.44+ completes it)
|
|
90
|
+
*/
|
|
91
|
+
compatibility?: "2.43" | "2.56";
|
|
33
92
|
}
|
|
34
93
|
|
|
35
94
|
/** What git's process_trailer_options carries for formatting trailers. */
|
|
@@ -50,32 +109,261 @@ export interface TrailerFormatOptions {
|
|
|
50
109
|
keys?: readonly string[];
|
|
51
110
|
}
|
|
52
111
|
|
|
53
|
-
/**
|
|
112
|
+
/** A trailer to add (`--trailer <key>[(=|:)<value>]`) and how, over the configuration. */
|
|
113
|
+
export interface NewTrailer {
|
|
114
|
+
/** `<key>`, `<key>:<value>`, `<key>=<value>` (any of `trailer.separators` or `=`) */
|
|
115
|
+
text: string;
|
|
116
|
+
/** `--where` given before it */
|
|
117
|
+
where?: TrailerWhere;
|
|
118
|
+
/** `--if-exists` given before it */
|
|
119
|
+
ifExists?: TrailerIfExists;
|
|
120
|
+
/** `--if-missing` given before it */
|
|
121
|
+
ifMissing?: TrailerIfMissing;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A shell command of `trailer.<name>.cmd` / `.command` for the host to run. */
|
|
125
|
+
export interface TrailerCommand {
|
|
126
|
+
/** The command line (`command` with its `$ARG` replaced, or `cmd`) */
|
|
127
|
+
command: string;
|
|
128
|
+
/** The arguments after it (`cmd`'s value; none for `command`) */
|
|
129
|
+
args: string[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** What a trailer command did. */
|
|
133
|
+
export interface TrailerCommandOutcome {
|
|
134
|
+
exitCode: number;
|
|
135
|
+
stdout: string;
|
|
136
|
+
/** What it wrote on stderr (git's own stderr shows it) */
|
|
137
|
+
stderr?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Runs trailer commands as git's `apply_command` does: through the shell (`sh -c`), stdin
|
|
142
|
+
* closed, without the variables naming the repository (`local_repo_env`). Undefined when the
|
|
143
|
+
* command could not be started (git reports it as failed).
|
|
144
|
+
*/
|
|
145
|
+
export type TrailerCommandRunner = (
|
|
146
|
+
command: TrailerCommand,
|
|
147
|
+
) => Promise<TrailerCommandOutcome | undefined>;
|
|
148
|
+
|
|
149
|
+
/** How {@link interpretTrailers} edits a message (`git interpret-trailers` options). */
|
|
150
|
+
export interface InterpretTrailersOptions {
|
|
151
|
+
/** The trailers to add (`--trailer`), in order; a string takes the options below */
|
|
152
|
+
trailers?: readonly (string | NewTrailer)[];
|
|
153
|
+
/** `--where` for the trailers given as strings */
|
|
154
|
+
where?: TrailerWhere;
|
|
155
|
+
/** `--if-exists` for the trailers given as strings */
|
|
156
|
+
ifExists?: TrailerIfExists;
|
|
157
|
+
/** `--if-missing` for the trailers given as strings */
|
|
158
|
+
ifMissing?: TrailerIfMissing;
|
|
159
|
+
/** `--trim-empty`: trailers with an empty value are left out */
|
|
160
|
+
trimEmpty?: boolean;
|
|
161
|
+
/** `--only-trailers`: only the trailers are output */
|
|
162
|
+
onlyTrailers?: boolean;
|
|
163
|
+
/** `--only-input`: no `trailer.<name>.command` trailers (and no `trailers` allowed) */
|
|
164
|
+
onlyInput?: boolean;
|
|
165
|
+
/** `--unfold`: continuation lines joined into one */
|
|
166
|
+
unfold?: boolean;
|
|
167
|
+
/** `--parse`: `--only-trailers --only-input --unfold` */
|
|
168
|
+
parse?: boolean;
|
|
169
|
+
/** `--no-divider`: a `---` line does not end the message */
|
|
170
|
+
noDivider?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Runs `trailer.<name>.cmd` / `.command` (see {@link TrailerCommandRunner}). Absent, as in a
|
|
173
|
+
* host that runs no commands: commands are not run, a trailer keeps the value given and no
|
|
174
|
+
* `.command` trailer is added on its own.
|
|
175
|
+
*/
|
|
176
|
+
runCommand?: TrailerCommandRunner;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** What {@link interpretTrailers} gave. */
|
|
180
|
+
export interface InterpretTrailersResult {
|
|
181
|
+
/** The message with its trailers (git's stdout) */
|
|
182
|
+
output: string;
|
|
183
|
+
/** git's stderr: `error:` lines and the commands' stderr, in order */
|
|
184
|
+
errors: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** One line of a trailer block as git's trailer iterator gives it. */
|
|
188
|
+
export interface TrailerLine {
|
|
189
|
+
/** The line as written, continuation lines included */
|
|
190
|
+
raw: string;
|
|
191
|
+
/** The key (the configured `key` where one matches); the whole line for a non-trailer */
|
|
192
|
+
key: string;
|
|
193
|
+
/** The value, unfolded; empty for a non-trailer */
|
|
194
|
+
value: string;
|
|
195
|
+
/** Whether it is a trailer (`<key><separator><value>`) */
|
|
196
|
+
isTrailer: boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** git's `trailer_set_where`: the placement named (without case); undefined when unknown. */
|
|
200
|
+
export function parseTrailerWhere(value: string): TrailerWhere | undefined {
|
|
201
|
+
const lower = lowerAscii(value);
|
|
202
|
+
for (const where of ["after", "before", "end", "start"] as const)
|
|
203
|
+
if (lower === where) return where;
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** git's `trailer_set_if_exists`: the action named (without case); undefined when unknown. */
|
|
208
|
+
export function parseTrailerIfExists(value: string): TrailerIfExists | undefined {
|
|
209
|
+
const lower = lowerAscii(value);
|
|
210
|
+
for (const action of [
|
|
211
|
+
"addIfDifferent",
|
|
212
|
+
"addIfDifferentNeighbor",
|
|
213
|
+
"add",
|
|
214
|
+
"replace",
|
|
215
|
+
"doNothing",
|
|
216
|
+
] as const) {
|
|
217
|
+
if (lower === lowerAscii(action)) return action;
|
|
218
|
+
}
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** git's `trailer_set_if_missing`: the action named (without case); undefined when unknown. */
|
|
223
|
+
export function parseTrailerIfMissing(value: string): TrailerIfMissing | undefined {
|
|
224
|
+
const lower = lowerAscii(value);
|
|
225
|
+
if (lower === "donothing") return "doNothing";
|
|
226
|
+
if (lower === "add") return "add";
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The trailer configuration of a working copy (`trailer.*`, the comment prefix). */
|
|
54
231
|
export function trailerConfigOf(workingCopy: WorkingCopy): TrailerConfig {
|
|
55
232
|
const config = RemoteConfigStore.from(workingCopy);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
233
|
+
let entries = config.entriesWithPrefix("trailer.");
|
|
234
|
+
if (!entries) {
|
|
235
|
+
// a config that cannot list its variables in order: section by section
|
|
236
|
+
entries = [];
|
|
237
|
+
for (const variable of ["where", "ifexists", "ifmissing", "separators"]) {
|
|
238
|
+
for (const value of config.values(`trailer.${variable}`)) {
|
|
239
|
+
entries.push({ key: `trailer.${variable}`, value });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
for (const name of config.subsections("trailer")) {
|
|
243
|
+
for (const variable of TRAILER_VARIABLES) {
|
|
244
|
+
for (const value of config.values(`trailer.${name}.${variable}`)) {
|
|
245
|
+
entries.push({ key: `trailer.${name}.${variable}`, value });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return trailerConfigFromEntries(entries, commentPrefixOf(workingCopy));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const TRAILER_VARIABLES = ["key", "command", "cmd", "where", "ifexists", "ifmissing"] as const;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The trailer configuration from `trailer.*` variables in the configuration's order (keys
|
|
257
|
+
* canonical: section and variable in lower case), as git's `trailer_config_init` reads them:
|
|
258
|
+
* `trailer.where`/`ifexists`/`ifmissing`/`separators` first, then each `trailer.<name>.*`.
|
|
259
|
+
* A `key`, `command`, `cmd` or `separators` without a value is git's fatal config error.
|
|
260
|
+
*/
|
|
261
|
+
export function trailerConfigFromEntries(
|
|
262
|
+
entries: readonly { key: string; value: string | undefined }[],
|
|
263
|
+
commentString?: string,
|
|
264
|
+
): TrailerConfig {
|
|
265
|
+
const warnings: string[] = [];
|
|
266
|
+
const unknown = (value: string | undefined, key: string) =>
|
|
267
|
+
warnings.push(`warning: unknown value '${value ?? "(null)"}' for key '${key}'`);
|
|
268
|
+
const missing = (key: string): never => {
|
|
269
|
+
throw new GitApiError(
|
|
270
|
+
`error: missing value for '${key}'\nfatal: bad config variable '${key}'`,
|
|
271
|
+
{
|
|
272
|
+
exitCode: 128,
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
const out: {
|
|
277
|
+
separators?: string;
|
|
278
|
+
where?: TrailerWhere;
|
|
279
|
+
ifExists?: TrailerIfExists;
|
|
280
|
+
ifMissing?: TrailerIfMissing;
|
|
281
|
+
} = {};
|
|
282
|
+
// git_trailer_default_config
|
|
283
|
+
for (const { key, value } of entries) {
|
|
284
|
+
const rest = key.slice("trailer.".length);
|
|
285
|
+
if (!key.startsWith("trailer.") || rest.includes(".")) continue;
|
|
286
|
+
if (rest === "where") {
|
|
287
|
+
const where = value === undefined ? undefined : parseTrailerWhere(value);
|
|
288
|
+
if (where) out.where = where;
|
|
289
|
+
else if (value !== undefined) unknown(value, key);
|
|
290
|
+
} else if (rest === "ifexists") {
|
|
291
|
+
const action = value === undefined ? undefined : parseTrailerIfExists(value);
|
|
292
|
+
if (action) out.ifExists = action;
|
|
293
|
+
else if (value !== undefined) unknown(value, key);
|
|
294
|
+
} else if (rest === "ifmissing") {
|
|
295
|
+
const action = value === undefined ? undefined : parseTrailerIfMissing(value);
|
|
296
|
+
if (action) out.ifMissing = action;
|
|
297
|
+
else if (value !== undefined) unknown(value, key);
|
|
298
|
+
} else if (rest === "separators") {
|
|
299
|
+
if (value === undefined) missing(key);
|
|
300
|
+
else out.separators = value;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// git_trailer_config: one item per name (without case), in the order first met
|
|
304
|
+
const items: TrailerItemConfig[] = [];
|
|
305
|
+
for (const { key, value } of entries) {
|
|
306
|
+
if (!key.startsWith("trailer.")) continue;
|
|
307
|
+
const rest = key.slice("trailer.".length);
|
|
308
|
+
const dot = rest.lastIndexOf(".");
|
|
309
|
+
if (dot < 0) continue;
|
|
310
|
+
const variable = rest.slice(dot + 1);
|
|
311
|
+
if (!(TRAILER_VARIABLES as readonly string[]).includes(variable)) continue;
|
|
312
|
+
const name = rest.slice(0, dot);
|
|
313
|
+
let item = items.find((i) => lowerAscii(i.name) === lowerAscii(name));
|
|
314
|
+
if (!item) {
|
|
315
|
+
item = { name };
|
|
316
|
+
items.push(item);
|
|
317
|
+
}
|
|
318
|
+
switch (variable) {
|
|
319
|
+
case "key":
|
|
320
|
+
case "command":
|
|
321
|
+
case "cmd": {
|
|
322
|
+
const field = variable;
|
|
323
|
+
if (item[field] !== undefined) warnings.push(`warning: more than one ${key}`);
|
|
324
|
+
if (value === undefined) missing(key);
|
|
325
|
+
else item[field] = value;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "where": {
|
|
329
|
+
const where = value === undefined ? undefined : parseTrailerWhere(value);
|
|
330
|
+
if (where) item.where = where;
|
|
331
|
+
else unknown(value, key);
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case "ifexists": {
|
|
335
|
+
const action = value === undefined ? undefined : parseTrailerIfExists(value);
|
|
336
|
+
if (action) item.ifExists = action;
|
|
337
|
+
else unknown(value, key);
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
case "ifmissing": {
|
|
341
|
+
const action = value === undefined ? undefined : parseTrailerIfMissing(value);
|
|
342
|
+
if (action) item.ifMissing = action;
|
|
343
|
+
else unknown(value, key);
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
66
347
|
}
|
|
67
|
-
const separators = config.value("trailer.separators");
|
|
68
348
|
return {
|
|
69
|
-
...
|
|
70
|
-
commentString:
|
|
349
|
+
...out,
|
|
350
|
+
...(commentString !== undefined ? { commentString } : {}),
|
|
71
351
|
items,
|
|
352
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
72
353
|
};
|
|
73
354
|
}
|
|
74
355
|
|
|
75
356
|
const lowerAscii = (s: string) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
76
357
|
/** strncasecmp(a, b, n) === 0 */
|
|
77
|
-
|
|
78
|
-
|
|
358
|
+
function sameStart(a: string, b: string, n: number): boolean {
|
|
359
|
+
for (let i = 0; i < n; i++) {
|
|
360
|
+
const x = a[i];
|
|
361
|
+
const y = b[i];
|
|
362
|
+
if (x === undefined || y === undefined) return x === y;
|
|
363
|
+
if (x !== y && lowerAscii(x) !== lowerAscii(y)) return false;
|
|
364
|
+
}
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
79
367
|
/** git's isspace (sane_ctype): space, tab, LF, CR */
|
|
80
368
|
const isSpace = (c: string | undefined) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
81
369
|
const isAlnum = (c: string | undefined) => c !== undefined && /^[A-Za-z0-9]$/.test(c);
|
|
@@ -102,16 +390,40 @@ function lastLine(buf: string, len: number): number {
|
|
|
102
390
|
return 0;
|
|
103
391
|
}
|
|
104
392
|
|
|
393
|
+
/** The configuration with git's defaults. */
|
|
394
|
+
interface Resolved {
|
|
395
|
+
separators: string;
|
|
396
|
+
commentString: string;
|
|
397
|
+
where: TrailerWhere;
|
|
398
|
+
ifExists: TrailerIfExists;
|
|
399
|
+
ifMissing: TrailerIfMissing;
|
|
400
|
+
items: readonly TrailerItemConfig[];
|
|
401
|
+
legacy: boolean;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function resolve(config: TrailerConfig): Resolved {
|
|
405
|
+
return {
|
|
406
|
+
separators: config.separators || ":",
|
|
407
|
+
commentString: config.commentString || "#",
|
|
408
|
+
where: config.where ?? "end",
|
|
409
|
+
ifExists: config.ifExists ?? "addIfDifferentNeighbor",
|
|
410
|
+
ifMissing: config.ifMissing ?? "add",
|
|
411
|
+
items: config.items ?? [],
|
|
412
|
+
legacy: config.compatibility === "2.43",
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
105
416
|
/**
|
|
106
417
|
* git's find_separator: where the separator of `<token><optional blanks><separator>` is in
|
|
107
|
-
* `line`, -1 when it is not a trailer line (a `://` right after the token is a URL
|
|
418
|
+
* `line` from `at`, -1 when it is not a trailer line (a `://` right after the token is a URL,
|
|
419
|
+
* git 2.45+). 0 when the line starts with a separator.
|
|
108
420
|
*/
|
|
109
|
-
function findSeparator(line: string, at: number, separators: string): number {
|
|
421
|
+
function findSeparator(line: string, at: number, separators: string, legacy: boolean): number {
|
|
110
422
|
let whitespace = false;
|
|
111
|
-
for (let c = at; c < line.length
|
|
423
|
+
for (let c = at; c < line.length; c++) {
|
|
112
424
|
const ch = line[c] as string;
|
|
113
425
|
if (separators.includes(ch)) {
|
|
114
|
-
if (!whitespace && line.startsWith("://", c)) return -1;
|
|
426
|
+
if (!legacy && !whitespace && line.startsWith("://", c)) return -1;
|
|
115
427
|
return c - at;
|
|
116
428
|
}
|
|
117
429
|
if (!whitespace && (isAlnum(ch) || ch === "-")) continue;
|
|
@@ -131,12 +443,19 @@ function tokenLength(token: string): number {
|
|
|
131
443
|
return len;
|
|
132
444
|
}
|
|
133
445
|
|
|
446
|
+
/** git's token_matches_item: `tok`'s first `len` characters start the item's name or key. */
|
|
447
|
+
function tokenMatches(tok: string, item: TrailerItemConfig, len: number): boolean {
|
|
448
|
+
if (sameStart(tok, item.name, len)) return true;
|
|
449
|
+
return item.key !== undefined && sameStart(tok, item.key, len);
|
|
450
|
+
}
|
|
451
|
+
|
|
134
452
|
const GIT_GENERATED_PREFIXES = ["Signed-off-by: ", "(cherry picked from commit "];
|
|
135
453
|
const CUT_LINE = "------------------------ >8 ------------------------";
|
|
136
454
|
|
|
137
455
|
/** commit.c's ignored_log_message_bytes: the trailing comments, blank lines, scissors. */
|
|
138
456
|
function ignoredBytes(buf: string, len: number, comment: string): number {
|
|
139
|
-
// wt_status_locate_end
|
|
457
|
+
// wt_status_locate_end (strstr over the whole input; wt-status.c's cut_line ends with its
|
|
458
|
+
// line end, so a cut line with text after it is no cut line)
|
|
140
459
|
let cutoff = len;
|
|
141
460
|
const pattern = `\n${comment} ${CUT_LINE}\n`;
|
|
142
461
|
if (buf.startsWith(pattern.slice(1))) cutoff = 0;
|
|
@@ -166,14 +485,32 @@ function ignoredBytes(buf: string, len: number, comment: string): number {
|
|
|
166
485
|
return boc ? len - boc : len - cutoff;
|
|
167
486
|
}
|
|
168
487
|
|
|
169
|
-
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
488
|
+
/**
|
|
489
|
+
* commit.c's ignored_log_message_bytes: how many characters at the end of `message` are not
|
|
490
|
+
* part of the log message (trailing comments and blank lines, an old `Conflicts:` block, the
|
|
491
|
+
* scissors line and what follows it): the `ignoreFooter` of {@link appendSignoff} for a
|
|
492
|
+
* commit message being edited.
|
|
493
|
+
*/
|
|
494
|
+
export function ignoredLogMessageBytes(message: string, commentString = "#"): number {
|
|
495
|
+
return ignoredBytes(message, message.length, commentString || "#");
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** trailer.c's find_end_of_log_message: before a `---` line (unless `noDivider`) and the ignored tail. */
|
|
499
|
+
function endOfLogMessage(input: string, noDivider: boolean, comment: string): number {
|
|
500
|
+
let end = input.length;
|
|
501
|
+
if (!noDivider) {
|
|
502
|
+
for (let s = 0; s < input.length; s = nextLine(input, s)) {
|
|
503
|
+
if (input.startsWith("---", s) && isSpace(input[s + 3])) {
|
|
504
|
+
end = s;
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return end - ignoredBytes(input, end, comment);
|
|
173
510
|
}
|
|
174
511
|
|
|
175
512
|
/** trailer.c's find_trailer_block_start: where the block starts, `len` when there is none. */
|
|
176
|
-
function trailerBlockStart(buf: string, len: number, config:
|
|
513
|
+
function trailerBlockStart(buf: string, len: number, config: Resolved): number {
|
|
177
514
|
const comment = config.commentString;
|
|
178
515
|
let s = 0;
|
|
179
516
|
for (; s < len; s = nextLine(buf, s)) {
|
|
@@ -206,7 +543,7 @@ function trailerBlockStart(buf: string, len: number, config: Required<TrailerCon
|
|
|
206
543
|
recognizedPrefix = true;
|
|
207
544
|
continue;
|
|
208
545
|
}
|
|
209
|
-
const separatorPos = findSeparator(buf, l, config.separators);
|
|
546
|
+
const separatorPos = findSeparator(buf, l, config.separators, config.legacy);
|
|
210
547
|
if (separatorPos >= 1 && !isSpace(buf[l])) {
|
|
211
548
|
trailerLines++;
|
|
212
549
|
possibleContinuationLines = 0;
|
|
@@ -225,12 +562,6 @@ function trailerBlockStart(buf: string, len: number, config: Required<TrailerCon
|
|
|
225
562
|
return len;
|
|
226
563
|
}
|
|
227
564
|
|
|
228
|
-
/** git's token_matches_item: `tok`'s first `len` characters start the item's name or key. */
|
|
229
|
-
function tokenMatches(tok: string, item: { name: string; key?: string }, len: number): boolean {
|
|
230
|
-
if (sameStart(tok, item.name, len)) return true;
|
|
231
|
-
return item.key !== undefined && sameStart(tok, item.key, len);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
565
|
/** git's unfold_value: each line end and the blanks after it one space, then trimmed. */
|
|
235
566
|
function unfoldValue(value: string): string {
|
|
236
567
|
let out = "";
|
|
@@ -245,15 +576,19 @@ function unfoldValue(value: string): string {
|
|
|
245
576
|
return trim(out);
|
|
246
577
|
}
|
|
247
578
|
|
|
248
|
-
/**
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
579
|
+
/** A trailer block (trailer.c's `trailer_block`). */
|
|
580
|
+
interface Block {
|
|
581
|
+
start: number;
|
|
582
|
+
end: number;
|
|
583
|
+
/** Its lines, a continuation (a line starting with a blank) joined to the trailer before it */
|
|
584
|
+
lines: string[];
|
|
585
|
+
/** A blank line comes right before `start` */
|
|
586
|
+
blankLineBefore: boolean;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** trailer.c's trailer_block_get. */
|
|
590
|
+
function trailerBlock(message: string, config: Resolved, noDivider: boolean): Block {
|
|
591
|
+
const end = endOfLogMessage(message, noDivider, config.commentString);
|
|
257
592
|
const start = trailerBlockStart(message, end, config);
|
|
258
593
|
const lines: string[] = [];
|
|
259
594
|
let lastIsTrailer = false;
|
|
@@ -266,25 +601,442 @@ function trailerBlock(
|
|
|
266
601
|
continue;
|
|
267
602
|
}
|
|
268
603
|
lines.push(line);
|
|
269
|
-
lastIsTrailer = findSeparator(line, 0, config.separators) >= 1;
|
|
604
|
+
lastIsTrailer = findSeparator(line, 0, config.separators, config.legacy) >= 1;
|
|
270
605
|
}
|
|
271
|
-
|
|
606
|
+
// ends_with_blank_line(message, start)
|
|
607
|
+
const ll = lastLine(message, start);
|
|
608
|
+
return { start, end, lines, blankLineBefore: ll >= 0 && isBlankLine(message, ll) };
|
|
272
609
|
}
|
|
273
610
|
|
|
274
|
-
/**
|
|
275
|
-
|
|
611
|
+
/** A line of a block, or a trailer to add (git's `trailer_item`). */
|
|
612
|
+
interface Item {
|
|
613
|
+
/** undefined for a line that is not a trailer */
|
|
614
|
+
token?: string;
|
|
615
|
+
value: string;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** The settings a trailer is added with (git's `conf_info`). */
|
|
619
|
+
interface Conf {
|
|
620
|
+
command?: string;
|
|
621
|
+
cmd?: string;
|
|
622
|
+
where: TrailerWhere;
|
|
623
|
+
ifExists: TrailerIfExists;
|
|
624
|
+
ifMissing: TrailerIfMissing;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** A trailer to add (git's `arg_item`). */
|
|
628
|
+
interface ArgItem {
|
|
629
|
+
token: string;
|
|
630
|
+
value: string;
|
|
631
|
+
conf: Conf;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function confOf(item: TrailerItemConfig | undefined, config: Resolved): Conf {
|
|
276
635
|
return {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
636
|
+
...(item?.command !== undefined ? { command: item.command } : {}),
|
|
637
|
+
...(item?.cmd !== undefined ? { cmd: item.cmd } : {}),
|
|
638
|
+
where: item?.where ?? config.where,
|
|
639
|
+
ifExists: item?.ifExists ?? config.ifExists,
|
|
640
|
+
ifMissing: item?.ifMissing ?? config.ifMissing,
|
|
280
641
|
};
|
|
281
642
|
}
|
|
282
643
|
|
|
283
644
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
|
|
287
|
-
|
|
645
|
+
* git's parse_trailer: the token and value of `trailer` around its separator (the whole
|
|
646
|
+
* text as the token for -1), the token replaced by the `key` of the item it names.
|
|
647
|
+
*/
|
|
648
|
+
function parseTrailer(
|
|
649
|
+
trailer: string,
|
|
650
|
+
separatorPos: number,
|
|
651
|
+
config: Resolved,
|
|
652
|
+
): { token: string; value: string; item?: TrailerItemConfig } {
|
|
653
|
+
let token: string;
|
|
654
|
+
let value = "";
|
|
655
|
+
if (separatorPos !== -1) {
|
|
656
|
+
token = trim(trailer.slice(0, separatorPos));
|
|
657
|
+
value = trim(trailer.slice(separatorPos + 1));
|
|
658
|
+
} else token = trim(trailer);
|
|
659
|
+
const len = tokenLength(token);
|
|
660
|
+
const item = config.items.find((i) => tokenMatches(token, i, len));
|
|
661
|
+
if (item) return { token: item.key ?? token, value, item };
|
|
662
|
+
return { token, value };
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** trailer.c's parse_trailers: the block of `message` and its items. */
|
|
666
|
+
function parseTrailers(
|
|
667
|
+
message: string,
|
|
668
|
+
options: { unfold?: boolean; onlyTrailers?: boolean; noDivider: boolean },
|
|
669
|
+
config: Resolved,
|
|
670
|
+
): { block: Block; items: Item[] } {
|
|
671
|
+
const block = trailerBlock(message, config, options.noDivider);
|
|
672
|
+
const items: Item[] = [];
|
|
673
|
+
for (const trailer of block.lines) {
|
|
674
|
+
if (trailer.startsWith(config.commentString)) continue;
|
|
675
|
+
const separatorPos = findSeparator(trailer, 0, config.separators, config.legacy);
|
|
676
|
+
if (separatorPos >= 1) {
|
|
677
|
+
const parsed = parseTrailer(trailer, separatorPos, config);
|
|
678
|
+
items.push({
|
|
679
|
+
token: parsed.token,
|
|
680
|
+
value: options.unfold ? unfoldValue(parsed.value) : parsed.value,
|
|
681
|
+
});
|
|
682
|
+
} else if (!options.onlyTrailers) {
|
|
683
|
+
items.push({ value: trailer.endsWith("\n") ? trailer.slice(0, -1) : trailer });
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return { block, items };
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* The lines of the trailer block of `message` (sequencer.c's trailer_iterator: no `---`
|
|
691
|
+
* divider, values unfolded, non-trailer and comment lines included).
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* ```typescript
|
|
695
|
+
* trailerLinesOf("Fix\n\nAcked-by: A\n").map((t) => [t.key, t.value]); // [["Acked-by", "A"]]
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
export function trailerLinesOf(message: string, trailerConfig: TrailerConfig = {}): TrailerLine[] {
|
|
699
|
+
const config = resolve(trailerConfig);
|
|
700
|
+
const { lines } = trailerBlock(message, config, true);
|
|
701
|
+
return lines.map((raw) => {
|
|
702
|
+
const separatorPos = findSeparator(raw, 0, config.separators, config.legacy);
|
|
703
|
+
const parsed = parseTrailer(raw, separatorPos, config);
|
|
704
|
+
return {
|
|
705
|
+
raw,
|
|
706
|
+
key: parsed.token,
|
|
707
|
+
value: unfoldValue(parsed.value),
|
|
708
|
+
isTrailer: separatorPos >= 1,
|
|
709
|
+
};
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/** git's same_token: the tokens without final punctuation agree over the shorter, without case. */
|
|
714
|
+
function sameToken(a: Item, b: ArgItem): boolean {
|
|
715
|
+
if (a.token === undefined) return false;
|
|
716
|
+
const len = Math.min(tokenLength(a.token), tokenLength(b.token));
|
|
717
|
+
return sameStart(a.token, b.token, len);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** git's same_trailer: same token and the same value without case. */
|
|
721
|
+
function sameTrailer(a: Item, b: ArgItem): boolean {
|
|
722
|
+
return sameToken(a, b) && lowerAscii(a.value) === lowerAscii(b.value);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const afterOrEnd = (where: TrailerWhere) => where === "after" || where === "end";
|
|
726
|
+
|
|
727
|
+
/** The state of one run of the engine: the commands' runner and git's stderr. */
|
|
728
|
+
interface Run {
|
|
729
|
+
config: Resolved;
|
|
730
|
+
runCommand?: TrailerCommandRunner;
|
|
731
|
+
errors: string[];
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** git's apply_command: the command's trimmed output, "" (and an error) when it failed. */
|
|
735
|
+
async function applyCommand(conf: Conf, arg: string, run: Run): Promise<string> {
|
|
736
|
+
let command: TrailerCommand;
|
|
737
|
+
if (conf.cmd !== undefined) command = { command: conf.cmd, args: [arg] };
|
|
738
|
+
else {
|
|
739
|
+
const text = conf.command ?? "";
|
|
740
|
+
const at = text.indexOf("$ARG");
|
|
741
|
+
command = {
|
|
742
|
+
command: at < 0 ? text : text.slice(0, at) + arg + text.slice(at + "$ARG".length),
|
|
743
|
+
args: [],
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
const outcome = await run.runCommand?.(command);
|
|
747
|
+
if (outcome?.stderr) run.errors.push(outcome.stderr);
|
|
748
|
+
if (outcome?.exitCode !== 0) {
|
|
749
|
+
run.errors.push(`error: running trailer command '${command.command}' failed\n`);
|
|
750
|
+
return "";
|
|
751
|
+
}
|
|
752
|
+
return trim(outcome.stdout);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/** git's apply_item_command: the value of a trailer with a command, from its output. */
|
|
756
|
+
async function applyItemCommand(inTok: Item | undefined, arg: ArgItem, run: Run): Promise<void> {
|
|
757
|
+
if (!run.runCommand) return;
|
|
758
|
+
if (arg.conf.command === undefined && arg.conf.cmd === undefined) return;
|
|
759
|
+
const value = arg.value ? arg.value : (inTok?.value ?? "");
|
|
760
|
+
arg.value = await applyCommand(arg.conf, value, run);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** git's add_arg_to_input_list: after `on` (after, end) or before it. */
|
|
764
|
+
function addArg(list: Item[], on: Item, arg: ArgItem): void {
|
|
765
|
+
const at = list.indexOf(on);
|
|
766
|
+
const item: Item = { token: arg.token, value: arg.value };
|
|
767
|
+
list.splice(afterOrEnd(arg.conf.where) ? at + 1 : at, 0, item);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/** git's check_if_different: no trailer from `inTok` on (toward the start for after/end) is the same. */
|
|
771
|
+
function checkIfDifferent(list: Item[], inTok: Item, arg: ArgItem, checkAll: boolean): boolean {
|
|
772
|
+
const step = afterOrEnd(arg.conf.where) ? -1 : 1;
|
|
773
|
+
let i = list.indexOf(inTok);
|
|
774
|
+
do {
|
|
775
|
+
if (sameTrailer(list[i] as Item, arg)) return false;
|
|
776
|
+
i += step;
|
|
777
|
+
if (i < 0 || i >= list.length) break;
|
|
778
|
+
} while (checkAll);
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** git's apply_arg_if_exists. */
|
|
783
|
+
async function applyIfExists(
|
|
784
|
+
list: Item[],
|
|
785
|
+
inTok: Item,
|
|
786
|
+
arg: ArgItem,
|
|
787
|
+
on: Item,
|
|
788
|
+
run: Run,
|
|
789
|
+
): Promise<void> {
|
|
790
|
+
switch (arg.conf.ifExists) {
|
|
791
|
+
case "doNothing":
|
|
792
|
+
return;
|
|
793
|
+
case "replace":
|
|
794
|
+
await applyItemCommand(inTok, arg, run);
|
|
795
|
+
addArg(list, on, arg);
|
|
796
|
+
list.splice(list.indexOf(inTok), 1);
|
|
797
|
+
return;
|
|
798
|
+
case "add":
|
|
799
|
+
await applyItemCommand(inTok, arg, run);
|
|
800
|
+
addArg(list, on, arg);
|
|
801
|
+
return;
|
|
802
|
+
case "addIfDifferent":
|
|
803
|
+
await applyItemCommand(inTok, arg, run);
|
|
804
|
+
if (checkIfDifferent(list, inTok, arg, true)) addArg(list, on, arg);
|
|
805
|
+
return;
|
|
806
|
+
case "addIfDifferentNeighbor":
|
|
807
|
+
await applyItemCommand(inTok, arg, run);
|
|
808
|
+
if (checkIfDifferent(list, on, arg, false)) addArg(list, on, arg);
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** git's process_trailers_lists: each trailer to add applied to the block's items. */
|
|
814
|
+
async function processLists(list: Item[], args: ArgItem[], run: Run): Promise<void> {
|
|
815
|
+
for (const arg of args) {
|
|
816
|
+
// find_same_and_apply_arg
|
|
817
|
+
const where = arg.conf.where;
|
|
818
|
+
const middle = where === "after" || where === "before";
|
|
819
|
+
const backwards = afterOrEnd(where);
|
|
820
|
+
let applied = false;
|
|
821
|
+
if (list.length > 0) {
|
|
822
|
+
const start = (backwards ? list[list.length - 1] : list[0]) as Item;
|
|
823
|
+
const order = backwards ? [...list].reverse() : [...list];
|
|
824
|
+
for (const inTok of order) {
|
|
825
|
+
if (!sameToken(inTok, arg)) continue;
|
|
826
|
+
await applyIfExists(list, inTok, arg, middle ? inTok : start, run);
|
|
827
|
+
applied = true;
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
if (applied) continue;
|
|
832
|
+
// apply_arg_if_missing
|
|
833
|
+
if (arg.conf.ifMissing === "doNothing") continue;
|
|
834
|
+
await applyItemCommand(undefined, arg, run);
|
|
835
|
+
const item: Item = { token: arg.token, value: arg.value };
|
|
836
|
+
if (afterOrEnd(where)) list.push(item);
|
|
837
|
+
else list.unshift(item);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/** git's parse_trailers_from_config: a trailer for each item with a `command`. */
|
|
842
|
+
function argsFromConfig(run: Run): ArgItem[] {
|
|
843
|
+
// a host that runs no commands adds none
|
|
844
|
+
if (!run.runCommand) return [];
|
|
845
|
+
return run.config.items
|
|
846
|
+
.filter((item) => item.command !== undefined)
|
|
847
|
+
.map((item) => ({ token: item.key ?? item.name, value: "", conf: confOf(item, run.config) }));
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/** git's parse_trailers_from_command_line_args (`=` is a separator there too). */
|
|
851
|
+
function argsFromCommandLine(trailers: readonly NewTrailer[], run: Run): ArgItem[] {
|
|
852
|
+
const config = run.config;
|
|
853
|
+
const separators = `=${config.separators}`;
|
|
854
|
+
const args: ArgItem[] = [];
|
|
855
|
+
for (const trailer of trailers) {
|
|
856
|
+
const separatorPos = findSeparator(trailer.text, 0, separators, config.legacy);
|
|
857
|
+
if (separatorPos === 0) {
|
|
858
|
+
run.errors.push(`error: empty trailer token in trailer '${trim(trailer.text)}'\n`);
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
const parsed = parseTrailer(trailer.text, separatorPos, config);
|
|
862
|
+
const conf = confOf(parsed.item, config);
|
|
863
|
+
if (trailer.where) conf.where = trailer.where;
|
|
864
|
+
if (trailer.ifExists) conf.ifExists = trailer.ifExists;
|
|
865
|
+
if (trailer.ifMissing) conf.ifMissing = trailer.ifMissing;
|
|
866
|
+
args.push({ token: parsed.token, value: parsed.value, conf });
|
|
867
|
+
}
|
|
868
|
+
return args;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** git's last_non_space_char. */
|
|
872
|
+
function lastNonSpace(s: string): string {
|
|
873
|
+
for (let i = s.length - 1; i >= 0; i--) if (!isSpace(s[i])) return s[i] as string;
|
|
874
|
+
return "";
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** format_trailers for interpret-trailers (2.43: print_all). */
|
|
878
|
+
function formatItems(
|
|
879
|
+
items: readonly Item[],
|
|
880
|
+
options: { trimEmpty?: boolean; onlyTrailers?: boolean },
|
|
881
|
+
config: Resolved,
|
|
882
|
+
): string {
|
|
883
|
+
let out = "";
|
|
884
|
+
for (const item of items) {
|
|
885
|
+
if (item.token !== undefined) {
|
|
886
|
+
if (options.trimEmpty && item.value === "") continue;
|
|
887
|
+
const c = lastNonSpace(item.token);
|
|
888
|
+
// 2.43's print_tok_val prints nothing for a token of blanks
|
|
889
|
+
if (config.legacy && !c) continue;
|
|
890
|
+
out += item.token;
|
|
891
|
+
if (c && !config.separators.includes(c)) out += `${config.separators[0]} `;
|
|
892
|
+
out += `${item.value}\n`;
|
|
893
|
+
} else if (!options.onlyTrailers) {
|
|
894
|
+
if (config.legacy && options.trimEmpty && item.value === "") continue;
|
|
895
|
+
out += `${item.value}\n`;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return out;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** The trailers as {@link NewTrailer}s, strings taking the options' placement. */
|
|
902
|
+
function newTrailersOf(options: InterpretTrailersOptions): NewTrailer[] {
|
|
903
|
+
return (options.trailers ?? []).map((t) =>
|
|
904
|
+
typeof t === "string"
|
|
905
|
+
? {
|
|
906
|
+
text: t,
|
|
907
|
+
...(options.where ? { where: options.where } : {}),
|
|
908
|
+
...(options.ifExists ? { ifExists: options.ifExists } : {}),
|
|
909
|
+
...(options.ifMissing ? { ifMissing: options.ifMissing } : {}),
|
|
910
|
+
}
|
|
911
|
+
: t,
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* trailer.c's process_trailers: `message` with its trailer block parsed, the configured and
|
|
917
|
+
* given trailers applied, and the block written back (the text around it kept as it is).
|
|
918
|
+
*/
|
|
919
|
+
export async function processTrailers(
|
|
920
|
+
message: string,
|
|
921
|
+
options: InterpretTrailersOptions = {},
|
|
922
|
+
trailerConfig: TrailerConfig = {},
|
|
923
|
+
): Promise<InterpretTrailersResult> {
|
|
924
|
+
const config = resolve(trailerConfig);
|
|
925
|
+
const onlyTrailers = options.onlyTrailers || options.parse;
|
|
926
|
+
const onlyInput = options.onlyInput || options.parse;
|
|
927
|
+
const unfold = options.unfold || options.parse;
|
|
928
|
+
const run: Run = {
|
|
929
|
+
config,
|
|
930
|
+
...(options.runCommand ? { runCommand: options.runCommand } : {}),
|
|
931
|
+
errors: [],
|
|
932
|
+
};
|
|
933
|
+
const { block, items } = parseTrailers(
|
|
934
|
+
message,
|
|
935
|
+
{ unfold: !!unfold, onlyTrailers: !!onlyTrailers, noDivider: !!options.noDivider },
|
|
936
|
+
config,
|
|
937
|
+
);
|
|
938
|
+
let out = "";
|
|
939
|
+
if (!onlyTrailers) out += message.slice(0, block.start);
|
|
940
|
+
if (!onlyTrailers && !block.blankLineBefore) out += "\n";
|
|
941
|
+
if (!onlyInput) {
|
|
942
|
+
const args = [...argsFromConfig(run), ...argsFromCommandLine(newTrailersOf(options), run)];
|
|
943
|
+
await processLists(items, args, run);
|
|
944
|
+
}
|
|
945
|
+
out += formatItems(
|
|
946
|
+
items,
|
|
947
|
+
{ trimEmpty: !!options.trimEmpty, onlyTrailers: !!onlyTrailers },
|
|
948
|
+
config,
|
|
949
|
+
);
|
|
950
|
+
if (!onlyTrailers) out += message.slice(block.end);
|
|
951
|
+
return { output: out, errors: run.errors.join("") };
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* `git interpret-trailers` on one input: the message completed with a line end (as git 2.44+
|
|
956
|
+
* reads its input), then {@link processTrailers}. `trailers` with `onlyInput`/`parse` is git's usage
|
|
957
|
+
* error.
|
|
958
|
+
*
|
|
959
|
+
* @example
|
|
960
|
+
* ```typescript
|
|
961
|
+
* const config = { items: [{ name: "ack", key: "Acked-by" }] };
|
|
962
|
+
* (await interpretTrailers("Fix\n", { trailers: ["ack: Peff"] }, config)).output;
|
|
963
|
+
* // "Fix\n\nAcked-by: Peff\n"
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
export async function interpretTrailers(
|
|
967
|
+
message: string,
|
|
968
|
+
options: InterpretTrailersOptions = {},
|
|
969
|
+
trailerConfig: TrailerConfig = {},
|
|
970
|
+
): Promise<InterpretTrailersResult> {
|
|
971
|
+
if ((options.onlyInput || options.parse) && (options.trailers?.length ?? 0) > 0) {
|
|
972
|
+
throw new GitApiError("error: --trailer with --only-input does not make sense", {
|
|
973
|
+
exitCode: 129,
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
// read_input_file's strbuf_complete_line (2.44+; 2.43 reads the input as it is)
|
|
977
|
+
const complete =
|
|
978
|
+
trailerConfig.compatibility !== "2.43" && message.length > 0 && !message.endsWith("\n");
|
|
979
|
+
return processTrailers(complete ? `${message}\n` : message, options, trailerConfig);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* git's validate_trailer_args: the `error:` line refusing the first `--trailer` argument that
|
|
984
|
+
* is empty or starts with a separator; undefined when all are fine.
|
|
985
|
+
*/
|
|
986
|
+
export function validateTrailerArgs(
|
|
987
|
+
args: readonly string[],
|
|
988
|
+
trailerConfig: TrailerConfig = {},
|
|
989
|
+
): string | undefined {
|
|
990
|
+
const config = resolve(trailerConfig);
|
|
991
|
+
const separators = `=${config.separators}`;
|
|
992
|
+
for (const text of args) {
|
|
993
|
+
if (!text) return "error: empty --trailer argument";
|
|
994
|
+
if (findSeparator(text, 0, separators, config.legacy) === 0) {
|
|
995
|
+
return `error: invalid trailer '${text}': missing key before separator`;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
return undefined;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* trailer.c's amend_strbuf_with_trailers, what `commit`, `tag`, `merge`, `rebase` and
|
|
1003
|
+
* `cherry-pick` do with their `--trailer` arguments: each added to `message` as
|
|
1004
|
+
* `interpret-trailers --no-divider --trailer <arg>` adds it (the configured `where`, `ifexists`,
|
|
1005
|
+
* `ifmissing` and commands apply). An empty argument throws git's `empty --trailer argument`.
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* ```typescript
|
|
1009
|
+
* (await amendWithTrailers("Fix\n", ["Closes: #12"])).output; // "Fix\n\nCloses: #12\n"
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
export async function amendWithTrailers(
|
|
1013
|
+
message: string,
|
|
1014
|
+
args: readonly string[],
|
|
1015
|
+
trailerConfig: TrailerConfig = {},
|
|
1016
|
+
runCommand?: TrailerCommandRunner,
|
|
1017
|
+
): Promise<InterpretTrailersResult> {
|
|
1018
|
+
if (args.some((a) => a === "")) {
|
|
1019
|
+
throw new GitApiError("error: empty --trailer argument", { exitCode: 128 });
|
|
1020
|
+
}
|
|
1021
|
+
return processTrailers(
|
|
1022
|
+
message,
|
|
1023
|
+
{ trailers: args, noDivider: true, ...(runCommand ? { runCommand } : {}) },
|
|
1024
|
+
trailerConfig,
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/** git's `Signed-off-by: <name> <email>` line (sign_off_header and fmt_name), with its line end. */
|
|
1029
|
+
export function signoffLine(ident: { name: string; email: string }): string {
|
|
1030
|
+
return `Signed-off-by: ${ident.name} <${ident.email}>\n`;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* sequencer.c's append_signoff: `sob` (`Signed-off-by: <ident>` and a line end, see
|
|
1035
|
+
* {@link signoffLine}) added to `message` before its last `ignoreFooter` characters (commit's
|
|
1036
|
+
* comments and scissors, `ignored_log_message_bytes`), after a blank line unless the message
|
|
1037
|
+
* ends with a trailer block; nothing added when the block's last line is `sob` already
|
|
1038
|
+
* (has_conforming_footer), or when the message is `sob` alone. `dedup`
|
|
1039
|
+
* (APPEND_SIGNOFF_DEDUP, format-patch) adds nothing when the block has `sob` anywhere.
|
|
288
1040
|
*
|
|
289
1041
|
* @example
|
|
290
1042
|
* ```typescript
|
|
@@ -297,56 +1049,37 @@ export function appendSignoff(
|
|
|
297
1049
|
sob: string,
|
|
298
1050
|
trailerConfig: TrailerConfig = {},
|
|
299
1051
|
dedup = false,
|
|
1052
|
+
ignoreFooter = 0,
|
|
300
1053
|
): string {
|
|
301
1054
|
// strbuf_complete_line
|
|
302
|
-
let out =
|
|
1055
|
+
let out =
|
|
1056
|
+
ignoreFooter === 0 && message.length > 0 && !message.endsWith("\n") ? `${message}\n` : message;
|
|
1057
|
+
const len = out.length - ignoreFooter;
|
|
1058
|
+
const body = out.slice(0, len);
|
|
303
1059
|
let footer: 0 | 1 | 2 | 3;
|
|
304
|
-
if (
|
|
1060
|
+
if (body === sob) footer = 3;
|
|
305
1061
|
else {
|
|
306
|
-
|
|
1062
|
+
// has_conforming_footer
|
|
1063
|
+
const { lines } = trailerBlock(body, resolve(trailerConfig), true);
|
|
307
1064
|
let found = 0;
|
|
308
1065
|
lines.forEach((line, k) => {
|
|
309
1066
|
if (line.startsWith(sob)) found = k + 1;
|
|
310
1067
|
});
|
|
311
1068
|
footer = lines.length === 0 ? 0 : found === lines.length ? 3 : found ? 2 : 1;
|
|
312
1069
|
}
|
|
1070
|
+
const insert = (text: string) => {
|
|
1071
|
+
const at = out.length - ignoreFooter;
|
|
1072
|
+
out = out.slice(0, at) + text + out.slice(at);
|
|
1073
|
+
};
|
|
313
1074
|
if (footer === 0) {
|
|
314
|
-
if (
|
|
315
|
-
else if (
|
|
316
|
-
else if (out[
|
|
1075
|
+
if (len === 0) insert("\n\n");
|
|
1076
|
+
else if (len === 1) insert("\n");
|
|
1077
|
+
else if (out[len - 2] !== "\n") insert("\n");
|
|
317
1078
|
}
|
|
318
|
-
|
|
319
|
-
if (footer !== 3 && !(dedup && footer === 2)) out += sob;
|
|
1079
|
+
if (footer !== 3 && !(dedup && footer === 2)) insert(sob);
|
|
320
1080
|
return out;
|
|
321
1081
|
}
|
|
322
1082
|
|
|
323
|
-
/** The block of `message` and its items (trailer.c's parse_trailers, no `---` divider). */
|
|
324
|
-
function parseTrailers(
|
|
325
|
-
message: string,
|
|
326
|
-
options: TrailerFormatOptions,
|
|
327
|
-
config: Required<TrailerConfig>,
|
|
328
|
-
): { start: number; end: number; items: TrailerItem[] } {
|
|
329
|
-
const { start, end, lines } = trailerBlock(message, config);
|
|
330
|
-
const items: TrailerItem[] = [];
|
|
331
|
-
for (const trailer of lines) {
|
|
332
|
-
if (trailer.startsWith(config.commentString)) continue;
|
|
333
|
-
const separatorPos = findSeparator(trailer, 0, config.separators);
|
|
334
|
-
if (separatorPos >= 1) {
|
|
335
|
-
// parse_trailer: the token as configured (an item's key, when it names one)
|
|
336
|
-
let token = trim(trailer.slice(0, separatorPos));
|
|
337
|
-
let value = trim(trailer.slice(separatorPos + 1));
|
|
338
|
-
const len = tokenLength(token);
|
|
339
|
-
const item = config.items.find((i) => tokenMatches(token, i, len));
|
|
340
|
-
if (item?.key !== undefined) token = item.key;
|
|
341
|
-
if (options.unfold) value = unfoldValue(value);
|
|
342
|
-
items.push({ token, value });
|
|
343
|
-
} else if (!options.onlyTrailers) {
|
|
344
|
-
items.push({ value: trailer.endsWith("\n") ? trailer.slice(0, -1) : trailer });
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return { start, end, items };
|
|
348
|
-
}
|
|
349
|
-
|
|
350
1083
|
/**
|
|
351
1084
|
* trailer.c's format_trailers_from_commit: the trailer block of `message` (from its
|
|
352
1085
|
* subject), whole when no option changes it, else each trailer formatted. `before` is what
|
|
@@ -359,8 +1092,12 @@ export function appendTrailers(
|
|
|
359
1092
|
options: TrailerFormatOptions = {},
|
|
360
1093
|
trailerConfig: TrailerConfig = {},
|
|
361
1094
|
): string {
|
|
362
|
-
const config =
|
|
363
|
-
const block = parseTrailers(
|
|
1095
|
+
const config = resolve(trailerConfig);
|
|
1096
|
+
const { block, items } = parseTrailers(
|
|
1097
|
+
message,
|
|
1098
|
+
{ unfold: !!options.unfold, onlyTrailers: !!options.onlyTrailers, noDivider: true },
|
|
1099
|
+
config,
|
|
1100
|
+
);
|
|
364
1101
|
const filtered = options.keys !== undefined;
|
|
365
1102
|
if (
|
|
366
1103
|
!options.onlyTrailers &&
|
|
@@ -375,7 +1112,7 @@ export function appendTrailers(
|
|
|
375
1112
|
}
|
|
376
1113
|
let out = before;
|
|
377
1114
|
const origLength = out.length;
|
|
378
|
-
for (const item of
|
|
1115
|
+
for (const item of items) {
|
|
379
1116
|
if (item.token !== undefined) {
|
|
380
1117
|
const token = item.token;
|
|
381
1118
|
const keep =
|
|
@@ -391,7 +1128,7 @@ export function appendTrailers(
|
|
|
391
1128
|
if (!options.keyOnly && !options.valueOnly) {
|
|
392
1129
|
if (options.keyValueSeparator !== undefined) out += options.keyValueSeparator;
|
|
393
1130
|
else {
|
|
394
|
-
const last = token
|
|
1131
|
+
const last = lastNonSpace(token);
|
|
395
1132
|
if (last && !config.separators.includes(last)) out += `${config.separators[0]} `;
|
|
396
1133
|
}
|
|
397
1134
|
}
|