@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
|
@@ -1,18 +1,109 @@
|
|
|
1
1
|
import type { AnnotatedTag, ObjectId, PersonIdent, Ref } from "@statewalker/vcs-core";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
collectTagBytes,
|
|
4
|
+
compareRefNames,
|
|
5
|
+
isValidTagName,
|
|
6
|
+
ObjectType,
|
|
7
|
+
} from "@statewalker/vcs-core";
|
|
8
|
+
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
3
9
|
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
4
10
|
|
|
5
11
|
import {
|
|
6
12
|
GitApiError,
|
|
13
|
+
InvalidArgumentError,
|
|
7
14
|
InvalidTagNameError,
|
|
8
15
|
RefAlreadyExistsError,
|
|
16
|
+
RefFilterError,
|
|
9
17
|
RefNotFoundError,
|
|
10
18
|
StoreNotAvailableError,
|
|
11
19
|
} from "../errors/index.js";
|
|
12
20
|
import { type CommandCommits, GitCommand } from "../git-command.js";
|
|
21
|
+
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
22
|
+
import type { CommitEditor } from "./commit-command.js";
|
|
13
23
|
import { abbrevLengths } from "./core-config.js";
|
|
14
|
-
import {
|
|
24
|
+
import { OperationState } from "./merge-support.js";
|
|
25
|
+
import { CleanupMode, commentPrefixOf, completeLine, stripspace } from "./message-cleanup.js";
|
|
15
26
|
import { canonicalObjectId, isFullHexObjectId } from "./object-id-input.js";
|
|
27
|
+
import {
|
|
28
|
+
filterAndFormatRefs,
|
|
29
|
+
filterRefs,
|
|
30
|
+
parseRefSorting,
|
|
31
|
+
type RefFilterOptions,
|
|
32
|
+
RefFormat,
|
|
33
|
+
RefKind,
|
|
34
|
+
RefListingCommand,
|
|
35
|
+
type RefSortKey,
|
|
36
|
+
signatureStart,
|
|
37
|
+
} from "./ref-filter/index.js";
|
|
38
|
+
import { SigningFailedError, signPayload } from "./signing.js";
|
|
39
|
+
import {
|
|
40
|
+
amendWithTrailers,
|
|
41
|
+
type TrailerCommandRunner,
|
|
42
|
+
trailerConfigOf,
|
|
43
|
+
validateTrailerArgs,
|
|
44
|
+
} from "./trailers.js";
|
|
45
|
+
|
|
46
|
+
/** What `git tag <name>` printed ({@link TagCommand.callText}). */
|
|
47
|
+
export interface TagCreateResult {
|
|
48
|
+
/** The tag's ref as written */
|
|
49
|
+
ref: Ref;
|
|
50
|
+
/** git's stdout: `Updated tag '<name>' (was <abbrev>)` and its newline under `-f`, else empty */
|
|
51
|
+
output: string;
|
|
52
|
+
/** git's stderr lines (the nested-tag advice) */
|
|
53
|
+
warnings: string[];
|
|
54
|
+
/** The value the tag had before (under `-f`) */
|
|
55
|
+
previous?: ObjectId;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The object type codes of a tag's `type` header. */
|
|
59
|
+
const OBJECT_TYPE_CODES = {
|
|
60
|
+
commit: ObjectType.COMMIT,
|
|
61
|
+
tree: ObjectType.TREE,
|
|
62
|
+
blob: ObjectType.BLOB,
|
|
63
|
+
tag: ObjectType.TAG,
|
|
64
|
+
} as const;
|
|
65
|
+
|
|
66
|
+
/** builtin/tag.c's tag_template (strip) and tag_template_nocleanup (whitespace, verbatim). */
|
|
67
|
+
function tagTemplate(name: string, comment: string, cleanup: CleanupMode): string {
|
|
68
|
+
const tail =
|
|
69
|
+
cleanup === CleanupMode.STRIP
|
|
70
|
+
? `Lines starting with '${comment}' will be ignored.\n`
|
|
71
|
+
: `Lines starting with '${comment}' will be kept; you may remove them yourself if you want to.\n`;
|
|
72
|
+
return `\nWrite a message for tag:\n ${name}\n${tail}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* strbuf_add_commented_lines: each line after the comment prefix, and a space unless the
|
|
77
|
+
* line is empty or starts with a tab.
|
|
78
|
+
*/
|
|
79
|
+
function commentedLines(text: string, prefix: string): string {
|
|
80
|
+
let out = "";
|
|
81
|
+
for (const line of text.split(/(?<=\n)/)) {
|
|
82
|
+
if (line === "") continue;
|
|
83
|
+
out += prefix;
|
|
84
|
+
if (line[0] !== "\n" && line[0] !== "\t") out += " ";
|
|
85
|
+
out += line;
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** create_tag's advice when the tagged object is a tag (`advice.nestedTag`). */
|
|
91
|
+
function nestedTagAdvice(
|
|
92
|
+
name: string,
|
|
93
|
+
objectRef: string,
|
|
94
|
+
compatibility: "2.43" | "2.56",
|
|
95
|
+
): string[] {
|
|
96
|
+
return [
|
|
97
|
+
"hint: You have created a nested tag. The object referred to by your new tag is",
|
|
98
|
+
"hint: already a tag. If you meant to tag the object that it points to, use:",
|
|
99
|
+
// 2.43's advise_if_enabled wrote "hint: " before an empty line too
|
|
100
|
+
compatibility === "2.43" ? "hint: " : "hint:",
|
|
101
|
+
`hint: \tgit tag -f ${name} ${objectRef}^{}`,
|
|
102
|
+
compatibility === "2.43"
|
|
103
|
+
? 'hint: Disable this message with "git config advice.nestedTag false"'
|
|
104
|
+
: 'hint: Disable this message with "git config set advice.nestedTag false"',
|
|
105
|
+
];
|
|
106
|
+
}
|
|
16
107
|
|
|
17
108
|
/**
|
|
18
109
|
* Create a tag (lightweight or annotated).
|
|
@@ -55,8 +146,18 @@ export class TagCommand extends GitCommand<Ref> {
|
|
|
55
146
|
private taggerName?: { name: string; email: string };
|
|
56
147
|
private annotated = false;
|
|
57
148
|
private force = false;
|
|
58
|
-
|
|
149
|
+
/** `-s` / `--no-sign` (undefined: `tag.gpgSign`) */
|
|
150
|
+
private signed?: boolean;
|
|
151
|
+
/** `-u <key-id>` */
|
|
152
|
+
private signingKey?: string;
|
|
59
153
|
private cleanupMode?: CleanupMode;
|
|
154
|
+
/** `-e` */
|
|
155
|
+
private edit = false;
|
|
156
|
+
private editor?: CommitEditor;
|
|
157
|
+
private createReflog = false;
|
|
158
|
+
/** `--trailer` arguments, in order */
|
|
159
|
+
private trailerArgs: string[] = [];
|
|
160
|
+
private compatibility?: "2.43" | "2.56";
|
|
60
161
|
|
|
61
162
|
/**
|
|
62
163
|
* Set the tag name.
|
|
@@ -174,18 +275,106 @@ export class TagCommand extends GitCommand<Ref> {
|
|
|
174
275
|
}
|
|
175
276
|
|
|
176
277
|
/**
|
|
177
|
-
*
|
|
278
|
+
* `-s` (true) / `--no-sign` (false): whether to make a signed tag (an annotated one);
|
|
279
|
+
* undefined (the default) leaves it to `tag.gpgSign`, and `tag.forceSignAnnotated` signs
|
|
280
|
+
* a tag with a message not made with {@link setAnnotated}, as git's does.
|
|
178
281
|
*
|
|
179
|
-
*
|
|
282
|
+
* The tag object is signed through the host's signer (`GitHostEnvironment.signer`) as
|
|
283
|
+
* builtin/tag.c's `do_sign` signs it: `gpg.format`, the `-u` key, else `user.signingKey`,
|
|
284
|
+
* else `gpg.ssh.defaultKeyCommand` (ssh) or the committer (openpgp, x509), the signature
|
|
285
|
+
* appended to the message. Without a signer, or when signing fails, it fails as git
|
|
286
|
+
* (`error: gpg failed to sign the data:`, `error: unable to sign the tag`, exit 128:
|
|
287
|
+
* {@link SigningFailedError}), and neither a tag object nor a ref is written.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* await git.tag().setName("v1.0").setMessage("Release").setSigned(true).call();
|
|
292
|
+
* ```
|
|
180
293
|
*
|
|
181
294
|
* @param signed Whether to sign
|
|
182
295
|
*/
|
|
183
|
-
setSigned(signed: boolean): this {
|
|
296
|
+
setSigned(signed: boolean | undefined): this {
|
|
184
297
|
this.checkCallable();
|
|
185
298
|
this.signed = signed;
|
|
186
299
|
return this;
|
|
187
300
|
}
|
|
188
301
|
|
|
302
|
+
/**
|
|
303
|
+
* `-u <key-id>`: make a tag signed with this key (whatever {@link setSigned} says, as
|
|
304
|
+
* git's `-u` with `--no-sign`); refused as {@link setSigned} says.
|
|
305
|
+
*/
|
|
306
|
+
setSigningKey(keyId: string): this {
|
|
307
|
+
this.checkCallable();
|
|
308
|
+
this.signingKey = keyId;
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* `-e` / `--edit`: the message (`-m` or the default one) goes through the editor
|
|
314
|
+
* ({@link setEditor}) before it is stored, as git's `tag -e`. git 2.5x makes an annotated
|
|
315
|
+
* tag of `-e` alone; 2.43 ignored `-e` without a message (a lightweight tag).
|
|
316
|
+
*/
|
|
317
|
+
setEdit(edit: boolean): this {
|
|
318
|
+
this.checkCallable();
|
|
319
|
+
this.edit = edit;
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The editor of the tag message (git's `core.editor` / `GIT_EDITOR`): given the path of
|
|
325
|
+
* the message file in the git directory (`TAG_EDITMSG`) and its text, it returns the edited
|
|
326
|
+
* text, or anything else after editing the file in place. It runs where git launches the
|
|
327
|
+
* editor: with {@link setEdit}, or for an annotated tag made without a message (the text is
|
|
328
|
+
* then the previous tag's body under `-f`, else git's template, `# Write a message for
|
|
329
|
+
* tag:`). Without an editor that text is taken as it is (as `GIT_EDITOR=:`), so an annotated
|
|
330
|
+
* tag without a message fails as git's `fatal: no tag message?`. An editor that throws
|
|
331
|
+
* fails the tag as git's `Please supply the message using either -m or -F option.` (exit 1).
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* await git.tag().setName("v1").setEdit(true).setMessage("Release")
|
|
336
|
+
* .setEditor(async (_path, text) => `${text}\nNotes.\n`).call();
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
setEditor(editor: CommitEditor): this {
|
|
340
|
+
this.checkCallable();
|
|
341
|
+
this.editor = editor;
|
|
342
|
+
return this;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* `--create-reflog`: create the tag's reflog (git's REF_FORCE_CREATE_REFLOG), whatever
|
|
347
|
+
* `core.logAllRefUpdates` says.
|
|
348
|
+
*/
|
|
349
|
+
setCreateReflog(create: boolean): this {
|
|
350
|
+
this.checkCallable();
|
|
351
|
+
this.createReflog = create;
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* `--trailer <token>[(=|:)<value>]` (git 2.46+): a trailer added to the message as git's
|
|
357
|
+
* `interpret-trailers --no-divider --trailer` adds it (`trailer.*` configuration applies),
|
|
358
|
+
* before the editor runs. A trailer alone makes an annotated tag and launches the editor,
|
|
359
|
+
* as git does.
|
|
360
|
+
*/
|
|
361
|
+
addTrailer(trailer: string): this {
|
|
362
|
+
this.checkCallable();
|
|
363
|
+
this.trailerArgs.push(trailer);
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The git version to follow where versions differ (default: the hook runner's, else 2.56):
|
|
369
|
+
* 2.43 ignores `-e` without a message, writes a `-m` message into the editor's file as
|
|
370
|
+
* given (no newline added, an empty one too) and has no `--trailer`.
|
|
371
|
+
*/
|
|
372
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
373
|
+
this.checkCallable();
|
|
374
|
+
this.compatibility = version;
|
|
375
|
+
return this;
|
|
376
|
+
}
|
|
377
|
+
|
|
189
378
|
/**
|
|
190
379
|
* Execute the tag creation.
|
|
191
380
|
*
|
|
@@ -194,46 +383,109 @@ export class TagCommand extends GitCommand<Ref> {
|
|
|
194
383
|
* @throws RefAlreadyExistsError if tag exists and force is false
|
|
195
384
|
*/
|
|
196
385
|
async call(): Promise<Ref> {
|
|
386
|
+
return (await this.callText()).ref;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* `git tag <name> [<object>]` with git's output: `Updated tag '<name>' (was <abbrev>)` when
|
|
391
|
+
* `-f` moved an existing tag, and the nested-tag advice (`advice.nestedTag`) when the
|
|
392
|
+
* tagged object is a tag itself.
|
|
393
|
+
*
|
|
394
|
+
* @throws GitApiError with git's message and exit status where git dies (`fatal: tag 'x'
|
|
395
|
+
* already exists`, `fatal: 'x' is not a valid tag name.`, `fatal: no tag message?`, ...)
|
|
396
|
+
*/
|
|
397
|
+
async callText(): Promise<TagCreateResult> {
|
|
197
398
|
this.checkCallable();
|
|
198
399
|
|
|
199
|
-
if (
|
|
400
|
+
if (this.name === undefined) {
|
|
200
401
|
throw new InvalidTagNameError("", "Tag name is required");
|
|
201
402
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
403
|
+
const name = this.name;
|
|
404
|
+
const compatibility = this.compatibility ?? this.hooks.compatibility;
|
|
405
|
+
if (compatibility === "2.43" && this.trailerArgs.length > 0) {
|
|
406
|
+
throw new GitApiError("error: unknown option `trailer'", { exitCode: 129 });
|
|
205
407
|
}
|
|
206
408
|
|
|
207
|
-
|
|
409
|
+
// cmd_tag: the object first, then the name, then whether the tag exists
|
|
410
|
+
const objectRef = this.objectId ?? "HEAD";
|
|
411
|
+
let targetId: ObjectId;
|
|
412
|
+
try {
|
|
413
|
+
// a full id in either case, else any revision (git's `get_oid`)
|
|
414
|
+
targetId =
|
|
415
|
+
this.objectId === undefined
|
|
416
|
+
? await this.resolveHead()
|
|
417
|
+
: isFullHexObjectId(this.objectId)
|
|
418
|
+
? this.objectId
|
|
419
|
+
: await this.resolveRevision(this.objectId);
|
|
420
|
+
} catch (e) {
|
|
421
|
+
if (!(e instanceof GitApiError)) throw e;
|
|
422
|
+
throw new RefNotFoundError(
|
|
423
|
+
objectRef,
|
|
424
|
+
`fatal: Failed to resolve '${objectRef}' as a valid ref.`,
|
|
425
|
+
);
|
|
426
|
+
}
|
|
208
427
|
|
|
209
|
-
//
|
|
210
|
-
if (!
|
|
211
|
-
throw new
|
|
428
|
+
// check_tag_ref: 2.43 took a tag named HEAD
|
|
429
|
+
if (!isValidTagName(name) && !(compatibility === "2.43" && name === "HEAD")) {
|
|
430
|
+
throw new InvalidTagNameError(name, `fatal: '${name}' is not a valid tag name.`);
|
|
212
431
|
}
|
|
432
|
+
const refName = `refs/tags/${name}`;
|
|
213
433
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
434
|
+
const existing = await this.refsStore.resolve(refName).catch(() => undefined);
|
|
435
|
+
const prev = existing && "objectId" in existing ? existing.objectId : undefined;
|
|
436
|
+
if (prev !== undefined && !this.force) {
|
|
437
|
+
throw new RefAlreadyExistsError(refName, `fatal: tag '${name}' already exists`);
|
|
438
|
+
}
|
|
439
|
+
const cleanup = this.cleanupMode ?? CleanupMode.STRIP;
|
|
440
|
+
if (
|
|
441
|
+
cleanup !== CleanupMode.STRIP &&
|
|
442
|
+
cleanup !== CleanupMode.WHITESPACE &&
|
|
443
|
+
cleanup !== CleanupMode.VERBATIM
|
|
444
|
+
) {
|
|
445
|
+
throw new InvalidArgumentError("cleanup", cleanup, `fatal: Invalid cleanup mode ${cleanup}`);
|
|
446
|
+
}
|
|
222
447
|
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
|
|
448
|
+
// git's cmd_tag: -u signs whatever --no-sign says, -s/--no-sign win over tag.gpgSign
|
|
449
|
+
const config = RemoteConfigStore.from(this.workingCopy);
|
|
450
|
+
let sign =
|
|
451
|
+
this.signingKey !== undefined ||
|
|
452
|
+
(this.signed ?? configBool(config.value("tag.gpgSign"), false));
|
|
453
|
+
// an annotated tag: -a, -m (an empty one too), -s, --trailer, and in 2.5x -e
|
|
454
|
+
const createAnnotated =
|
|
455
|
+
this.annotated ||
|
|
456
|
+
this.message !== undefined ||
|
|
457
|
+
sign ||
|
|
458
|
+
this.trailerArgs.length > 0 ||
|
|
459
|
+
(this.edit && compatibility !== "2.43");
|
|
460
|
+
// tag.forceSignAnnotated signs a tag object not asked for with -a (git's
|
|
461
|
+
// `force_sign_annotate && !annotate`)
|
|
462
|
+
if (
|
|
463
|
+
createAnnotated &&
|
|
464
|
+
!this.annotated &&
|
|
465
|
+
configBool(config.value("tag.forceSignAnnotated"), false)
|
|
466
|
+
) {
|
|
467
|
+
sign = true;
|
|
468
|
+
}
|
|
226
469
|
|
|
470
|
+
const warnings: string[] = [];
|
|
471
|
+
const state = new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
227
472
|
let tagObjectId: ObjectId;
|
|
228
473
|
|
|
229
474
|
if (createAnnotated) {
|
|
230
|
-
// Create annotated tag object
|
|
231
475
|
if (!this.tagsStore) {
|
|
232
476
|
throw new StoreNotAvailableError(
|
|
233
477
|
"TagStore",
|
|
234
478
|
"Tag store is not available for annotated tags",
|
|
235
479
|
);
|
|
236
480
|
}
|
|
481
|
+
const resolver = this.revisionResolver();
|
|
482
|
+
const type = await resolver.objectType(targetId);
|
|
483
|
+
if (type === undefined) throw new GitApiError("fatal: bad object type.");
|
|
484
|
+
if (type === "tag" && configBool(config.value("advice.nestedTag"), true)) {
|
|
485
|
+
warnings.push(...nestedTagAdvice(name, objectRef, compatibility));
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const message = await this.tagMessage(name, prev, cleanup, compatibility, state);
|
|
237
489
|
|
|
238
490
|
// git's tagger: git_committer_info(IDENT_STRICT) (GIT_COMMITTER_*, committer.*,
|
|
239
491
|
// user.*), unless given
|
|
@@ -243,36 +495,186 @@ export class TagCommand extends GitCommand<Ref> {
|
|
|
243
495
|
|
|
244
496
|
const tag: AnnotatedTag = {
|
|
245
497
|
object: targetId,
|
|
246
|
-
objectType:
|
|
247
|
-
tag:
|
|
498
|
+
objectType: OBJECT_TYPE_CODES[type],
|
|
499
|
+
tag: name,
|
|
248
500
|
tagger,
|
|
249
|
-
message
|
|
250
|
-
this.message !== undefined
|
|
251
|
-
? tagMessageFromOption(this.message, this.cleanupMode, this.workingCopy)
|
|
252
|
-
: "",
|
|
501
|
+
message,
|
|
253
502
|
};
|
|
254
503
|
|
|
504
|
+
// build_tag_object signs before writing (do_sign): the signature appended to the tag
|
|
505
|
+
// object, so to its message
|
|
506
|
+
if (sign) {
|
|
507
|
+
const signature = await this.signTag(
|
|
508
|
+
await collectTagBytes(tag),
|
|
509
|
+
tagger,
|
|
510
|
+
compatibility,
|
|
511
|
+
warnings,
|
|
512
|
+
);
|
|
513
|
+
if (signature) tag.message = `${message}${new TextDecoder().decode(signature)}`;
|
|
514
|
+
}
|
|
255
515
|
tagObjectId = await this.tagsStore.storeTag(tag);
|
|
256
516
|
} else {
|
|
257
517
|
// Lightweight tag - just point to the object
|
|
258
518
|
tagObjectId = targetId;
|
|
259
519
|
}
|
|
260
520
|
|
|
261
|
-
// git's create_reflog_msg; refs/tags/ is logged only with core.logAllRefUpdates=always
|
|
262
|
-
//
|
|
521
|
+
// git's create_reflog_msg; refs/tags/ is logged only with core.logAllRefUpdates=always,
|
|
522
|
+
// an existing reflog or --create-reflog
|
|
263
523
|
const log = await tagReflogMessage(
|
|
264
524
|
this.workingCopy,
|
|
265
525
|
{ commits: this.commits, trees: this.trees, blobs: this.blobs, tags: this.tagsStore },
|
|
266
526
|
targetId,
|
|
267
527
|
this.hasReflogAction() ? this.reflogAction("tag") : undefined,
|
|
268
528
|
);
|
|
269
|
-
|
|
529
|
+
// one transaction: the tag from the value read (none, or `prev` under -f)
|
|
530
|
+
const result = await this.refsStore.batch(
|
|
531
|
+
// no REF_NO_DEREF: a symbolic tag ref is updated through (git moves what it names)
|
|
532
|
+
[{ name: refName, old: prev ?? null, new: tagObjectId }],
|
|
533
|
+
{ ...this.reflogLine(log), ...(this.createReflog ? { createReflog: true } : {}) },
|
|
534
|
+
);
|
|
535
|
+
if (!result.ok) {
|
|
536
|
+
const reasons = result.rejected.map((r) => r.reason).join(", ");
|
|
537
|
+
throw new GitApiError(`fatal: cannot update ref '${refName}': ${reasons}`);
|
|
538
|
+
}
|
|
539
|
+
// the message file goes once the tag is made (unlink_or_warn of TAG_EDITMSG)
|
|
540
|
+
if (createAnnotated && state.supported) await state.remove("TAG_EDITMSG");
|
|
270
541
|
|
|
271
542
|
this.setCallable(false);
|
|
272
543
|
|
|
273
|
-
|
|
274
|
-
|
|
544
|
+
let output = "";
|
|
545
|
+
if (this.force && prev !== undefined && prev !== tagObjectId) {
|
|
546
|
+
output = `Updated tag '${name}' (was ${await this.abbreviateObjectId(prev)})\n`;
|
|
547
|
+
}
|
|
548
|
+
const ref = (await this.refsStore.get(refName)) as Ref;
|
|
549
|
+
return { ref, output, warnings, ...(prev !== undefined ? { previous: prev } : {}) };
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* create_tag's message: the one given, else (or with -e) what the editor leaves of
|
|
554
|
+
* TAG_EDITMSG (the message, the previous tag's body, or git's template), the trailers
|
|
555
|
+
* added first, then cleaned up; an empty one refused unless a message was given.
|
|
556
|
+
*/
|
|
557
|
+
private async tagMessage(
|
|
558
|
+
name: string,
|
|
559
|
+
prev: ObjectId | undefined,
|
|
560
|
+
cleanup: CleanupMode,
|
|
561
|
+
compatibility: "2.43" | "2.56",
|
|
562
|
+
state: OperationState,
|
|
563
|
+
): Promise<string> {
|
|
564
|
+
const messageGiven = this.message !== undefined;
|
|
565
|
+
let buf = this.message ?? "";
|
|
566
|
+
const shouldEdit = this.edit || !messageGiven;
|
|
567
|
+
const comment = commentPrefixOf(this.workingCopy);
|
|
568
|
+
if (shouldEdit || this.trailerArgs.length > 0) {
|
|
569
|
+
let text: string;
|
|
570
|
+
if (messageGiven && compatibility === "2.43") text = buf;
|
|
571
|
+
else if (messageGiven && buf.length > 0) text = completeLine(buf);
|
|
572
|
+
else if (prev !== undefined) text = await this.tagBody(prev);
|
|
573
|
+
else text = `\n${commentedLines(tagTemplate(name, comment, cleanup), comment)}`;
|
|
574
|
+
await state.write("TAG_EDITMSG", text);
|
|
575
|
+
if (this.trailerArgs.length > 0) {
|
|
576
|
+
const trailerConfig = { ...trailerConfigOf(this.workingCopy), commentString: comment };
|
|
577
|
+
const refused = validateTrailerArgs(this.trailerArgs, trailerConfig);
|
|
578
|
+
if (refused !== undefined) {
|
|
579
|
+
throw new GitApiError(`${refused}\nfatal: unable to pass trailers to --trailers`, {
|
|
580
|
+
exitCode: 128,
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
const hooks = this.hooks;
|
|
584
|
+
const runCommand: TrailerCommandRunner | undefined = hooks.enabled
|
|
585
|
+
? (command) => hooks.runShellCommand("trailer", command.command, command.args)
|
|
586
|
+
: undefined;
|
|
587
|
+
text = (await amendWithTrailers(text, this.trailerArgs, trailerConfig, runCommand)).output;
|
|
588
|
+
await state.write("TAG_EDITMSG", text);
|
|
589
|
+
}
|
|
590
|
+
if (shouldEdit && this.editor) {
|
|
591
|
+
let edited: unknown;
|
|
592
|
+
try {
|
|
593
|
+
edited = await this.editor("TAG_EDITMSG", text);
|
|
594
|
+
} catch (e) {
|
|
595
|
+
if (e instanceof GitApiError) throw e;
|
|
596
|
+
throw new GitApiError("Please supply the message using either -m or -F option.", {
|
|
597
|
+
exitCode: 1,
|
|
598
|
+
cause: e,
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
if (typeof edited === "string") {
|
|
602
|
+
await state.write("TAG_EDITMSG", edited);
|
|
603
|
+
buf = edited;
|
|
604
|
+
} else {
|
|
605
|
+
buf = (state.supported ? await state.read("TAG_EDITMSG") : undefined) ?? text;
|
|
606
|
+
}
|
|
607
|
+
} else {
|
|
608
|
+
buf = text;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (cleanup !== CleanupMode.VERBATIM) {
|
|
612
|
+
buf = stripspace(buf, cleanup === CleanupMode.STRIP ? comment : undefined);
|
|
613
|
+
}
|
|
614
|
+
if (!messageGiven && buf.length === 0) throw new GitApiError("fatal: no tag message?");
|
|
615
|
+
return buf;
|
|
275
616
|
}
|
|
617
|
+
|
|
618
|
+
/** write_tag_body: the previous tag object's message without its signature, else nothing. */
|
|
619
|
+
private async tagBody(prev: ObjectId): Promise<string> {
|
|
620
|
+
if ((await this.revisionResolver().objectType(prev)) !== "tag") return "";
|
|
621
|
+
const tag = await this.tagsStore?.loadTag(prev).catch(() => undefined);
|
|
622
|
+
// parse_signature: the payload before a trailing signature
|
|
623
|
+
const message = tag?.message ?? "";
|
|
624
|
+
return message.slice(0, signatureStart(message));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* builtin/tag.c's `do_sign`: `payload` (the tag object without a signature) signed with the
|
|
629
|
+
* `-u` key, else `user.signingKey`, else the format's default (`get_signing_key`: ssh's
|
|
630
|
+
* `gpg.ssh.defaultKeyCommand`, openpgp's and x509's the committer as `Name <email>`), the
|
|
631
|
+
* program run in the worktree top. A failure is create_tag's: the signer's lines, `error:
|
|
632
|
+
* unable to sign the tag` and where the message was left (`TAG_EDITMSG` in the git
|
|
633
|
+
* directory, named as git names it from the top of the worktree: `.git/TAG_EDITMSG`),
|
|
634
|
+
* exit 128; a death of the signing (ssh without a key) only its `fatal:` line. Under 2.43
|
|
635
|
+
* an ssh-keygen that ran and failed leaves the tag unsigned, its error in `warnings`
|
|
636
|
+
* (undefined returned).
|
|
637
|
+
*/
|
|
638
|
+
private async signTag(
|
|
639
|
+
payload: Uint8Array,
|
|
640
|
+
tagger: PersonIdent,
|
|
641
|
+
compatibility: "2.43" | "2.56",
|
|
642
|
+
warnings: string[],
|
|
643
|
+
): Promise<Uint8Array | undefined> {
|
|
644
|
+
const gitDir = (await this.hooks.hostGitDir({ real: false }).catch(() => undefined))?.replace(
|
|
645
|
+
/\/+$/,
|
|
646
|
+
"",
|
|
647
|
+
);
|
|
648
|
+
const top = (await this.hostWorkingDir())?.replace(/\/+$/, "");
|
|
649
|
+
const path =
|
|
650
|
+
gitDir === undefined
|
|
651
|
+
? ".git/TAG_EDITMSG"
|
|
652
|
+
: top !== undefined && gitDir.startsWith(`${top}/`)
|
|
653
|
+
? `${gitDir.slice(top.length + 1)}/TAG_EDITMSG`
|
|
654
|
+
: `${gitDir}/TAG_EDITMSG`;
|
|
655
|
+
const cwd = await this.hooks.hostWorkingDirectory().catch(() => undefined);
|
|
656
|
+
try {
|
|
657
|
+
return await signPayload(this.workingCopy, this.signingKey ?? "", payload, {
|
|
658
|
+
committer: tagger,
|
|
659
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
660
|
+
tail: ["error: unable to sign the tag", `The tag message has been left in ${path}`],
|
|
661
|
+
});
|
|
662
|
+
} catch (e) {
|
|
663
|
+
if (!(e instanceof SigningFailedError)) throw e;
|
|
664
|
+
// git 2.43's do_sign fails only on a negative return, and its sign_buffer_ssh returns
|
|
665
|
+
// ssh-keygen's exit status: the error printed, the tag made unsigned
|
|
666
|
+
if (compatibility === "2.43" && (e.programExitCode ?? 0) > 0) {
|
|
667
|
+
warnings.push(...(e.signerMessages ?? []));
|
|
668
|
+
return undefined;
|
|
669
|
+
}
|
|
670
|
+
throw new SigningFailedError(e.message, e.signingKey, 128);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/** A git boolean (`git_config_bool`), else `fallback`. */
|
|
676
|
+
function configBool(value: string | undefined, fallback: boolean): boolean {
|
|
677
|
+
return value === undefined ? fallback : (parseGitBool(value) ?? fallback);
|
|
276
678
|
}
|
|
277
679
|
|
|
278
680
|
/**
|
|
@@ -288,11 +690,13 @@ export class TagCommand extends GitCommand<Ref> {
|
|
|
288
690
|
*/
|
|
289
691
|
export class DeleteTagCommand extends GitCommand<string[]> {
|
|
290
692
|
private tags: string[] = [];
|
|
693
|
+
private compatibility?: "2.43" | "2.56";
|
|
291
694
|
|
|
292
695
|
/**
|
|
293
696
|
* Set the tags to delete.
|
|
294
697
|
*
|
|
295
|
-
* @param tags Tag names (without refs/tags/ prefix
|
|
698
|
+
* @param tags Tag names (without refs/tags/ prefix: git deletes `refs/tags/<name>` for
|
|
699
|
+
* every name, so `refs/tags/x` names `refs/tags/refs/tags/x`)
|
|
296
700
|
*/
|
|
297
701
|
setTags(...tags: string[]): this {
|
|
298
702
|
this.checkCallable();
|
|
@@ -300,75 +704,483 @@ export class DeleteTagCommand extends GitCommand<string[]> {
|
|
|
300
704
|
return this;
|
|
301
705
|
}
|
|
302
706
|
|
|
707
|
+
/**
|
|
708
|
+
* The git version whose messages to follow (default: the hook runner's, else 2.56): a tag
|
|
709
|
+
* named twice makes 2.43 print a second `error: could not delete references: ` line.
|
|
710
|
+
*/
|
|
711
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
712
|
+
this.checkCallable();
|
|
713
|
+
this.compatibility = version;
|
|
714
|
+
return this;
|
|
715
|
+
}
|
|
716
|
+
|
|
303
717
|
/**
|
|
304
718
|
* Execute the tag deletion.
|
|
305
719
|
*
|
|
306
720
|
* @returns List of deleted tag names (full ref names)
|
|
307
|
-
* @throws RefNotFoundError if tag doesn't exist
|
|
721
|
+
* @throws RefNotFoundError if tag doesn't exist (the others are still deleted)
|
|
308
722
|
*/
|
|
309
723
|
async call(): Promise<string[]> {
|
|
724
|
+
const result = await this.run();
|
|
725
|
+
if (result.refusals.length > 0) throw GitApiError.ofRefusals(result.refusals);
|
|
726
|
+
if (result.failure) throw result.failure;
|
|
727
|
+
return result.deleted;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* `git tag -d <name>...` with git's output: `Deleted tag '<name>' (was <abbrev>)` per tag
|
|
732
|
+
* deleted, `error: tag '<name>' not found.` per missing one (the others still deleted) and
|
|
733
|
+
* exit status 1 after any error; a tag named twice deletes nothing (git's one transaction
|
|
734
|
+
* refuses `multiple updates for ref`).
|
|
735
|
+
*/
|
|
736
|
+
async callText(): Promise<TagDeleteResult> {
|
|
737
|
+
const result = await this.run();
|
|
738
|
+
return {
|
|
739
|
+
deleted: result.deleted,
|
|
740
|
+
output: result.output,
|
|
741
|
+
errors: result.errors,
|
|
742
|
+
exitCode: result.errors.length > 0 ? 1 : 0,
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** git's delete_tags. */
|
|
747
|
+
private async run(): Promise<{
|
|
748
|
+
deleted: string[];
|
|
749
|
+
output: string;
|
|
750
|
+
errors: string[];
|
|
751
|
+
refusals: { error: GitApiError; text: string }[];
|
|
752
|
+
failure?: GitApiError;
|
|
753
|
+
}> {
|
|
310
754
|
this.checkCallable();
|
|
311
755
|
this.setCallable(false);
|
|
756
|
+
const compatibility = this.compatibility ?? this.hooks.compatibility;
|
|
312
757
|
|
|
313
|
-
//
|
|
314
|
-
//
|
|
315
|
-
const
|
|
758
|
+
// for_each_tag_name: each name read as refs/tags/<name> (each missing one reported,
|
|
759
|
+
// the others collected in order), then all of them deleted with one refs_delete_refs
|
|
760
|
+
const collected: { name: string; refName: string; objectId: ObjectId }[] = [];
|
|
316
761
|
const refusals: { error: GitApiError; text: string }[] = [];
|
|
762
|
+
const errors: string[] = [];
|
|
317
763
|
for (const name of this.tags) {
|
|
318
|
-
const refName =
|
|
319
|
-
|
|
320
|
-
|
|
764
|
+
const refName = `refs/tags/${name}`;
|
|
765
|
+
const ref = await this.refsStore.resolve(refName).catch(() => undefined);
|
|
766
|
+
if (!ref || !("objectId" in ref) || !ref.objectId) {
|
|
767
|
+
const text = `error: tag '${name}' not found.`;
|
|
321
768
|
refusals.push({
|
|
322
769
|
error: new RefNotFoundError(refName, `Tag '${name}' not found`).withExitCode(1),
|
|
323
|
-
text
|
|
770
|
+
text,
|
|
324
771
|
});
|
|
772
|
+
errors.push(text);
|
|
325
773
|
continue;
|
|
326
774
|
}
|
|
327
|
-
|
|
775
|
+
collected.push({ name, refName, objectId: ref.objectId });
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const names = collected.map((c) => c.refName);
|
|
779
|
+
const duplicate = [...names].sort().find((n, i, sorted) => i > 0 && sorted[i - 1] === n);
|
|
780
|
+
let failure: GitApiError | undefined;
|
|
781
|
+
let removed: string[] = [];
|
|
782
|
+
if (duplicate !== undefined) {
|
|
783
|
+
// ref_update_reject_duplicates: the transaction refused whole
|
|
784
|
+
const lines = [
|
|
785
|
+
`error: could not delete references: multiple updates for ref '${duplicate}' not allowed`,
|
|
786
|
+
];
|
|
787
|
+
// 2.43's files_delete_refs reports the packed store's failure, then its own
|
|
788
|
+
if (compatibility === "2.43") lines.push("error: could not delete references: ");
|
|
789
|
+
errors.push(...lines);
|
|
790
|
+
failure = new GitApiError(lines.join("\n"), { exitCode: 1 });
|
|
791
|
+
} else if (names.length > 0) {
|
|
792
|
+
const outcome = await this.removeRefsAsGit(names, undefined, compatibility === "2.43");
|
|
793
|
+
removed = outcome.removed;
|
|
794
|
+
if (outcome.error !== undefined) {
|
|
795
|
+
// delete_tags reports the failure and goes on to print what was deleted (exit 1)
|
|
796
|
+
const failed = names.filter((n) => !removed.includes(n));
|
|
797
|
+
const lines = await this.deleteFailureLines(outcome.error, names, failed, compatibility);
|
|
798
|
+
errors.push(...lines);
|
|
799
|
+
failure = new GitApiError(lines.join("\n"), { exitCode: 1, cause: outcome.error });
|
|
800
|
+
}
|
|
328
801
|
}
|
|
329
802
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
803
|
+
let output = "";
|
|
804
|
+
for (const c of collected) {
|
|
805
|
+
if (!removed.includes(c.refName)) continue;
|
|
806
|
+
output += `Deleted tag '${c.name}' (was ${await this.abbreviateObjectId(c.objectId)})\n`;
|
|
807
|
+
}
|
|
808
|
+
return {
|
|
809
|
+
deleted: removed,
|
|
810
|
+
output,
|
|
811
|
+
errors,
|
|
812
|
+
refusals,
|
|
813
|
+
...(failure ? { failure } : {}),
|
|
814
|
+
};
|
|
335
815
|
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* git's lines for a failed refs_delete_refs: 2.5x's one transaction (`could not delete
|
|
819
|
+
* references: <why>`, `reference <ref>: <why>` for one ref; the files backend's lock
|
|
820
|
+
* message names the lock file, reftable's says `cannot lock references`), or 2.43's
|
|
821
|
+
* files_delete_refs, which deletes each ref on its own (`cannot lock ref` with lockfile.c's
|
|
822
|
+
* longer advice, then `could not remove reference <ref>`, per ref it could not delete).
|
|
823
|
+
*/
|
|
824
|
+
private async deleteFailureLines(
|
|
825
|
+
error: unknown,
|
|
826
|
+
names: string[],
|
|
827
|
+
failed: string[],
|
|
828
|
+
compatibility: "2.43" | "2.56",
|
|
829
|
+
): Promise<string[]> {
|
|
830
|
+
const rejected = (error as { rejected?: { name: string; reason: string }[] }).rejected;
|
|
831
|
+
const locked = rejected?.find((r) => r.reason === "locked")?.name;
|
|
832
|
+
const reftable =
|
|
833
|
+
RemoteConfigStore.from(this.workingCopy).value("extensions.refStorage")?.toLowerCase() ===
|
|
834
|
+
"reftable";
|
|
835
|
+
const gitDir = (await this.hooks.hostGitDir({ real: false }).catch(() => undefined))?.replace(
|
|
836
|
+
/\/+$/,
|
|
837
|
+
"",
|
|
838
|
+
);
|
|
839
|
+
const lockText = (ref: string, legacy: boolean) =>
|
|
840
|
+
[
|
|
841
|
+
`cannot lock ref '${ref}': Unable to create '${gitDir ?? ".git"}/${ref}.lock': File exists.`,
|
|
842
|
+
"",
|
|
843
|
+
...(legacy
|
|
844
|
+
? [
|
|
845
|
+
"Another git process seems to be running in this repository, e.g.",
|
|
846
|
+
"an editor opened by 'git commit'. Please make sure all processes",
|
|
847
|
+
"are terminated then try again. If it still fails, a git process",
|
|
848
|
+
"may have crashed in this repository earlier:",
|
|
849
|
+
"remove the file manually to continue.",
|
|
850
|
+
]
|
|
851
|
+
: [
|
|
852
|
+
"Another git process seems to be running in this repository, or the lock file may be stale",
|
|
853
|
+
]),
|
|
854
|
+
].join("\n");
|
|
855
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
856
|
+
if (compatibility === "2.43" && !reftable) {
|
|
857
|
+
const lines: string[] = [];
|
|
858
|
+
for (const ref of failed) {
|
|
859
|
+
if (locked !== undefined) lines.push(`error: ${lockText(ref, true)}`);
|
|
860
|
+
lines.push(`error: could not remove reference ${ref}`);
|
|
861
|
+
}
|
|
862
|
+
return lines.length > 0 ? lines : [`error: ${message}`];
|
|
863
|
+
}
|
|
864
|
+
const why =
|
|
865
|
+
locked === undefined
|
|
866
|
+
? message
|
|
867
|
+
: reftable
|
|
868
|
+
? "cannot lock references"
|
|
869
|
+
: lockText(locked, false);
|
|
870
|
+
const what = names.length === 1 ? `reference ${names[0]}` : "references";
|
|
871
|
+
return [`error: could not delete ${what}: ${why}`];
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/** What `git tag -d` printed ({@link DeleteTagCommand.callText}). */
|
|
876
|
+
export interface TagDeleteResult {
|
|
877
|
+
/** The refs deleted (full names) */
|
|
878
|
+
deleted: string[];
|
|
879
|
+
/** git's stdout: a `Deleted tag '<name>' (was <abbrev>)` line per deleted tag */
|
|
880
|
+
output: string;
|
|
881
|
+
/** git's stderr lines (`error: tag 'x' not found.`, ...) */
|
|
882
|
+
errors: string[];
|
|
883
|
+
/** git's exit status: 1 after any error, else 0 */
|
|
884
|
+
exitCode: number;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/** What `git tag --list` printed ({@link ListTagCommand.callText}). */
|
|
888
|
+
export interface TagListResult {
|
|
889
|
+
/** git's stdout: each tag's line and its newline (bytes outside UTF-8 as `decodeGitPath` keeps them) */
|
|
890
|
+
output: string;
|
|
891
|
+
/** Each shown tag's line, in order (an empty one left out with `--omit-empty`) */
|
|
892
|
+
lines: string[];
|
|
893
|
+
/** The tags shown, in order */
|
|
894
|
+
tags: { refname: string; objectId: ObjectId }[];
|
|
895
|
+
/** git's warnings on stderr */
|
|
896
|
+
warnings: string[];
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/** What `git tag --list` printed ({@link ListTagCommand.callText}). */
|
|
900
|
+
export interface TagListResult {
|
|
901
|
+
/** git's stdout: each tag's line and its newline (bytes outside UTF-8 as `decodeGitPath` keeps them) */
|
|
902
|
+
output: string;
|
|
903
|
+
/** Each shown tag's line, in order (an empty one left out with `--omit-empty`) */
|
|
904
|
+
lines: string[];
|
|
905
|
+
/** The tags shown, in order */
|
|
906
|
+
tags: { refname: string; objectId: ObjectId }[];
|
|
907
|
+
/** git's warnings on stderr */
|
|
908
|
+
warnings: string[];
|
|
336
909
|
}
|
|
337
910
|
|
|
338
911
|
/**
|
|
339
912
|
* List tags.
|
|
340
913
|
*
|
|
341
|
-
* Equivalent to `git tag -
|
|
914
|
+
* Equivalent to `git tag --list [-n[<num>]] [--contains <commit>] [--no-contains <commit>]
|
|
915
|
+
* [--points-at <object>] [--merged <commit>] [--no-merged <commit>] [--sort=<key>]
|
|
916
|
+
* [--format=<format>] [--omit-empty] [--[no-]color] [-i] [<pattern>...]`, on git's ref
|
|
917
|
+
* filter: {@link call} gives the refs the filters keep, in name order; {@link callText}
|
|
918
|
+
* gives git's output (`tag.sort` and `--sort` keys, `versionsort.suffix`, `-n<num>`'s
|
|
919
|
+
* annotations as builtin/tag.c's `list_tags` formats them).
|
|
342
920
|
*
|
|
343
921
|
* @example
|
|
344
922
|
* ```typescript
|
|
345
923
|
* // List all tags
|
|
346
924
|
* const tags = await git.tagList().call();
|
|
925
|
+
*
|
|
926
|
+
* // git tag -n2 --sort=-version:refname 'v*'
|
|
927
|
+
* const { output } = await git
|
|
928
|
+
* .tagList()
|
|
929
|
+
* .setLines(2)
|
|
930
|
+
* .setSort("-version:refname")
|
|
931
|
+
* .setPatterns("v*")
|
|
932
|
+
* .callText();
|
|
347
933
|
* ```
|
|
348
934
|
*/
|
|
349
|
-
export class ListTagCommand extends
|
|
935
|
+
export class ListTagCommand extends RefListingCommand<Ref[]> {
|
|
936
|
+
private patterns: string[] = [];
|
|
937
|
+
private lines?: number;
|
|
938
|
+
private format?: string;
|
|
939
|
+
/** git starts its sort list with `tag.sort` (else `refname`); `--no-sort` clears it */
|
|
940
|
+
private configSort = true;
|
|
941
|
+
private sortKeys: string[] = [];
|
|
942
|
+
private ignoreCase = false;
|
|
943
|
+
private omitEmpty = false;
|
|
944
|
+
private color?: boolean;
|
|
945
|
+
private pointsAt: string[] = [];
|
|
946
|
+
private contains: string[] = [];
|
|
947
|
+
private noContains: string[] = [];
|
|
948
|
+
private merged: string[] = [];
|
|
949
|
+
private noMerged: string[] = [];
|
|
950
|
+
private compatibility: "2.43" | "2.56" = "2.56";
|
|
951
|
+
|
|
952
|
+
/** `<pattern>...`: tags whose name (after `refs/tags/`) matches one of these globs. */
|
|
953
|
+
setPatterns(...patterns: string[]): this {
|
|
954
|
+
this.checkCallable();
|
|
955
|
+
this.patterns = patterns;
|
|
956
|
+
return this;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* `-n<num>` (`-n` alone is 1): each tag followed by `num` lines of its annotation (a
|
|
961
|
+
* lightweight tag's commit message, a signed tag's message without the signature, nothing
|
|
962
|
+
* for a tree or blob), as `%(align:15)%(refname:lstrip=2)%(end) %(contents:lines=<num>)`;
|
|
963
|
+
* 0 lists the names alone. Ignored with {@link setFormat}.
|
|
964
|
+
*/
|
|
965
|
+
setLines(lines = 1): this {
|
|
966
|
+
this.checkCallable();
|
|
967
|
+
this.lines = lines;
|
|
968
|
+
return this;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/** `--format=<format>`: each tag through git's ref format language. */
|
|
972
|
+
setFormat(format: string): this {
|
|
973
|
+
this.checkCallable();
|
|
974
|
+
this.format = format;
|
|
975
|
+
return this;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* `--sort=<key>` for each key, in command-line order (the last is the primary key), after
|
|
980
|
+
* the `tag.sort` keys; `version:refname` (`v:`) compares as versions (`versionsort.suffix`).
|
|
981
|
+
*/
|
|
982
|
+
setSort(...keys: string[]): this {
|
|
983
|
+
this.checkCallable();
|
|
984
|
+
this.sortKeys = keys;
|
|
985
|
+
return this;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** `--no-sort`: the `tag.sort` keys, the default `refname` and the keys given so far dropped. */
|
|
989
|
+
setNoSort(): this {
|
|
990
|
+
this.checkCallable();
|
|
991
|
+
this.configSort = false;
|
|
992
|
+
this.sortKeys = [];
|
|
993
|
+
return this;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/** `-i`: patterns and sorting without case. */
|
|
997
|
+
setIgnoreCase(ignore: boolean): this {
|
|
998
|
+
this.checkCallable();
|
|
999
|
+
this.ignoreCase = ignore;
|
|
1000
|
+
return this;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/** `--omit-empty`: no line for a tag whose format expands to nothing. */
|
|
1004
|
+
setOmitEmpty(omit: boolean): this {
|
|
1005
|
+
this.checkCallable();
|
|
1006
|
+
this.omitEmpty = omit;
|
|
1007
|
+
return this;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/** `--color` (true) or `--no-color` (false); default: colors only under `color.ui=always`. */
|
|
1011
|
+
setColor(color: boolean): this {
|
|
1012
|
+
this.checkCallable();
|
|
1013
|
+
this.color = color;
|
|
1014
|
+
return this;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/** `--points-at[=<object>]` (HEAD without one): tags naming one of these, directly or through tags. */
|
|
1018
|
+
setPointsAt(...objects: string[]): this {
|
|
1019
|
+
this.checkCallable();
|
|
1020
|
+
this.pointsAt = objects.length ? objects.map(canonicalName) : ["HEAD"];
|
|
1021
|
+
return this;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/** `--contains[=<commit>]` (HEAD without one): tags whose commit reaches one of these. */
|
|
1025
|
+
setContains(...commits: string[]): this {
|
|
1026
|
+
this.checkCallable();
|
|
1027
|
+
this.contains = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
1028
|
+
return this;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/** `--no-contains[=<commit>]` (HEAD without one): tags whose commit reaches none of these. */
|
|
1032
|
+
setNoContains(...commits: string[]): this {
|
|
1033
|
+
this.checkCallable();
|
|
1034
|
+
this.noContains = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
1035
|
+
return this;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/** `--merged[=<commit>]` (HEAD without one): tags whose commit one of these reaches. */
|
|
1039
|
+
setMerged(...commits: string[]): this {
|
|
1040
|
+
this.checkCallable();
|
|
1041
|
+
this.merged = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
1042
|
+
return this;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/** `--no-merged[=<commit>]` (HEAD without one): tags whose commit none of these reaches. */
|
|
1046
|
+
setNoMerged(...commits: string[]): this {
|
|
1047
|
+
this.checkCallable();
|
|
1048
|
+
this.noMerged = commits.length ? commits.map(canonicalName) : ["HEAD"];
|
|
1049
|
+
return this;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* The git version whose `--format` output to follow where versions differ (default 2.56;
|
|
1054
|
+
* see `ForEachRefCommand.setCompatibility`).
|
|
1055
|
+
*/
|
|
1056
|
+
setCompatibility(version: "2.43" | "2.56"): this {
|
|
1057
|
+
this.checkCallable();
|
|
1058
|
+
this.compatibility = version;
|
|
1059
|
+
return this;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
private async filterOptions(): Promise<RefFilterOptions> {
|
|
1063
|
+
const resolved = await this.resolveFilterArgs({
|
|
1064
|
+
pointsAt: this.pointsAt,
|
|
1065
|
+
contains: this.contains,
|
|
1066
|
+
noContains: this.noContains,
|
|
1067
|
+
merged: this.merged,
|
|
1068
|
+
noMerged: this.noMerged,
|
|
1069
|
+
});
|
|
1070
|
+
return {
|
|
1071
|
+
kind: RefKind.TAGS,
|
|
1072
|
+
patterns: this.patterns,
|
|
1073
|
+
ignoreCase: this.ignoreCase,
|
|
1074
|
+
...resolved,
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
|
|
350
1078
|
/**
|
|
351
1079
|
* Execute the tag listing.
|
|
352
1080
|
*
|
|
353
|
-
* @returns
|
|
1081
|
+
* @returns The tag refs the filters keep, in name order
|
|
1082
|
+
* @throws RefFilterError where git refuses an option (a name that is no commit)
|
|
354
1083
|
*/
|
|
355
1084
|
async call(): Promise<Ref[]> {
|
|
356
1085
|
this.checkCallable();
|
|
357
1086
|
this.setCallable(false);
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
1087
|
+
const { items } = await filterRefs(this.filterSource(), await this.filterOptions());
|
|
1088
|
+
// one listing of the tags, not a lookup per kept tag (a packed ref's lookup reads
|
|
1089
|
+
// packed-refs again: quadratic over thousands of tags)
|
|
1090
|
+
const listed = new Map<string, Ref>();
|
|
361
1091
|
for await (const ref of this.refsStore.list("refs/tags/")) {
|
|
362
|
-
if ("objectId" in ref)
|
|
363
|
-
|
|
364
|
-
|
|
1092
|
+
if ("objectId" in ref) listed.set(ref.name, ref);
|
|
1093
|
+
}
|
|
1094
|
+
const tags: Ref[] = [];
|
|
1095
|
+
for (const item of items) {
|
|
1096
|
+
if (item.flags.symref) continue;
|
|
1097
|
+
const ref = listed.get(item.refname);
|
|
1098
|
+
if (ref) tags.push(ref);
|
|
365
1099
|
}
|
|
366
|
-
|
|
367
|
-
// Sort by name
|
|
368
1100
|
tags.sort((a, b) => compareRefNames(a.name, b.name));
|
|
369
|
-
|
|
370
1101
|
return tags;
|
|
371
1102
|
}
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* `git tag --list`'s output.
|
|
1106
|
+
*
|
|
1107
|
+
* @throws RefFilterError where git refuses an option or dies (bad format, bad sort key,
|
|
1108
|
+
* a name that is no commit)
|
|
1109
|
+
*/
|
|
1110
|
+
async callText(): Promise<TagListResult> {
|
|
1111
|
+
this.checkCallable();
|
|
1112
|
+
this.setCallable(false);
|
|
1113
|
+
const config = RemoteConfigStore.from(this.workingCopy);
|
|
1114
|
+
// parse_options resolves --contains & co. in its callbacks, before anything else
|
|
1115
|
+
const filter = await this.filterOptions();
|
|
1116
|
+
// repo_config: tag.sort keys, else "refname"; --sort appends, --no-sort clears
|
|
1117
|
+
const configured = config.values("tag.sort");
|
|
1118
|
+
const sortKeys = this.configSort
|
|
1119
|
+
? [...(configured.length ? configured : ["refname"]), ...this.sortKeys]
|
|
1120
|
+
: [...this.sortKeys];
|
|
1121
|
+
// want_color(GIT_COLOR_UNKNOWN): color.ui, and only `always` colors without a terminal
|
|
1122
|
+
const useColor = this.color ?? config.value("color.ui")?.trim().toLowerCase() === "always";
|
|
1123
|
+
const formatSource = this.formatSource();
|
|
1124
|
+
const compatibility = this.compatibility;
|
|
1125
|
+
const formatOptions = { useColor, compatibility } as const;
|
|
1126
|
+
// ref_sorting_options runs before list_tags verifies the format
|
|
1127
|
+
const sortFormat = new RefFormat("", formatSource, formatOptions);
|
|
1128
|
+
parseRefSorting(sortKeys, sortFormat);
|
|
1129
|
+
// git 2.43 collects `%(ahead-behind)` bases per format: atoms the sort keys parsed first
|
|
1130
|
+
// (into a dummy format) get none
|
|
1131
|
+
const sortedFirst = new Set(
|
|
1132
|
+
compatibility === "2.43" ? sortFormat.atoms.map((a) => a.name) : [],
|
|
1133
|
+
);
|
|
1134
|
+
// list_tags: -n<num> (negative: none) annotates with %(contents:lines=<num>)
|
|
1135
|
+
const lines = this.lines === undefined || this.lines === -1 ? 0 : this.lines;
|
|
1136
|
+
const formatText =
|
|
1137
|
+
this.format ??
|
|
1138
|
+
(lines
|
|
1139
|
+
? `%(align:15)%(refname:lstrip=2)%(end) %(contents:lines=${lines})`
|
|
1140
|
+
: "%(refname:lstrip=2)");
|
|
1141
|
+
let format: RefFormat;
|
|
1142
|
+
try {
|
|
1143
|
+
format = new RefFormat(formatText, formatSource, formatOptions);
|
|
1144
|
+
} catch (e) {
|
|
1145
|
+
// verify_ref_format's error, then tag's death
|
|
1146
|
+
if (e instanceof RefFilterError && e.message.startsWith("error: malformed format string")) {
|
|
1147
|
+
throw new RefFilterError(`${e.message}\nfatal: unable to parse format string`, 128);
|
|
1148
|
+
}
|
|
1149
|
+
throw e;
|
|
1150
|
+
}
|
|
1151
|
+
const sorting: RefSortKey[] = parseRefSorting(sortKeys, format).map((key) =>
|
|
1152
|
+
this.ignoreCase ? { ...key, icase: true } : key,
|
|
1153
|
+
);
|
|
1154
|
+
const source = this.filterSource();
|
|
1155
|
+
const aheadBehindBases: ObjectId[] = [];
|
|
1156
|
+
const isBaseTips: { name: string; commit: ObjectId }[] = [];
|
|
1157
|
+
const baseWarnings: string[] = [];
|
|
1158
|
+
for (const atom of format.atoms) {
|
|
1159
|
+
if (atom.type !== "ahead-behind" && atom.type !== "is-base") continue;
|
|
1160
|
+
if (sortedFirst.has(atom.name)) continue;
|
|
1161
|
+
const name = atom.base as string;
|
|
1162
|
+
const commit = await source.commitByName(name, baseWarnings);
|
|
1163
|
+
if (!commit) throw new RefFilterError(`fatal: failed to find '${name}'`, 128);
|
|
1164
|
+
if (atom.type === "ahead-behind") aheadBehindBases.push(commit);
|
|
1165
|
+
else isBaseTips.push({ name, commit });
|
|
1166
|
+
}
|
|
1167
|
+
const result = await filterAndFormatRefs(source, filter, sorting, format, {
|
|
1168
|
+
omitEmpty: this.omitEmpty,
|
|
1169
|
+
aheadBehindBases,
|
|
1170
|
+
isBaseTips,
|
|
1171
|
+
});
|
|
1172
|
+
return {
|
|
1173
|
+
output: result.output,
|
|
1174
|
+
lines: result.lines,
|
|
1175
|
+
tags: result.items.map((i) => ({ refname: i.refname, objectId: i.objectId })),
|
|
1176
|
+
warnings: [...baseWarnings, ...result.warnings],
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/** A full object id canonicalised (lowercase), any other name as given. */
|
|
1182
|
+
function canonicalName(name: string): string {
|
|
1183
|
+
return isFullHexObjectId(name) ? canonicalObjectId(name) : name;
|
|
372
1184
|
}
|
|
373
1185
|
|
|
374
1186
|
/**
|