@deepseek-ai/dsh-experimental-client-ui-forge 0.2.3-alpha.2 → 0.2.3-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +10 -10
- package/README.md +37 -19
- package/README.zh.md +37 -19
- package/lib/client.js +22 -17
- package/lib/client.js.map +1 -1
- package/lib/index.js +941 -188
- package/lib/typert.host.js +894 -175
- package/lib/typert.remote-client.d.ts +35 -17
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +751 -146
- package/lib/types/client/ActionToast.d.ts +1 -1
- package/lib/types/client/ActionToast.d.ts.map +1 -1
- package/lib/types/client/ActionToast.js.map +1 -1
- package/lib/types/client/BaseMenu.d.ts +6 -4
- package/lib/types/client/BaseMenu.d.ts.map +1 -1
- package/lib/types/client/BaseMenu.js.map +1 -1
- package/lib/types/client/BranchPicker.d.ts +84 -0
- package/lib/types/client/BranchPicker.d.ts.map +1 -0
- package/lib/types/client/BranchPicker.js.map +1 -0
- package/lib/types/client/ChangeRequestCard.d.ts +31 -13
- package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestCard.js.map +1 -1
- package/lib/types/client/ChangeRequestOverview.d.ts +28 -6
- package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestOverview.js.map +1 -1
- package/lib/types/client/ChangeRequestsSection.d.ts +5 -3
- package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestsSection.js.map +1 -1
- package/lib/types/client/ChangeStatus.d.ts +41 -0
- package/lib/types/client/ChangeStatus.d.ts.map +1 -0
- package/lib/types/client/ChangeStatus.js.map +1 -0
- package/lib/types/client/ChangedFiles.d.ts +1 -1
- package/lib/types/client/ChangedFiles.d.ts.map +1 -1
- package/lib/types/client/ChangedFiles.js.map +1 -1
- package/lib/types/client/ChangesLoading.d.ts +1 -1
- package/lib/types/client/ChangesLoading.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.d.ts +35 -12
- package/lib/types/client/ChangesTab.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.js.map +1 -1
- package/lib/types/client/ChangesTabTitle.d.ts +1 -1
- package/lib/types/client/ChangesTabTitle.d.ts.map +1 -1
- package/lib/types/client/ChangesTabTitle.js.map +1 -1
- package/lib/types/client/CommitMenu.d.ts +11 -8
- package/lib/types/client/CommitMenu.d.ts.map +1 -1
- package/lib/types/client/CommitMenu.js.map +1 -1
- package/lib/types/client/CopyCommandButton.d.ts +19 -0
- package/lib/types/client/CopyCommandButton.d.ts.map +1 -0
- package/lib/types/client/CopyCommandButton.js.map +1 -0
- package/lib/types/client/DiffFile.d.ts +36 -5
- package/lib/types/client/DiffFile.d.ts.map +1 -1
- package/lib/types/client/DiffFile.js.map +1 -1
- package/lib/types/client/EnvironmentRows.d.ts +6 -6
- package/lib/types/client/EnvironmentRows.d.ts.map +1 -1
- package/lib/types/client/EnvironmentRows.js.map +1 -1
- package/lib/types/client/FileLabel.d.ts +5 -5
- package/lib/types/client/FileLabel.d.ts.map +1 -1
- package/lib/types/client/FileLabel.js.map +1 -1
- package/lib/types/client/HeadMenu.d.ts +35 -0
- package/lib/types/client/HeadMenu.d.ts.map +1 -0
- package/lib/types/client/HeadMenu.js.map +1 -0
- package/lib/types/client/HostSettings.d.ts +33 -0
- package/lib/types/client/HostSettings.d.ts.map +1 -0
- package/lib/types/client/HostSettings.js.map +1 -0
- package/lib/types/client/LensFilter.d.ts +2 -2
- package/lib/types/client/LensFilter.d.ts.map +1 -1
- package/lib/types/client/LensFilter.js.map +1 -1
- package/lib/types/client/ReasonButton.js.map +1 -1
- package/lib/types/client/RefreshGlyph.js.map +1 -1
- package/lib/types/client/ReviewComposer.d.ts +1 -1
- package/lib/types/client/ReviewComposer.d.ts.map +1 -1
- package/lib/types/client/ReviewComposer.js.map +1 -1
- package/lib/types/client/ReviewControls.d.ts +1 -1
- package/lib/types/client/ReviewControls.d.ts.map +1 -1
- package/lib/types/client/ReviewControls.js.map +1 -1
- package/lib/types/client/ReviewThread.d.ts +1 -1
- package/lib/types/client/ReviewThread.d.ts.map +1 -1
- package/lib/types/client/ReviewThread.js.map +1 -1
- package/lib/types/client/ReviewThreads.d.ts +21 -4
- package/lib/types/client/ReviewThreads.d.ts.map +1 -1
- package/lib/types/client/ReviewThreads.js.map +1 -1
- package/lib/types/client/SessionHoverForge.d.ts +1 -1
- package/lib/types/client/SessionHoverForge.d.ts.map +1 -1
- package/lib/types/client/SessionHoverForge.js.map +1 -1
- package/lib/types/client/SessionRowForge.d.ts +1 -1
- package/lib/types/client/SessionRowForge.d.ts.map +1 -1
- package/lib/types/client/SessionRowForge.js.map +1 -1
- package/lib/types/client/SubmitReview.d.ts +1 -1
- package/lib/types/client/SubmitReview.d.ts.map +1 -1
- package/lib/types/client/SubmitReview.js.map +1 -1
- package/lib/types/client/ThreadList.d.ts +3 -1
- package/lib/types/client/ThreadList.d.ts.map +1 -1
- package/lib/types/client/ThreadList.js.map +1 -1
- package/lib/types/client/ViewOptionsMenu.d.ts +1 -1
- package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
- package/lib/types/client/ViewOptionsMenu.js.map +1 -1
- package/lib/types/client/WorktreeNameDialog.d.ts +1 -1
- package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -1
- package/lib/types/client/WorktreeNameDialog.js.map +1 -1
- package/lib/types/client/WorktreeProgress.d.ts +1 -1
- package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
- package/lib/types/client/WorktreeProgress.js.map +1 -1
- package/lib/types/client/WorktreeSettings.d.ts +1 -1
- package/lib/types/client/WorktreeSettings.d.ts.map +1 -1
- package/lib/types/client/WorktreeSettings.js.map +1 -1
- package/lib/types/client/WorktreeToggle.d.ts +1 -1
- package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
- package/lib/types/client/WorktreeToggle.js.map +1 -1
- package/lib/types/client/annotations.d.ts +1 -1
- package/lib/types/client/annotations.d.ts.map +1 -1
- package/lib/types/client/branch-search.d.ts +1 -1
- package/lib/types/client/branch-search.d.ts.map +1 -1
- package/lib/types/client/branch-search.js.map +1 -1
- package/lib/types/client/changes-address.d.ts +1 -1
- package/lib/types/client/changes-address.d.ts.map +1 -1
- package/lib/types/client/changes-service.d.ts +1 -1
- package/lib/types/client/changes-service.d.ts.map +1 -1
- package/lib/types/client/changes-store.d.ts +25 -6
- package/lib/types/client/changes-store.d.ts.map +1 -1
- package/lib/types/client/changes-store.js.map +1 -1
- package/lib/types/client/checkout.d.ts +1 -1
- package/lib/types/client/checkout.d.ts.map +1 -1
- package/lib/types/client/code-selection.d.ts.map +1 -1
- package/lib/types/client/code-selection.js.map +1 -1
- package/lib/types/client/forge-copy.d.ts +8 -1
- package/lib/types/client/forge-copy.d.ts.map +1 -1
- package/lib/types/client/forge-copy.js.map +1 -1
- package/lib/types/client/format.d.ts +1 -1
- package/lib/types/client/format.d.ts.map +1 -1
- package/lib/types/client/format.js.map +1 -1
- package/lib/types/client/glyphs.d.ts +36 -1
- package/lib/types/client/glyphs.d.ts.map +1 -1
- package/lib/types/client/glyphs.js.map +1 -1
- package/lib/types/client/highlight-context.d.ts +1 -1
- package/lib/types/client/highlight-context.d.ts.map +1 -1
- package/lib/types/client/host-settings-form.d.ts +69 -0
- package/lib/types/client/host-settings-form.d.ts.map +1 -0
- package/lib/types/client/host-settings-form.js.map +1 -0
- package/lib/types/client/host-sign-in.d.ts +31 -0
- package/lib/types/client/host-sign-in.d.ts.map +1 -0
- package/lib/types/client/host-sign-in.js.map +1 -0
- package/lib/types/client/index.d.ts +1 -2
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/local-writes.d.ts +47 -0
- package/lib/types/client/local-writes.d.ts.map +1 -0
- package/lib/types/client/local-writes.js.map +1 -0
- package/lib/types/client/locales.d.ts +111 -13
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js.map +1 -1
- package/lib/types/client/minute-clock.d.ts +7 -0
- package/lib/types/client/minute-clock.d.ts.map +1 -0
- package/lib/types/client/minute-clock.js.map +1 -0
- package/lib/types/client/mount.d.ts +15 -1
- package/lib/types/client/mount.d.ts.map +1 -1
- package/lib/types/client/mount.js.map +1 -1
- package/lib/types/client/review-page/ReviewActivity.d.ts +44 -0
- package/lib/types/client/review-page/ReviewActivity.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewActivity.js.map +1 -0
- package/lib/types/client/review-page/ReviewChat.d.ts +1 -1
- package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewChat.js.map +1 -1
- package/lib/types/client/review-page/ReviewDetail.d.ts +26 -9
- package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewDetail.js.map +1 -1
- package/lib/types/client/review-page/ReviewLabels.d.ts +1 -1
- package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewLabels.js.map +1 -1
- package/lib/types/client/review-page/ReviewList.d.ts +10 -8
- package/lib/types/client/review-page/ReviewList.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewList.js.map +1 -1
- package/lib/types/client/review-page/ReviewNav.d.ts +1 -1
- package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewPage.d.ts +17 -14
- package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewPage.js.map +1 -1
- package/lib/types/client/review-page/ReviewSkeleton.d.ts +26 -0
- package/lib/types/client/review-page/ReviewSkeleton.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewSkeleton.js.map +1 -0
- package/lib/types/client/review-page/ReviewStatus.d.ts +19 -13
- package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewStatus.js.map +1 -1
- package/lib/types/client/review-page/review-activity.d.ts +37 -0
- package/lib/types/client/review-page/review-activity.d.ts.map +1 -0
- package/lib/types/client/review-page/review-activity.js.map +1 -0
- package/lib/types/client/review-page/review-lists.d.ts +48 -13
- package/lib/types/client/review-page/review-lists.d.ts.map +1 -1
- package/lib/types/client/review-page/review-lists.js.map +1 -1
- package/lib/types/client/review-page/review-mount.d.ts +3 -1
- package/lib/types/client/review-page/review-mount.d.ts.map +1 -1
- package/lib/types/client/review-page/review-mount.js.map +1 -1
- package/lib/types/client/review-page/review-store.d.ts +19 -9
- package/lib/types/client/review-page/review-store.d.ts.map +1 -1
- package/lib/types/client/review-page/review-store.js.map +1 -1
- package/lib/types/client/review-queue.d.ts +1 -1
- package/lib/types/client/review-queue.d.ts.map +1 -1
- package/lib/types/client/review-queue.js.map +1 -1
- package/lib/types/client/review-threads.d.ts +15 -8
- package/lib/types/client/review-threads.d.ts.map +1 -1
- package/lib/types/client/review-threads.js.map +1 -1
- package/lib/types/client/review.d.ts +12 -1
- package/lib/types/client/review.d.ts.map +1 -1
- package/lib/types/client/review.js.map +1 -1
- package/lib/types/client/row-form-labels.d.ts +12 -0
- package/lib/types/client/row-form-labels.d.ts.map +1 -0
- package/lib/types/client/row-form-labels.js.map +1 -0
- package/lib/types/client/session-list.d.ts +1 -1
- package/lib/types/client/session-list.d.ts.map +1 -1
- package/lib/types/client/slots.d.ts +1 -1
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/client/source.d.ts +1 -1
- package/lib/types/client/source.d.ts.map +1 -1
- package/lib/types/client/status.d.ts +7 -6
- package/lib/types/client/status.d.ts.map +1 -1
- package/lib/types/client/status.js.map +1 -1
- package/lib/types/client/thread-state.d.ts +2 -2
- package/lib/types/client/thread-state.d.ts.map +1 -1
- package/lib/types/client/thread-state.js.map +1 -1
- package/lib/types/client/toolbar-fold.d.ts +16 -6
- package/lib/types/client/toolbar-fold.d.ts.map +1 -1
- package/lib/types/client/toolbar-fold.js.map +1 -1
- package/lib/types/client/worktree-settings-form.d.ts +1 -1
- package/lib/types/client/worktree-settings-form.d.ts.map +1 -1
- package/lib/types/client/worktree-settings-form.js.map +1 -1
- package/lib/types/diff.d.ts.map +1 -1
- package/lib/types/diff.js.map +1 -1
- package/lib/types/git.d.ts +22 -0
- package/lib/types/git.d.ts.map +1 -1
- package/lib/types/git.js.map +1 -1
- package/lib/types/index.d.ts +137 -36
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/local-diff.d.ts +81 -23
- package/lib/types/local-diff.d.ts.map +1 -1
- package/lib/types/local-diff.js.map +1 -1
- package/lib/types/local-write.d.ts +44 -0
- package/lib/types/local-write.d.ts.map +1 -0
- package/lib/types/local-write.js.map +1 -0
- package/lib/types/panel.js.map +1 -1
- package/lib/types/parse.d.ts +12 -3
- package/lib/types/parse.d.ts.map +1 -1
- package/lib/types/parse.js.map +1 -1
- package/lib/types/restore.d.ts +12 -0
- package/lib/types/restore.d.ts.map +1 -0
- package/lib/types/restore.js.map +1 -0
- package/lib/types/types.d.ts +128 -13
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/viewer-lists.d.ts +22 -13
- package/lib/types/viewer-lists.d.ts.map +1 -1
- package/lib/types/viewer-lists.js.map +1 -1
- package/lib/types/worktree.js.map +1 -1
- package/package.json +62 -58
- package/src/client/ActionToast.tsx +2 -2
- package/src/client/BaseMenu.module.css +15 -3
- package/src/client/BaseMenu.tsx +25 -88
- package/src/client/BranchPicker.tsx +170 -0
- package/src/client/ChangeRequestCard.tsx +194 -70
- package/src/client/ChangeRequestOverview.tsx +194 -82
- package/src/client/ChangeRequestsSection.tsx +45 -14
- package/src/client/ChangeStatus.module.css +70 -0
- package/src/client/ChangeStatus.tsx +104 -0
- package/src/client/ChangedFiles.tsx +22 -9
- package/src/client/ChangesLoading.tsx +1 -1
- package/src/client/ChangesTab.module.css +181 -33
- package/src/client/ChangesTab.tsx +499 -183
- package/src/client/ChangesTabTitle.tsx +2 -2
- package/src/client/CommitMenu.tsx +83 -42
- package/src/client/CopyCommandButton.tsx +25 -0
- package/src/client/DiffFile.tsx +147 -29
- package/src/client/EnvironmentRows.tsx +34 -28
- package/src/client/FileLabel.module.css +16 -18
- package/src/client/FileLabel.tsx +16 -32
- package/src/client/Forge.module.css +26 -6
- package/src/client/HeadMenu.tsx +69 -0
- package/src/client/HostSettings.module.css +194 -0
- package/src/client/HostSettings.tsx +194 -0
- package/src/client/LensFilter.tsx +13 -11
- package/src/client/ReasonButton.tsx +1 -1
- package/src/client/RefreshGlyph.tsx +1 -1
- package/src/client/ReviewComposer.tsx +31 -19
- package/src/client/ReviewControls.tsx +18 -9
- package/src/client/ReviewThread.tsx +65 -23
- package/src/client/ReviewThreads.tsx +133 -38
- package/src/client/SessionHoverForge.tsx +2 -2
- package/src/client/SessionRowForge.tsx +2 -2
- package/src/client/SubmitReview.tsx +7 -5
- package/src/client/ThreadList.module.css +4 -3
- package/src/client/ThreadList.tsx +11 -8
- package/src/client/ViewOptionsMenu.tsx +12 -10
- package/src/client/WorktreeNameDialog.tsx +17 -13
- package/src/client/WorktreeProgress.tsx +13 -11
- package/src/client/WorktreeSettings.tsx +8 -14
- package/src/client/WorktreeToggle.tsx +67 -37
- package/src/client/annotations.ts +1 -1
- package/src/client/branch-search.tsx +2 -2
- package/src/client/changes-address.ts +1 -1
- package/src/client/changes-service.ts +1 -1
- package/src/client/changes-store.ts +57 -10
- package/src/client/checkout.ts +1 -1
- package/src/client/code-selection.ts +3 -1
- package/src/client/forge-copy.ts +11 -1
- package/src/client/format.ts +2 -2
- package/src/client/glyphs.tsx +72 -5
- package/src/client/highlight-context.ts +1 -1
- package/src/client/host-settings-form.ts +115 -0
- package/src/client/host-sign-in.ts +46 -0
- package/src/client/index.ts +1 -2
- package/src/client/local-writes.ts +129 -0
- package/src/client/locales.ts +881 -97
- package/src/client/minute-clock.ts +19 -0
- package/src/client/mount.ts +121 -57
- package/src/client/review-page/ReviewActivity.tsx +406 -0
- package/src/client/review-page/ReviewChat.tsx +48 -19
- package/src/client/review-page/ReviewDetail.tsx +246 -78
- package/src/client/review-page/ReviewLabels.tsx +2 -2
- package/src/client/review-page/ReviewList.tsx +173 -151
- package/src/client/review-page/ReviewNav.tsx +1 -1
- package/src/client/review-page/ReviewPage.module.css +571 -23
- package/src/client/review-page/ReviewPage.tsx +84 -53
- package/src/client/review-page/ReviewSkeleton.tsx +108 -0
- package/src/client/review-page/ReviewStatus.tsx +74 -44
- package/src/client/review-page/review-activity.ts +64 -0
- package/src/client/review-page/review-lists.ts +85 -22
- package/src/client/review-page/review-mount.ts +24 -7
- package/src/client/review-page/review-store.ts +24 -7
- package/src/client/review-queue.ts +7 -3
- package/src/client/review-threads.ts +24 -12
- package/src/client/review.ts +20 -2
- package/src/client/row-form-labels.ts +17 -0
- package/src/client/session-list.ts +1 -1
- package/src/client/slots.ts +1 -1
- package/src/client/source.ts +1 -1
- package/src/client/status.ts +20 -9
- package/src/client/thread-state.ts +8 -7
- package/src/client/toolbar-fold.ts +59 -14
- package/src/client/worktree-settings-form.ts +1 -1
- package/src/diff.ts +8 -5
- package/src/git.ts +31 -1
- package/src/index.ts +319 -70
- package/src/local-diff.ts +151 -48
- package/src/local-write.ts +159 -0
- package/src/panel.ts +1 -1
- package/src/parse.ts +26 -4
- package/src/restore.ts +15 -0
- package/src/types.ts +121 -17
- package/src/viewer-lists.ts +124 -48
- package/src/worktree.ts +1 -1
- package/lib/types/client/AttentionIndicator.d.ts +0 -22
- package/lib/types/client/AttentionIndicator.d.ts.map +0 -1
- package/lib/types/client/AttentionIndicator.js.map +0 -1
- package/src/client/AttentionIndicator.tsx +0 -37
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Service } from "@deepseek-ai/cordis";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { changeRequestKey } from "@deepseek-ai/dsh-experimental-forge";
|
|
4
|
-
import { appendPluginRecord, pluginRecordOf } from "@deepseek-ai/dsh-session";
|
|
4
|
+
import { appendPluginRecord, pluginRecordOf } from "@deepseek-ai/dsh-session-store";
|
|
5
5
|
import { MAX_TIMER_DELAY_MS, deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
6
6
|
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
7
7
|
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
@@ -90,14 +90,14 @@ function parseName(output) {
|
|
|
90
90
|
const BASE_REF_PREFIXES = ["refs/heads/", "refs/remotes/"];
|
|
91
91
|
/**
|
|
92
92
|
* Select the branches the `branch` scope can compare with from `git for-each-ref`
|
|
93
|
-
* output, keeping its order and leaving out symbolic refs and the
|
|
93
|
+
* output, keeping its order and leaving out symbolic refs and the hidden branches.
|
|
94
94
|
* @param output - stdout of `git for-each-ref --format=%(refname)%00%(symref)` over {@link BASE_REF_PREFIXES}.
|
|
95
|
-
* @param
|
|
95
|
+
* @param hidden - full refs the listing leaves out: the branch the scope shows, and the branch the automatic base stands for.
|
|
96
96
|
* @param query - text the names must contain, ignoring case; empty or blank for every branch.
|
|
97
97
|
* @param limit - most branches in each group.
|
|
98
98
|
* @returns remote-tracking and local branches, at most `limit` of each.
|
|
99
99
|
*/
|
|
100
|
-
function parseBaseBranches(output,
|
|
100
|
+
function parseBaseBranches(output, hidden, query, limit) {
|
|
101
101
|
const [heads, remotes] = BASE_REF_PREFIXES;
|
|
102
102
|
const needle = query.trim().toLowerCase();
|
|
103
103
|
const remote = [];
|
|
@@ -108,7 +108,7 @@ function parseBaseBranches(output, current, query, limit) {
|
|
|
108
108
|
const group = ref.startsWith(heads) ? local : ref.startsWith(remotes) ? remote : void 0;
|
|
109
109
|
if (group === void 0 || group.length >= limit) continue;
|
|
110
110
|
const name = ref.slice(group === local ? heads.length : remotes.length);
|
|
111
|
-
if (name.length === 0 ||
|
|
111
|
+
if (name.length === 0 || hidden.includes(ref) || !name.toLowerCase().includes(needle)) continue;
|
|
112
112
|
group.push({
|
|
113
113
|
ref,
|
|
114
114
|
name
|
|
@@ -120,6 +120,26 @@ function parseBaseBranches(output, current, query, limit) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
+
* Read which worktree has each branch checked out from `git worktree list --porcelain` output: one block of lines for
|
|
124
|
+
* each worktree, ended by an empty line. The NUL-separated form of the listing needs Git 2.36, so the lines are read
|
|
125
|
+
* instead; a directory whose name holds a line break is cut at the break, and Git before 2.31 does not mark a worktree
|
|
126
|
+
* whose directory is gone, so a caller confirms the directory before it reads there.
|
|
127
|
+
* @param output - stdout of the listing.
|
|
128
|
+
* @returns the directory of each worktree by the full ref of its branch, without detached, bare, and prunable entries.
|
|
129
|
+
*/
|
|
130
|
+
function parseWorktrees(output) {
|
|
131
|
+
const found = /* @__PURE__ */ new Map();
|
|
132
|
+
for (const entry of output.split("\n\n")) {
|
|
133
|
+
const fields = entry.split("\n");
|
|
134
|
+
const value = (name) => fields.find((field) => field.startsWith(`${name} `))?.slice(name.length + 1);
|
|
135
|
+
const path = value("worktree");
|
|
136
|
+
const branch = value("branch");
|
|
137
|
+
if (path === void 0 || branch === void 0 || fields.some((field) => field === "prunable" || field.startsWith("prunable "))) continue;
|
|
138
|
+
found.set(branch, path);
|
|
139
|
+
}
|
|
140
|
+
return found;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
123
143
|
* Select the branches a new worktree can start from out of `git for-each-ref` output, keeping its order within
|
|
124
144
|
* each group: the checked-out branch, each remote's default branch, the other local branches, and the other
|
|
125
145
|
* remote-tracking branches of each remote. A remote's default branch is the branch its `refs/remotes/<remote>/HEAD`
|
|
@@ -269,7 +289,7 @@ function remoteOrder(upstream, remotes) {
|
|
|
269
289
|
//#endregion
|
|
270
290
|
//#region lib/types/git.js
|
|
271
291
|
/** Git queries in a Session's current directory, using its permissions and execution world. */
|
|
272
|
-
var __addDisposableResource$
|
|
292
|
+
var __addDisposableResource$3 = function(env, value, async) {
|
|
273
293
|
if (value !== null && value !== void 0) {
|
|
274
294
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
275
295
|
var dispose, inner;
|
|
@@ -298,7 +318,7 @@ var __addDisposableResource$2 = function(env, value, async) {
|
|
|
298
318
|
} else if (async) env.stack.push({ async: true });
|
|
299
319
|
return value;
|
|
300
320
|
};
|
|
301
|
-
var __disposeResources$
|
|
321
|
+
var __disposeResources$3 = (function(SuppressedError) {
|
|
302
322
|
return function(env) {
|
|
303
323
|
function fail(e) {
|
|
304
324
|
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
@@ -331,6 +351,20 @@ var __disposeResources$2 = (function(SuppressedError) {
|
|
|
331
351
|
var GitOutputTooLarge = class extends Error {
|
|
332
352
|
name = "GitOutputTooLarge";
|
|
333
353
|
};
|
|
354
|
+
/** Thrown when a Git command ends with an exit code its caller does not allow, or by a signal. */
|
|
355
|
+
var GitFailed = class extends Error {
|
|
356
|
+
diagnostic;
|
|
357
|
+
name = "GitFailed";
|
|
358
|
+
/**
|
|
359
|
+
* @param command - the caller's name of the command.
|
|
360
|
+
* @param outcome - the exit code, or the signal that ended the process.
|
|
361
|
+
* @param diagnostic - first non-blank line Git printed on standard error, or `no diagnostic`.
|
|
362
|
+
*/
|
|
363
|
+
constructor(command, outcome, diagnostic) {
|
|
364
|
+
super(`git ${command} failed (${String(outcome)}): ${diagnostic}`);
|
|
365
|
+
this.diagnostic = diagnostic;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
334
368
|
/**
|
|
335
369
|
* Clear inherited repository, configuration, and replacement-ref selectors;
|
|
336
370
|
* disable prompts, optional index writes, and lazy fetches of missing objects.
|
|
@@ -483,6 +517,23 @@ function gitIn(ctx, config, session, directory, signal, root) {
|
|
|
483
517
|
return (name, args, allowedExitCodes = [0], configOverrides = {}) => runGit(ctx, config, policy, directory, name, args, signal, allowedExitCodes, configOverrides);
|
|
484
518
|
}
|
|
485
519
|
/**
|
|
520
|
+
* Bind a Git runner that no Session's sandbox policy confines, for a write a person asked for in the interface: the
|
|
521
|
+
* press is that person's authorization, as archiving is for the worktree service's removal of a checkout. Commands
|
|
522
|
+
* keep the mounted subprocess provider, the scrubbed environment, the fixed command prefix, and `config`'s limits.
|
|
523
|
+
* @param ctx - context that provides `subprocess`.
|
|
524
|
+
* @param config - executable and process limits.
|
|
525
|
+
* @param directory - working directory of every command.
|
|
526
|
+
* @param signal - cancellation of every command.
|
|
527
|
+
* @returns the runner.
|
|
528
|
+
*/
|
|
529
|
+
function gitUnconfined(ctx, config, directory, signal) {
|
|
530
|
+
const policy = {
|
|
531
|
+
mode: "danger-full-access",
|
|
532
|
+
workspaceRoot: directory
|
|
533
|
+
};
|
|
534
|
+
return (name, args, allowedExitCodes = [0], configOverrides = {}) => runGit(ctx, config, policy, directory, name, args, signal, allowedExitCodes, configOverrides);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
486
537
|
* Read the checked-out local branch, including an unborn one; null when HEAD is detached or names a ref outside
|
|
487
538
|
* `refs/heads/`. The full ref is read because the short form turns `main` into `heads/main` while a tag shares the name.
|
|
488
539
|
*/
|
|
@@ -511,7 +562,7 @@ async function runGit(ctx, config, policy, cwd, name, args, signal, allowedExitC
|
|
|
511
562
|
hasError: false
|
|
512
563
|
};
|
|
513
564
|
try {
|
|
514
|
-
const timeout = __addDisposableResource$
|
|
565
|
+
const timeout = __addDisposableResource$3(env_1, deadline(signal, config.gitTimeoutMs, "FORGE_PANEL_GIT_TIMEOUT"), false);
|
|
515
566
|
const command = [
|
|
516
567
|
await ctx.subprocess.resolveExecutable(config.gitCommand, void 0, timeout.signal),
|
|
517
568
|
...GIT_PREFIX,
|
|
@@ -545,7 +596,7 @@ async function runGit(ctx, config, policy, cwd, name, args, signal, allowedExitC
|
|
|
545
596
|
const captured = child.collected;
|
|
546
597
|
const stdout = captured.stdout.readFrom(0);
|
|
547
598
|
const stderr = captured.stderr.readFrom(0);
|
|
548
|
-
if (outcome.exitCode === null || !allowedExitCodes.includes(outcome.exitCode)) throw new
|
|
599
|
+
if (outcome.exitCode === null || !allowedExitCodes.includes(outcome.exitCode)) throw new GitFailed(name, outcome.signal ?? outcome.exitCode, firstLine(stderr.text));
|
|
549
600
|
if (stdout.lossy) throw new GitOutputTooLarge(`git ${name} output exceeds maxOutputBytes`);
|
|
550
601
|
return {
|
|
551
602
|
stdout: stdout.text,
|
|
@@ -560,7 +611,7 @@ async function runGit(ctx, config, policy, cwd, name, args, signal, allowedExitC
|
|
|
560
611
|
env_1.error = e_1;
|
|
561
612
|
env_1.hasError = true;
|
|
562
613
|
} finally {
|
|
563
|
-
__disposeResources$
|
|
614
|
+
__disposeResources$3(env_1);
|
|
564
615
|
}
|
|
565
616
|
}
|
|
566
617
|
function firstLine(text) {
|
|
@@ -575,6 +626,8 @@ const NULL_PATH = "/dev/null";
|
|
|
575
626
|
const BINARY_PROBE_BYTES = 8e3;
|
|
576
627
|
/** Blob names of both sides on a Git `index` header line, which identify a binary change that carries no hunks. */
|
|
577
628
|
const INDEX_LINE = /^index ([0-9a-f]+\.\.[0-9a-f]+)/m;
|
|
629
|
+
/** A header line that carries the file mode of a submodule entry: the `index` line of a change, or a creation or deletion. */
|
|
630
|
+
const SUBMODULE_LINE = /^(?:index [0-9a-f]+\.\.[0-9a-f]+ 160000|(?:new|deleted) file mode 160000)$/m;
|
|
578
631
|
/**
|
|
579
632
|
* Parse a Git-style unified patch, as `git diff` or a code host prints it,
|
|
580
633
|
* with `a/` and `b/` path prefixes. Hunk ranges follow jsdiff: a range that
|
|
@@ -604,8 +657,8 @@ function parseDiff(patch) {
|
|
|
604
657
|
newLines,
|
|
605
658
|
lines
|
|
606
659
|
}));
|
|
607
|
-
const header =
|
|
608
|
-
const blobs = INDEX_LINE.exec(header)?.[1] ?? "";
|
|
660
|
+
const header = headers.length === parsed.length ? String(headers[index]) : "";
|
|
661
|
+
const blobs = binary ? INDEX_LINE.exec(header)?.[1] ?? "" : "";
|
|
609
662
|
const modes = `${section.oldMode ?? ""}..${section.newMode ?? ""}`;
|
|
610
663
|
return [{
|
|
611
664
|
path,
|
|
@@ -614,6 +667,7 @@ function parseDiff(patch) {
|
|
|
614
667
|
binary,
|
|
615
668
|
oversized: false,
|
|
616
669
|
untracked: false,
|
|
670
|
+
submodule: SUBMODULE_LINE.test(header),
|
|
617
671
|
additions,
|
|
618
672
|
deletions,
|
|
619
673
|
hunks,
|
|
@@ -686,6 +740,7 @@ function addedFile(path, hunks, { binary, oversized, content }) {
|
|
|
686
740
|
binary,
|
|
687
741
|
oversized,
|
|
688
742
|
untracked: true,
|
|
743
|
+
submodule: false,
|
|
689
744
|
additions: hunks[0]?.newLines ?? 0,
|
|
690
745
|
deletions: 0,
|
|
691
746
|
hunks,
|
|
@@ -1119,6 +1174,10 @@ var NoForkPoint = class extends Error {
|
|
|
1119
1174
|
var BaseMissing = class extends Error {
|
|
1120
1175
|
name = "BaseMissing";
|
|
1121
1176
|
};
|
|
1177
|
+
/** Thrown when the branch a scope reads in place of the checked-out one does not exist. */
|
|
1178
|
+
var HeadMissing = class extends Error {
|
|
1179
|
+
name = "HeadMissing";
|
|
1180
|
+
};
|
|
1122
1181
|
/** Thrown when chosen commits are not among the commits of the `branch` scope, or are out of order. */
|
|
1123
1182
|
var CommitsMissing = class extends Error {
|
|
1124
1183
|
name = "CommitsMissing";
|
|
@@ -1172,17 +1231,47 @@ async function diffFilterOverrides(git) {
|
|
|
1172
1231
|
/** Characters Git inspects for a NUL character before it calls content binary. */
|
|
1173
1232
|
const BINARY_PROBE = 8e3;
|
|
1174
1233
|
/**
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
*
|
|
1234
|
+
* Read the Session's own HEAD.
|
|
1235
|
+
* @param git - runner bound to the Session's checkout.
|
|
1236
|
+
* @param checkout - that checkout.
|
|
1237
|
+
* @returns the commit and its name, or null while the checked-out branch has no commit.
|
|
1238
|
+
* @throws an Error when Git fails.
|
|
1239
|
+
*/
|
|
1240
|
+
async function sessionHead(git, checkout) {
|
|
1241
|
+
const head = await git("session-head", [
|
|
1242
|
+
"rev-parse",
|
|
1243
|
+
"--verify",
|
|
1244
|
+
"--quiet",
|
|
1245
|
+
"HEAD^{commit}"
|
|
1246
|
+
], [0, 1]);
|
|
1247
|
+
const commit = head.exitCode === 0 ? parseName(head.stdout) : null;
|
|
1248
|
+
if (commit === null) return null;
|
|
1249
|
+
return checkout.branch === null ? {
|
|
1250
|
+
commit,
|
|
1251
|
+
label: commit.slice(0, 7),
|
|
1252
|
+
ref: null
|
|
1253
|
+
} : {
|
|
1254
|
+
commit,
|
|
1255
|
+
label: checkout.branch,
|
|
1256
|
+
ref: `${BASE_REF_PREFIXES[0]}${checkout.branch}`
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Find where the `branch` scope forks while no base branch is chosen. For a branch shown in place of the Session's
|
|
1261
|
+
* checkout: the merge base of the tip with the Session's own HEAD. For the Session's checkout: the base commit of the
|
|
1262
|
+
* worktree the Session created while the checkout is that worktree, else the merge base of HEAD with the default
|
|
1263
|
+
* branch of the first remote that names one, in the order the panel recognizes code hosts.
|
|
1179
1264
|
* @param git - runner bound to the checkout.
|
|
1180
1265
|
* @param inspection - the checkout and its remotes.
|
|
1181
|
-
* @param created - worktree the Session created, or null.
|
|
1182
|
-
* @
|
|
1266
|
+
* @param created - worktree the checkout's Session created, or null.
|
|
1267
|
+
* @param tip - revision the scope shows: HEAD for the checkout, or a branch ref, which no created worktree applies to.
|
|
1268
|
+
* @param against - the Session's own HEAD while the scope shows another branch, or null for the Session's checkout.
|
|
1269
|
+
* @returns the fork point, or null when the tip shares no history with what it is compared with, or no remote names
|
|
1270
|
+
* a default branch for the Session's checkout.
|
|
1183
1271
|
*/
|
|
1184
|
-
async function forkPoint(git, inspection, created) {
|
|
1185
|
-
if (
|
|
1272
|
+
async function forkPoint(git, inspection, created, tip = "HEAD", against = null) {
|
|
1273
|
+
if (against !== null) return await mergeBase(git, tip, against.commit, against.label);
|
|
1274
|
+
if (tip === "HEAD" && created !== null && created.path === inspection.checkout.root) {
|
|
1186
1275
|
const label = created.from === null ? created.baseCommit.slice(0, 7) : branchLabel(created.from);
|
|
1187
1276
|
return {
|
|
1188
1277
|
commit: created.baseCommit,
|
|
@@ -1203,45 +1292,16 @@ async function forkPoint(git, inspection, created) {
|
|
|
1203
1292
|
]);
|
|
1204
1293
|
const base = head.exitCode === 0 ? parseName(head.stdout) : null;
|
|
1205
1294
|
if (base === null) continue;
|
|
1206
|
-
|
|
1207
|
-
"merge-base",
|
|
1208
|
-
"HEAD",
|
|
1209
|
-
base
|
|
1210
|
-
], [
|
|
1211
|
-
0,
|
|
1212
|
-
1,
|
|
1213
|
-
128
|
|
1214
|
-
]);
|
|
1215
|
-
const commit = merge.exitCode === 0 ? parseName(merge.stdout) : null;
|
|
1216
|
-
return commit === null ? null : {
|
|
1217
|
-
commit,
|
|
1218
|
-
label: base,
|
|
1219
|
-
worktree: false
|
|
1220
|
-
};
|
|
1295
|
+
return await mergeBase(git, tip, base, base);
|
|
1221
1296
|
}
|
|
1222
1297
|
return null;
|
|
1223
1298
|
}
|
|
1224
|
-
/**
|
|
1225
|
-
|
|
1226
|
-
* @param git - runner bound to the checkout.
|
|
1227
|
-
* @param ref - full ref name under `refs/heads/` or `refs/remotes/`.
|
|
1228
|
-
* @returns the fork point, or null when HEAD shares no history with the branch or has no commit.
|
|
1229
|
-
* @throws BaseMissing when the ref does not exist; an Error for another ref name or when Git fails.
|
|
1230
|
-
*/
|
|
1231
|
-
async function chosenForkPoint(git, ref) {
|
|
1232
|
-
const prefix = BASE_REF_PREFIXES.find((candidate) => ref.startsWith(candidate) && ref.length > candidate.length);
|
|
1233
|
-
if (prefix === void 0) throw new Error(`forge-panel: ${JSON.stringify(ref)} is not a branch ref`);
|
|
1234
|
-
const name = ref.slice(prefix.length);
|
|
1235
|
-
if ((await git("show-ref", [
|
|
1236
|
-
"show-ref",
|
|
1237
|
-
"--verify",
|
|
1238
|
-
"--quiet",
|
|
1239
|
-
ref
|
|
1240
|
-
], [0, 1])).exitCode !== 0) throw new BaseMissing(`The base branch ${name} does not exist`);
|
|
1299
|
+
/** The merge base of the tip with a revision, under the name the panel shows for that revision; null without shared history. */
|
|
1300
|
+
async function mergeBase(git, tip, revision, label) {
|
|
1241
1301
|
const merge = await git("merge-base", [
|
|
1242
1302
|
"merge-base",
|
|
1243
|
-
|
|
1244
|
-
|
|
1303
|
+
tip,
|
|
1304
|
+
revision
|
|
1245
1305
|
], [
|
|
1246
1306
|
0,
|
|
1247
1307
|
1,
|
|
@@ -1250,37 +1310,105 @@ async function chosenForkPoint(git, ref) {
|
|
|
1250
1310
|
const commit = merge.exitCode === 0 ? parseName(merge.stdout) : null;
|
|
1251
1311
|
return commit === null ? null : {
|
|
1252
1312
|
commit,
|
|
1253
|
-
label
|
|
1313
|
+
label,
|
|
1254
1314
|
worktree: false
|
|
1255
1315
|
};
|
|
1256
1316
|
}
|
|
1257
1317
|
/**
|
|
1318
|
+
* Find where the `branch` scope forks from a chosen base branch: the merge base of the tip with it.
|
|
1319
|
+
* @param git - runner bound to the checkout.
|
|
1320
|
+
* @param ref - full ref name under `refs/heads/` or `refs/remotes/`.
|
|
1321
|
+
* @param tip - revision the scope shows: HEAD for the checkout, or a branch ref.
|
|
1322
|
+
* @returns the fork point, or null when the tip shares no history with the branch or has no commit.
|
|
1323
|
+
* @throws BaseMissing when the ref does not exist; an Error for another ref name or when Git fails.
|
|
1324
|
+
*/
|
|
1325
|
+
async function chosenForkPoint(git, ref, tip = "HEAD") {
|
|
1326
|
+
const { name, present } = await branchOf(git, ref);
|
|
1327
|
+
if (!present) throw new BaseMissing(`The base branch ${name} does not exist`);
|
|
1328
|
+
return await mergeBase(git, tip, ref, name);
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Check the branch a scope shows in place of the checkout.
|
|
1332
|
+
* @param git - runner bound to a checkout of the repository.
|
|
1333
|
+
* @param ref - full ref name under `refs/heads/` or `refs/remotes/`.
|
|
1334
|
+
* @returns the ref, which Git may receive as a revision.
|
|
1335
|
+
* @throws HeadMissing when the ref does not exist; an Error for another ref name or when Git fails.
|
|
1336
|
+
*/
|
|
1337
|
+
async function branchTip(git, ref) {
|
|
1338
|
+
const { name, present } = await branchOf(git, ref);
|
|
1339
|
+
if (!present) throw new HeadMissing(`The branch ${name} does not exist`);
|
|
1340
|
+
return ref;
|
|
1341
|
+
}
|
|
1342
|
+
/** The name of a branch ref and whether the ref exists; another ref name is refused before Git reads it. */
|
|
1343
|
+
async function branchOf(git, ref) {
|
|
1344
|
+
const prefix = BASE_REF_PREFIXES.find((candidate) => ref.startsWith(candidate) && ref.length > candidate.length);
|
|
1345
|
+
if (prefix === void 0) throw new Error(`forge-panel: ${JSON.stringify(ref)} is not a branch ref`);
|
|
1346
|
+
const present = await git("show-ref", [
|
|
1347
|
+
"show-ref",
|
|
1348
|
+
"--verify",
|
|
1349
|
+
"--quiet",
|
|
1350
|
+
ref
|
|
1351
|
+
], [0, 1]);
|
|
1352
|
+
return {
|
|
1353
|
+
name: ref.slice(prefix.length),
|
|
1354
|
+
present: present.exitCode === 0
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1258
1358
|
* List the branches the `branch` scope can compare with.
|
|
1259
1359
|
* @param git - runner bound to the checkout.
|
|
1260
1360
|
* @param inspection - the checkout and its remotes.
|
|
1261
|
-
* @param created - worktree the Session created, or null.
|
|
1361
|
+
* @param created - worktree the checkout's Session created, or null.
|
|
1262
1362
|
* @param query - text the branch names must contain, ignoring case; empty for every branch.
|
|
1263
1363
|
* @param limit - most branches in each group.
|
|
1264
|
-
* @
|
|
1364
|
+
* @param tip - revision the scope shows: HEAD for the checkout, or a branch ref, which the listing leaves out.
|
|
1365
|
+
* @param against - the Session's own HEAD while the scope shows another branch, or null for the Session's checkout;
|
|
1366
|
+
* the listing leaves its branch out, because the automatic fork point already compares with it.
|
|
1367
|
+
* @returns the automatic fork point, then remote-tracking and local branches, most recently committed first; a local
|
|
1368
|
+
* branch that a worktree has checked out names the directory Git registered for it.
|
|
1265
1369
|
* @throws an Error when Git fails or prints more than the runner's output limit.
|
|
1266
1370
|
*/
|
|
1267
|
-
async function baseBranches(git, inspection, created, query, limit) {
|
|
1268
|
-
const fork = await forkPoint(git, inspection, created);
|
|
1371
|
+
async function baseBranches(git, inspection, created, query, limit, tip = "HEAD", against = null) {
|
|
1372
|
+
const fork = await forkPoint(git, inspection, created, tip, against);
|
|
1269
1373
|
const refs = await git("base-branches", [
|
|
1270
1374
|
"for-each-ref",
|
|
1271
1375
|
"--sort=-committerdate",
|
|
1272
1376
|
"--format=%(refname)%00%(symref)",
|
|
1273
1377
|
...BASE_REF_PREFIXES
|
|
1274
1378
|
]);
|
|
1379
|
+
const hidden = [tip !== "HEAD" ? tip : inspection.checkout.branch === null ? null : `${BASE_REF_PREFIXES[0]}${inspection.checkout.branch}`, against === null ? null : against.ref].filter((ref) => ref !== null);
|
|
1380
|
+
const { remote, local } = parseBaseBranches(refs.stdout, hidden, query, limit);
|
|
1381
|
+
const trees = await branchWorktrees(git);
|
|
1275
1382
|
return {
|
|
1276
1383
|
automatic: fork === null ? null : {
|
|
1277
1384
|
name: fork.label,
|
|
1278
1385
|
worktree: fork.worktree
|
|
1279
1386
|
},
|
|
1280
|
-
|
|
1387
|
+
remote,
|
|
1388
|
+
local: local.map((branch) => {
|
|
1389
|
+
const worktree = trees.get(branch.ref);
|
|
1390
|
+
return worktree === void 0 ? branch : {
|
|
1391
|
+
...branch,
|
|
1392
|
+
worktree
|
|
1393
|
+
};
|
|
1394
|
+
})
|
|
1281
1395
|
};
|
|
1282
1396
|
}
|
|
1283
1397
|
/**
|
|
1398
|
+
* Find the worktree of the repository that has each branch checked out.
|
|
1399
|
+
* @param git - runner bound to a checkout of the repository.
|
|
1400
|
+
* @returns the directory Git registered for each checked-out branch, by full ref name, without a worktree that Git
|
|
1401
|
+
* marks as gone and one without a branch. {@link parseWorktrees} says why a caller confirms the directory.
|
|
1402
|
+
* @throws an Error when Git fails or prints more than the runner's output limit.
|
|
1403
|
+
*/
|
|
1404
|
+
async function branchWorktrees(git) {
|
|
1405
|
+
return parseWorktrees((await git("worktrees", [
|
|
1406
|
+
"worktree",
|
|
1407
|
+
"list",
|
|
1408
|
+
"--porcelain"
|
|
1409
|
+
])).stdout);
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1284
1412
|
* Read changes at `root` with command-local clean/process filter overrides and without
|
|
1285
1413
|
* submodule working-tree inspection. Git's built-in newline, ident, and encoding conversions still apply.
|
|
1286
1414
|
* Each file's layer follows `layers` and the root `.gitattributes` of the new side: the index for `staged`,
|
|
@@ -1288,17 +1416,19 @@ async function baseBranches(git, inspection, created, query, limit) {
|
|
|
1288
1416
|
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
1289
1417
|
* @param config - Git and size limits.
|
|
1290
1418
|
* @param session - Session whose sandbox policy and execution world apply.
|
|
1291
|
-
* @param root - top-level directory of the checkout
|
|
1419
|
+
* @param root - top-level directory of the checkout the scope reads: the Session's own, or the worktree of its `head`.
|
|
1292
1420
|
* @param fork - fork point of the `branch` scope, or null without one.
|
|
1293
|
-
* @param scope - which changes to read
|
|
1421
|
+
* @param scope - which changes to read; its `head` is already resolved into `root` and `tip`.
|
|
1294
1422
|
* @param layers - classifier of each file's review layer.
|
|
1295
1423
|
* @param signal - cancellation of every command and read.
|
|
1296
|
-
* @
|
|
1424
|
+
* @param tip - `HEAD` to read the checkout at `root` with its working tree, or a verified branch ref that the
|
|
1425
|
+
* `branch` scope reads from its commits alone.
|
|
1426
|
+
* @returns tracked files in Git's order, then untracked files unless the scope is `staged` or reads a branch's commits.
|
|
1297
1427
|
* @throws NoForkPoint for the `branch` scope without `fork`; FilterConfigError when filter configuration
|
|
1298
1428
|
* cannot be read within `maxDiffBytes`; DiffTooLarge for oversized comparison output or `.gitattributes`;
|
|
1299
1429
|
* an Error when Git or the `.gitattributes` read fails.
|
|
1300
1430
|
*/
|
|
1301
|
-
async function localDiff(ctx, config, session, root, fork, scope, layers, signal) {
|
|
1431
|
+
async function localDiff(ctx, config, session, root, fork, scope, layers, signal, tip = "HEAD") {
|
|
1302
1432
|
const git = gitIn(ctx, {
|
|
1303
1433
|
...config,
|
|
1304
1434
|
maxOutputBytes: config.maxDiffBytes
|
|
@@ -1307,7 +1437,8 @@ async function localDiff(ctx, config, session, root, fork, scope, layers, signal
|
|
|
1307
1437
|
switch (scope.kind) {
|
|
1308
1438
|
case "branch":
|
|
1309
1439
|
if (fork === null) throw new NoForkPoint("The checkout has no fork point to compare its branch with");
|
|
1310
|
-
if (scope.commits !== null) return await commitsDiff(git, fork, scope.commits, layers);
|
|
1440
|
+
if (scope.commits !== null) return await commitsDiff(git, fork, scope.commits, layers, tip);
|
|
1441
|
+
if (tip !== "HEAD") return await treeDiff(git, fork, fork.commit, tip, layers);
|
|
1311
1442
|
range = [fork.commit];
|
|
1312
1443
|
break;
|
|
1313
1444
|
case "uncommitted":
|
|
@@ -1352,7 +1483,7 @@ async function localDiff(ctx, config, session, root, fork, scope, layers, signal
|
|
|
1352
1483
|
/**
|
|
1353
1484
|
* Read the new side of one file in a scope, which supplies the unchanged
|
|
1354
1485
|
* lines between hunks: the index for `staged`, the last chosen commit for
|
|
1355
|
-
* chosen commits of the `branch` scope, else the working tree.
|
|
1486
|
+
* chosen commits of the `branch` scope, the branch for a head read from its commits, else the working tree.
|
|
1356
1487
|
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
1357
1488
|
* @param config - Git and size limits.
|
|
1358
1489
|
* @param session - Session whose sandbox policy and execution world apply.
|
|
@@ -1360,15 +1491,17 @@ async function localDiff(ctx, config, session, root, fork, scope, layers, signal
|
|
|
1360
1491
|
* @param scope - the scope whose new side to read.
|
|
1361
1492
|
* @param path - path relative to `root`, as the diff names it.
|
|
1362
1493
|
* @param signal - cancellation.
|
|
1494
|
+
* @param tip - `HEAD` for the checkout at `root`, or a verified branch ref whose commits the `branch` scope reads.
|
|
1363
1495
|
* @returns the text.
|
|
1364
1496
|
* @throws DiffTooLarge over `maxDiffBytes`; an Error for a path outside the checkout, binary content, or a failed read.
|
|
1365
1497
|
*/
|
|
1366
|
-
async function localText(ctx, config, session, root, scope, path, signal) {
|
|
1498
|
+
async function localText(ctx, config, session, root, scope, path, signal, tip = "HEAD") {
|
|
1367
1499
|
if (!insideCheckout(path)) throw new Error(`forge-panel: ${JSON.stringify(path)} is not a path inside the checkout`);
|
|
1368
1500
|
let text;
|
|
1369
|
-
const
|
|
1501
|
+
const chosen = scope.kind === "branch" && scope.commits !== null ? scope.commits.to : void 0;
|
|
1502
|
+
if (chosen !== void 0 && !COMMIT.test(chosen)) throw new CommitsMissing("The chosen commit is not a full object name");
|
|
1503
|
+
const commit = scope.kind === "staged" ? "" : chosen ?? (scope.kind === "branch" && tip !== "HEAD" ? tip : void 0);
|
|
1370
1504
|
if (commit !== void 0) {
|
|
1371
|
-
if (commit !== "" && !COMMIT.test(commit)) throw new CommitsMissing("The chosen commit is not a full object name");
|
|
1372
1505
|
const shown = (await bounded(gitIn(ctx, {
|
|
1373
1506
|
...config,
|
|
1374
1507
|
maxOutputBytes: config.maxDiffBytes
|
|
@@ -1494,20 +1627,21 @@ async function aheadOf(git, branch, commit) {
|
|
|
1494
1627
|
])).stdout.trim());
|
|
1495
1628
|
}
|
|
1496
1629
|
/**
|
|
1497
|
-
* List the commits of the `branch` scope: those reachable from
|
|
1630
|
+
* List the commits of the `branch` scope: those reachable from the tip but not from the fork point, parents before children.
|
|
1498
1631
|
* @param git - runner bound to the checkout, whose output limit bounds the listing.
|
|
1499
1632
|
* @param fork - fork point of the `branch` scope.
|
|
1500
1633
|
* @param limit - most commits listed.
|
|
1501
|
-
* @
|
|
1634
|
+
* @param tip - revision the scope shows: HEAD for the checkout, or a branch ref.
|
|
1635
|
+
* @returns the newest `limit` commits, ending with the tip's commit, and the tip's commit.
|
|
1502
1636
|
* @throws an Error when Git fails or prints more than the runner's output limit.
|
|
1503
1637
|
*/
|
|
1504
|
-
async function localCommits(git, fork, limit) {
|
|
1638
|
+
async function localCommits(git, fork, limit, tip = "HEAD") {
|
|
1505
1639
|
const head = (await git("head", [
|
|
1506
1640
|
"rev-parse",
|
|
1507
1641
|
"--verify",
|
|
1508
|
-
|
|
1642
|
+
tip
|
|
1509
1643
|
])).stdout.trim();
|
|
1510
|
-
const listed = await branchCommits(git, fork, limit + 1);
|
|
1644
|
+
const listed = await branchCommits(git, fork, tip, limit + 1);
|
|
1511
1645
|
return {
|
|
1512
1646
|
headSha: head,
|
|
1513
1647
|
commits: listed.slice(-limit),
|
|
@@ -1515,10 +1649,10 @@ async function localCommits(git, fork, limit) {
|
|
|
1515
1649
|
};
|
|
1516
1650
|
}
|
|
1517
1651
|
/**
|
|
1518
|
-
* Commits between the fork point and
|
|
1652
|
+
* Commits between the fork point and the tip, parents before children.
|
|
1519
1653
|
* @param limit - when given, only the newest `limit` commits in topological order.
|
|
1520
1654
|
*/
|
|
1521
|
-
async function branchCommits(git, fork, limit) {
|
|
1655
|
+
async function branchCommits(git, fork, tip, limit) {
|
|
1522
1656
|
return (await git("log", [
|
|
1523
1657
|
"log",
|
|
1524
1658
|
"--no-show-signature",
|
|
@@ -1526,7 +1660,7 @@ async function branchCommits(git, fork, limit) {
|
|
|
1526
1660
|
"--reverse",
|
|
1527
1661
|
...limit === void 0 ? [] : [`--max-count=${String(limit)}`],
|
|
1528
1662
|
LOG_FORMAT,
|
|
1529
|
-
`${fork.commit}
|
|
1663
|
+
`${fork.commit}..${tip}`,
|
|
1530
1664
|
"--"
|
|
1531
1665
|
])).stdout.split("").flatMap((record) => {
|
|
1532
1666
|
const fields = record.replace(/^\n/, "").split("\0");
|
|
@@ -1542,20 +1676,23 @@ async function branchCommits(git, fork, limit) {
|
|
|
1542
1676
|
});
|
|
1543
1677
|
}
|
|
1544
1678
|
/** The committed changes of consecutive commits of the `branch` scope, from the first commit's first parent to the last. */
|
|
1545
|
-
async function commitsDiff(git, fork, chosen, layers) {
|
|
1679
|
+
async function commitsDiff(git, fork, chosen, layers, tip) {
|
|
1546
1680
|
if (!COMMIT.test(chosen.from) || !COMMIT.test(chosen.to)) throw new CommitsMissing("The chosen commits are not full object names");
|
|
1547
|
-
const start = rangeStart(await branchCommits(git, fork), chosen);
|
|
1681
|
+
const start = rangeStart(await branchCommits(git, fork, tip), chosen);
|
|
1548
1682
|
if (start === "missing") throw new CommitsMissing("The chosen commits are no longer on the branch");
|
|
1549
1683
|
if (start === "not-linear") throw new CommitsNotLinear("The chosen commits are not one run of first parents");
|
|
1550
|
-
|
|
1684
|
+
return await treeDiff(git, fork, start.parent ?? await emptyTree(git), chosen.to, layers);
|
|
1685
|
+
}
|
|
1686
|
+
/** The committed changes from one revision to another, with each file's layer read at the newer one. */
|
|
1687
|
+
async function treeDiff(git, fork, from, to, layers) {
|
|
1551
1688
|
const overrides = await diffFilterOverrides(git);
|
|
1552
1689
|
const files = parseDiff((await bounded(git("diff", [
|
|
1553
1690
|
...DIFF,
|
|
1554
|
-
|
|
1555
|
-
|
|
1691
|
+
from,
|
|
1692
|
+
to,
|
|
1556
1693
|
"--"
|
|
1557
1694
|
], void 0, overrides))).stdout);
|
|
1558
|
-
const shown = await bounded(git("attributes", ["show", `${
|
|
1695
|
+
const shown = await bounded(git("attributes", ["show", `${to}:${ATTRIBUTES_PATH}`], [0, 128]));
|
|
1559
1696
|
return {
|
|
1560
1697
|
base: fork.label,
|
|
1561
1698
|
files: layers.classify(files, shown.exitCode === 0 ? shown.stdout : ""),
|
|
@@ -1630,15 +1767,177 @@ async function bounded(output) {
|
|
|
1630
1767
|
throw error;
|
|
1631
1768
|
}
|
|
1632
1769
|
}
|
|
1633
|
-
/**
|
|
1770
|
+
/**
|
|
1771
|
+
* Whether a diff path stays inside the checkout: relative, without NUL, and without a `..` segment.
|
|
1772
|
+
* @param path - path as a diff names it.
|
|
1773
|
+
* @returns whether Git and the filesystem may receive it relative to the checkout root.
|
|
1774
|
+
*/
|
|
1634
1775
|
function insideCheckout(path) {
|
|
1635
1776
|
if (path.length === 0 || path.includes("\0") || path.startsWith("/") || /^[A-Za-z]:/.test(path)) return false;
|
|
1636
1777
|
return path.split(/[/\\]/).every((segment) => segment !== "..");
|
|
1637
1778
|
}
|
|
1638
1779
|
//#endregion
|
|
1780
|
+
//#region lib/types/restore.js
|
|
1781
|
+
/** Which unstaged changes a restore of the changes view can act on. */
|
|
1782
|
+
/**
|
|
1783
|
+
* Whether restoring a file of the `unstaged` scope has content to return to or an untracked file to delete. A file the
|
|
1784
|
+
* index tracks without content, as `git add --intent-to-add` leaves it, shows as added or renamed and has neither:
|
|
1785
|
+
* Git would replace it with an empty file. A submodule is left out as well: `git restore` succeeds on it and leaves
|
|
1786
|
+
* the commit it has checked out.
|
|
1787
|
+
* @param file - a file as the `unstaged` scope lists it.
|
|
1788
|
+
* @returns whether a restore of the file is offered and accepted.
|
|
1789
|
+
*/
|
|
1790
|
+
function restorable(file) {
|
|
1791
|
+
return !file.submodule && (file.untracked || file.status === "modified" || file.status === "deleted");
|
|
1792
|
+
}
|
|
1793
|
+
//#endregion
|
|
1794
|
+
//#region lib/types/local-write.js
|
|
1795
|
+
/**
|
|
1796
|
+
* Writes a person makes from the changes view to a Session's checkout: staging, unstaging, and restoring whole files,
|
|
1797
|
+
* and returning index entries to an earlier state. The press is that person's authorization, so Git runs through the
|
|
1798
|
+
* mounted subprocess provider without the Session's sandbox policy, which bounds what the Agent does. Staging and
|
|
1799
|
+
* restoring run the clean and smudge filters the repository configures.
|
|
1800
|
+
*/
|
|
1801
|
+
/** Thrown before anything is written when a file's unstaged change differs from the change the reader saw. */
|
|
1802
|
+
var LocalChangesStale = class extends Error {
|
|
1803
|
+
name = "LocalChangesStale";
|
|
1804
|
+
};
|
|
1805
|
+
/**
|
|
1806
|
+
* Thrown before anything is written when a file listed as deleted has a directory at its path. Git takes a path for
|
|
1807
|
+
* the directory and everything in it, so staging the deletion would stage those files and restoring the file would
|
|
1808
|
+
* delete them.
|
|
1809
|
+
*/
|
|
1810
|
+
var LocalPathReplaced = class extends Error {
|
|
1811
|
+
name = "LocalPathReplaced";
|
|
1812
|
+
};
|
|
1813
|
+
/** A full SHA-1 or SHA-256 object name, the only form of a tree Git receives. */
|
|
1814
|
+
const TREE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
1815
|
+
/** Characters of paths one command receives. Windows limits a command line to 32,767 characters, which Git's own arguments share. */
|
|
1816
|
+
const PATH_CHARACTERS = 16e3;
|
|
1817
|
+
/**
|
|
1818
|
+
* Apply one write to the checkout at `root`. `stage` and `restore` first read the `unstaged` scope again, under the
|
|
1819
|
+
* Session's sandbox policy as every read, and refuse the whole write when a file's change is not the one the reader
|
|
1820
|
+
* saw or a deleted file's path holds a directory; `unstage` and `reindex` change index entries only. The writing
|
|
1821
|
+
* commands run unconfined; paths reach Git as literal pathspecs, and a restore leaves submodules alone whatever
|
|
1822
|
+
* `submodule.recurse` says.
|
|
1823
|
+
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
1824
|
+
* @param config - Git and size limits.
|
|
1825
|
+
* @param session - Session whose sandbox policy the reads use.
|
|
1826
|
+
* @param root - top-level directory of the checkout.
|
|
1827
|
+
* @param write - the write.
|
|
1828
|
+
* @param layers - classifier the `unstaged` scope is read with.
|
|
1829
|
+
* @param signal - cancellation of every command and read.
|
|
1830
|
+
* @returns the index before a `stage` or `unstage` as a tree, for undoing it.
|
|
1831
|
+
* @throws LocalChangesStale when a file changed since it was read; LocalPathReplaced when a deleted file's path holds
|
|
1832
|
+
* a directory; an Error for a path outside the checkout, a tree that is not a full object name, or a file that
|
|
1833
|
+
* {@link restorable} leaves out of a restore; the errors of {@link localDiff}; GitFailed when Git fails. A failure
|
|
1834
|
+
* after the first command leaves the paths of the earlier commands written.
|
|
1835
|
+
*/
|
|
1836
|
+
async function localWrite(ctx, config, session, root, write, layers, signal) {
|
|
1837
|
+
const git = gitUnconfined(ctx, config, root, signal);
|
|
1838
|
+
const unstaged = (files) => listed(ctx, config, session, root, files, layers, signal);
|
|
1839
|
+
switch (write.kind) {
|
|
1840
|
+
case "stage": {
|
|
1841
|
+
const files = await unstaged(write.files);
|
|
1842
|
+
const undo = await indexTree(git);
|
|
1843
|
+
await run(git, "add", ["add", "--"], files.flatMap((file) => file.previousPath === null ? [file.path] : [file.previousPath, file.path]));
|
|
1844
|
+
return { undo };
|
|
1845
|
+
}
|
|
1846
|
+
case "unstage": {
|
|
1847
|
+
const paths = contained(write.paths);
|
|
1848
|
+
const undo = await indexTree(git);
|
|
1849
|
+
await run(git, "reset", [
|
|
1850
|
+
"reset",
|
|
1851
|
+
"-q",
|
|
1852
|
+
"--"
|
|
1853
|
+
], paths);
|
|
1854
|
+
return { undo };
|
|
1855
|
+
}
|
|
1856
|
+
case "restore": {
|
|
1857
|
+
const files = await unstaged(write.files);
|
|
1858
|
+
const refused = files.find((file) => !restorable(file));
|
|
1859
|
+
if (refused !== void 0) throw new Error(`forge-panel: ${refused.path} is a submodule or has no index content, so it cannot be restored`);
|
|
1860
|
+
await run(git, "restore", [
|
|
1861
|
+
"restore",
|
|
1862
|
+
"--worktree",
|
|
1863
|
+
"--no-recurse-submodules",
|
|
1864
|
+
"--"
|
|
1865
|
+
], files.filter((file) => !file.untracked).map((file) => file.path));
|
|
1866
|
+
await run(git, "clean", [
|
|
1867
|
+
"clean",
|
|
1868
|
+
"-f",
|
|
1869
|
+
"-q",
|
|
1870
|
+
"--"
|
|
1871
|
+
], files.filter((file) => file.untracked).map((file) => file.path));
|
|
1872
|
+
return { undo: null };
|
|
1873
|
+
}
|
|
1874
|
+
case "reindex":
|
|
1875
|
+
if (!TREE.test(write.tree)) throw new Error("forge-panel: the tree to return to is not a full object name");
|
|
1876
|
+
await run(git, "reset", [
|
|
1877
|
+
"reset",
|
|
1878
|
+
"-q",
|
|
1879
|
+
write.tree,
|
|
1880
|
+
"--"
|
|
1881
|
+
], contained(write.paths));
|
|
1882
|
+
return { undo: null };
|
|
1883
|
+
/* v8 ignore next -- closed ForgeLocalWrite union exhaustiveness guard */
|
|
1884
|
+
default: return assertNever(write, "ForgeLocalWrite.kind");
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* The files as the `unstaged` scope lists them now; a file that is gone or whose change differs is stale, and a
|
|
1889
|
+
* deleted file whose path holds a directory is refused.
|
|
1890
|
+
*/
|
|
1891
|
+
async function listed(ctx, config, session, root, files, layers, signal) {
|
|
1892
|
+
const current = new Map((await localDiff(ctx, config, session, root, null, { kind: "unstaged" }, layers, signal)).files.map((file) => [file.path, file]));
|
|
1893
|
+
const matched = files.map((seen) => {
|
|
1894
|
+
const file = current.get(seen.path);
|
|
1895
|
+
if (file?.digest !== seen.digest) throw new LocalChangesStale(`${seen.path} changed since it was read`);
|
|
1896
|
+
return file;
|
|
1897
|
+
});
|
|
1898
|
+
for (const file of matched) {
|
|
1899
|
+
if (file.status !== "deleted") continue;
|
|
1900
|
+
if ((await ctx.fs.lstat(file.path, { cwd: root }, signal))?.type === "directory") throw new LocalPathReplaced(`${file.path} is a directory now; stage or restore the files in it instead`);
|
|
1901
|
+
}
|
|
1902
|
+
return matched;
|
|
1903
|
+
}
|
|
1904
|
+
/** The paths, each of which stays inside the checkout. */
|
|
1905
|
+
function contained(paths) {
|
|
1906
|
+
const outside = paths.find((path) => !insideCheckout(path));
|
|
1907
|
+
if (outside !== void 0) throw new Error(`forge-panel: ${JSON.stringify(outside)} is not a path inside the checkout`);
|
|
1908
|
+
return paths;
|
|
1909
|
+
}
|
|
1910
|
+
/** Write the index as a tree; null while it holds unmerged entries or cannot be locked, which the write that follows reports. */
|
|
1911
|
+
async function indexTree(git) {
|
|
1912
|
+
const written = await git("write-tree", ["write-tree"], [0, 128]);
|
|
1913
|
+
return written.exitCode === 0 ? written.stdout.trim() : null;
|
|
1914
|
+
}
|
|
1915
|
+
/** Run one subcommand over the paths as literal pathspecs, in as many commands as the command-line limit needs. */
|
|
1916
|
+
async function run(git, name, command, paths) {
|
|
1917
|
+
let batch = [];
|
|
1918
|
+
let characters = 0;
|
|
1919
|
+
const flush = async () => {
|
|
1920
|
+
if (batch.length === 0) return;
|
|
1921
|
+
const args = [
|
|
1922
|
+
"--literal-pathspecs",
|
|
1923
|
+
...command,
|
|
1924
|
+
...batch
|
|
1925
|
+
];
|
|
1926
|
+
batch = [];
|
|
1927
|
+
characters = 0;
|
|
1928
|
+
await git(name, args);
|
|
1929
|
+
};
|
|
1930
|
+
for (const path of paths) {
|
|
1931
|
+
if (characters + path.length > PATH_CHARACTERS) await flush();
|
|
1932
|
+
batch.push(path);
|
|
1933
|
+
characters += path.length + 1;
|
|
1934
|
+
}
|
|
1935
|
+
await flush();
|
|
1936
|
+
}
|
|
1937
|
+
//#endregion
|
|
1639
1938
|
//#region lib/types/lenses.js
|
|
1640
1939
|
/** Filter lenses registered on the forge panel host, the runs that classify one diff with one of them, and the kept results. */
|
|
1641
|
-
var __addDisposableResource$
|
|
1940
|
+
var __addDisposableResource$2 = function(env, value, async) {
|
|
1642
1941
|
if (value !== null && value !== void 0) {
|
|
1643
1942
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
1644
1943
|
var dispose, inner;
|
|
@@ -1667,7 +1966,7 @@ var __addDisposableResource$1 = function(env, value, async) {
|
|
|
1667
1966
|
} else if (async) env.stack.push({ async: true });
|
|
1668
1967
|
return value;
|
|
1669
1968
|
};
|
|
1670
|
-
var __disposeResources$
|
|
1969
|
+
var __disposeResources$2 = (function(SuppressedError) {
|
|
1671
1970
|
return function(env) {
|
|
1672
1971
|
function fail(e) {
|
|
1673
1972
|
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
@@ -1807,7 +2106,7 @@ async function runLens(registration, subject, limits, signal, progress) {
|
|
|
1807
2106
|
hasError: false
|
|
1808
2107
|
};
|
|
1809
2108
|
try {
|
|
1810
|
-
const operation = __addDisposableResource$
|
|
2109
|
+
const operation = __addDisposableResource$2(env_1, deadline(AbortSignal.any([signal, registration.lifetime]), limits.timeoutMs, "FORGE_LENS_TIMEOUT"), false).signal;
|
|
1811
2110
|
const byPath = new Map(subject.files.map((file) => [file.path, file]));
|
|
1812
2111
|
let read = 0;
|
|
1813
2112
|
const overBudget = () => new LensFailed(`the lens read more than maxLensReadBytes (${limits.maxReadBytes} bytes) of file text`);
|
|
@@ -1855,7 +2154,7 @@ async function runLens(registration, subject, limits, signal, progress) {
|
|
|
1855
2154
|
env_1.error = e_1;
|
|
1856
2155
|
env_1.hasError = true;
|
|
1857
2156
|
} finally {
|
|
1858
|
-
__disposeResources$
|
|
2157
|
+
__disposeResources$2(env_1);
|
|
1859
2158
|
}
|
|
1860
2159
|
}
|
|
1861
2160
|
/**
|
|
@@ -2562,7 +2861,7 @@ var WorktreeCreations = class {
|
|
|
2562
2861
|
//#endregion
|
|
2563
2862
|
//#region lib/types/panel.js
|
|
2564
2863
|
/** Live panel state of one followed Session, shared by all of its followers. */
|
|
2565
|
-
var __addDisposableResource = function(env, value, async) {
|
|
2864
|
+
var __addDisposableResource$1 = function(env, value, async) {
|
|
2566
2865
|
if (value !== null && value !== void 0) {
|
|
2567
2866
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
2568
2867
|
var dispose, inner;
|
|
@@ -2591,7 +2890,7 @@ var __addDisposableResource = function(env, value, async) {
|
|
|
2591
2890
|
} else if (async) env.stack.push({ async: true });
|
|
2592
2891
|
return value;
|
|
2593
2892
|
};
|
|
2594
|
-
var __disposeResources = (function(SuppressedError) {
|
|
2893
|
+
var __disposeResources$1 = (function(SuppressedError) {
|
|
2595
2894
|
return function(env) {
|
|
2596
2895
|
function fail(e) {
|
|
2597
2896
|
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
@@ -3038,13 +3337,13 @@ var SessionPanel = class {
|
|
|
3038
3337
|
hasError: false
|
|
3039
3338
|
};
|
|
3040
3339
|
try {
|
|
3041
|
-
const timeout = __addDisposableResource(env_1, deadline(this.lifetime.signal, this.config.readinessTimeoutMs, "FORGE_PANEL_READINESS_TIMEOUT"), false);
|
|
3340
|
+
const timeout = __addDisposableResource$1(env_1, deadline(this.lifetime.signal, this.config.readinessTimeoutMs, "FORGE_PANEL_READINESS_TIMEOUT"), false);
|
|
3042
3341
|
readiness = await this.ctx.forge.readiness(repository, timeout.signal);
|
|
3043
3342
|
} catch (e_1) {
|
|
3044
3343
|
env_1.error = e_1;
|
|
3045
3344
|
env_1.hasError = true;
|
|
3046
3345
|
} finally {
|
|
3047
|
-
__disposeResources(env_1);
|
|
3346
|
+
__disposeResources$1(env_1);
|
|
3048
3347
|
}
|
|
3049
3348
|
} catch (error) {
|
|
3050
3349
|
readiness = {
|
|
@@ -3617,9 +3916,10 @@ var ChangeRequestStates = class {
|
|
|
3617
3916
|
/**
|
|
3618
3917
|
* The review page's lists of the signed-in user's change requests and its navigation count. Lists are read only while
|
|
3619
3918
|
* some reader streams them and the count only while some reader streams it; neither joins the forge's status polling.
|
|
3620
|
-
* Readers of one repository scope share one poller, which reads every list of every host each round, hosts in
|
|
3621
|
-
* and each host's lists one after another, so one host has at most one read in flight. A
|
|
3622
|
-
*
|
|
3919
|
+
* Readers of one repository scope share one poller, which reads every list of every due host each round, hosts in
|
|
3920
|
+
* parallel and each host's lists one after another, so one host has at most one read in flight. A host whose read
|
|
3921
|
+
* failed is read again later each time, as status polling waits after consecutive failures, while the other hosts
|
|
3922
|
+
* keep their cadence. A scope that names a repository reads only the host the repository is on.
|
|
3623
3923
|
*/
|
|
3624
3924
|
/** The lists in the order the page shows them. */
|
|
3625
3925
|
const FILTERS = [
|
|
@@ -3678,18 +3978,16 @@ var Reader = class {
|
|
|
3678
3978
|
}
|
|
3679
3979
|
}
|
|
3680
3980
|
};
|
|
3681
|
-
/** A loop that runs one round, waits, and repeats until stopped; a refresh ends the wait early. */
|
|
3981
|
+
/** A loop that runs one round, waits as long as the round asks, and repeats until stopped; a refresh ends the wait early. */
|
|
3682
3982
|
var Poller = class {
|
|
3683
3983
|
round;
|
|
3684
|
-
delay;
|
|
3685
3984
|
aborter = new AbortController();
|
|
3686
3985
|
wake;
|
|
3687
3986
|
refreshing = false;
|
|
3688
|
-
failures = 0;
|
|
3689
3987
|
done;
|
|
3690
|
-
|
|
3988
|
+
/** @param round - runs one round, `forced` after a refresh, and resolves to the milliseconds to wait before the next. */
|
|
3989
|
+
constructor(round) {
|
|
3691
3990
|
this.round = round;
|
|
3692
|
-
this.delay = delay;
|
|
3693
3991
|
this.done = this.loop();
|
|
3694
3992
|
}
|
|
3695
3993
|
refresh() {
|
|
@@ -3708,12 +4006,12 @@ var Poller = class {
|
|
|
3708
4006
|
async loop() {
|
|
3709
4007
|
const { signal } = this.aborter;
|
|
3710
4008
|
while (!signal.aborted) {
|
|
4009
|
+
const forced = this.refreshing;
|
|
3711
4010
|
this.refreshing = false;
|
|
3712
|
-
const
|
|
3713
|
-
this.failures = succeeded ? 0 : this.failures + 1;
|
|
4011
|
+
const wait = await this.round(signal, forced);
|
|
3714
4012
|
if (this.skipsWait(signal)) continue;
|
|
3715
4013
|
await new Promise((resolve) => {
|
|
3716
|
-
const timer = setTimeout(resolve,
|
|
4014
|
+
const timer = setTimeout(resolve, wait);
|
|
3717
4015
|
this.wake = () => {
|
|
3718
4016
|
clearTimeout(timer);
|
|
3719
4017
|
resolve();
|
|
@@ -3723,24 +4021,65 @@ var Poller = class {
|
|
|
3723
4021
|
}
|
|
3724
4022
|
}
|
|
3725
4023
|
};
|
|
3726
|
-
/**
|
|
4024
|
+
/**
|
|
4025
|
+
* When each host of one poller is read next. A host is due at once until its first read settles; after a read it is
|
|
4026
|
+
* due one delay after the start of the round that read it, and the delay grows with its consecutive failed reads.
|
|
4027
|
+
*/
|
|
4028
|
+
var HostSchedule = class {
|
|
4029
|
+
delay;
|
|
4030
|
+
hosts = /* @__PURE__ */ new Map();
|
|
4031
|
+
/** @param delay - milliseconds between two reads of a host after the given number of consecutive failed reads. */
|
|
4032
|
+
constructor(delay) {
|
|
4033
|
+
this.delay = delay;
|
|
4034
|
+
}
|
|
4035
|
+
/** Whether a round that starts at `now` reads the host. */
|
|
4036
|
+
due(key, now) {
|
|
4037
|
+
return (this.hosts.get(key)?.dueAt ?? 0) <= now;
|
|
4038
|
+
}
|
|
4039
|
+
/** Record whether the read of the host succeeded in the round that started at `started`. */
|
|
4040
|
+
settle(key, started, succeeded) {
|
|
4041
|
+
const failures = succeeded ? 0 : (this.hosts.get(key)?.failures ?? 0) + 1;
|
|
4042
|
+
this.hosts.set(key, {
|
|
4043
|
+
failures,
|
|
4044
|
+
dueAt: started + this.delay(failures)
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
/** Milliseconds from `now` until the first of `keys` is due, or the delay between two successful reads without any key. */
|
|
4048
|
+
wait(keys, now) {
|
|
4049
|
+
if (keys.length === 0) return this.delay(0);
|
|
4050
|
+
return Math.max(0, Math.min(...keys.map((key) => this.hosts.get(key)?.dueAt ?? 0)) - now);
|
|
4051
|
+
}
|
|
4052
|
+
};
|
|
4053
|
+
/** The readers of one repository scope, the poller they share, when each host is read next, and what was read. */
|
|
3727
4054
|
var Scope = class {
|
|
4055
|
+
repository;
|
|
3728
4056
|
readers = /* @__PURE__ */ new Set();
|
|
3729
4057
|
hosts = /* @__PURE__ */ new Map();
|
|
4058
|
+
schedule;
|
|
3730
4059
|
reading = false;
|
|
3731
4060
|
poller;
|
|
3732
4061
|
/**
|
|
3733
|
-
* @param
|
|
3734
|
-
* @param
|
|
4062
|
+
* @param repository - the repository the scope lists in, or null for every repository of every host.
|
|
4063
|
+
* @param round - reads the scope's due hosts once, every host when `forced`; resolves to the wait before the next round.
|
|
4064
|
+
* @param delay - milliseconds between two reads of a host after the given number of consecutive failed reads.
|
|
3735
4065
|
*/
|
|
3736
|
-
constructor(round, delay) {
|
|
3737
|
-
this.
|
|
4066
|
+
constructor(repository, round, delay) {
|
|
4067
|
+
this.repository = repository;
|
|
4068
|
+
this.schedule = new HostSchedule(delay);
|
|
4069
|
+
this.poller = new Poller((signal, forced) => round(this, signal, forced));
|
|
4070
|
+
}
|
|
4071
|
+
/** The hosts the scope reads, in registration and configuration order: every host, or the one its repository is on. */
|
|
4072
|
+
targets(order) {
|
|
4073
|
+
const only = this.repository?.host.toLowerCase();
|
|
4074
|
+
return order.flatMap((source) => source.hosts.filter((host) => only === void 0 || host === only).map((host) => ({
|
|
4075
|
+
source,
|
|
4076
|
+
host,
|
|
4077
|
+
key: hostKey(source.forge, host)
|
|
4078
|
+
})));
|
|
3738
4079
|
}
|
|
3739
4080
|
frame(order) {
|
|
3740
|
-
const hosts = [];
|
|
3741
|
-
for (const source of order) for (const host of source.hosts) hosts.push(this.hosts.get(hostKey(source.forge, host)) ?? emptyHost(source, host));
|
|
3742
4081
|
return {
|
|
3743
|
-
hosts,
|
|
4082
|
+
hosts: this.targets(order).map(({ source, host, key }) => this.hosts.get(key) ?? emptyHost(source, host)),
|
|
3744
4083
|
reading: this.reading
|
|
3745
4084
|
};
|
|
3746
4085
|
}
|
|
@@ -3752,6 +4091,7 @@ var ViewerLists = class {
|
|
|
3752
4091
|
scopes = /* @__PURE__ */ new Map();
|
|
3753
4092
|
countReaders = /* @__PURE__ */ new Set();
|
|
3754
4093
|
counts = /* @__PURE__ */ new Map();
|
|
4094
|
+
countSchedule = new HostSchedule((failures) => this.delay(this.timing.countIntervalMs, failures));
|
|
3755
4095
|
countPoller;
|
|
3756
4096
|
disposed = false;
|
|
3757
4097
|
/**
|
|
@@ -3765,17 +4105,17 @@ var ViewerLists = class {
|
|
|
3765
4105
|
/**
|
|
3766
4106
|
* Stream the lists of one repository scope: the lists read so far first, then a frame after each read settles.
|
|
3767
4107
|
* The stream ends when `signal` aborts or the hub is disposed; the last stream of a scope stops its reads.
|
|
3768
|
-
* @param scope - one repository, or null for every repository.
|
|
4108
|
+
* @param scope - one repository on its host, or null for every repository of every host.
|
|
3769
4109
|
* @param signal - ends the stream.
|
|
3770
4110
|
* @returns frames, each complete.
|
|
3771
4111
|
*/
|
|
3772
4112
|
async *lists(scope, signal) {
|
|
3773
4113
|
signal.throwIfAborted();
|
|
3774
4114
|
if (this.disposed) return;
|
|
3775
|
-
const key = scope === null ? "" : `${scope.owner}/${scope.name}`.toLowerCase();
|
|
4115
|
+
const key = scope === null ? "" : `${scope.host}\n${scope.owner}/${scope.name}`.toLowerCase();
|
|
3776
4116
|
let state = this.scopes.get(key);
|
|
3777
4117
|
if (state === void 0) {
|
|
3778
|
-
state = new Scope((created, round) => this.readScope(created,
|
|
4118
|
+
state = new Scope(scope, (created, round, forced) => this.readScope(created, round, forced), (failures) => this.delay(this.timing.listIntervalMs, failures));
|
|
3779
4119
|
this.scopes.set(key, state);
|
|
3780
4120
|
}
|
|
3781
4121
|
const reader = new Reader(signal);
|
|
@@ -3804,7 +4144,7 @@ var ViewerLists = class {
|
|
|
3804
4144
|
const reader = new Reader(signal);
|
|
3805
4145
|
this.countReaders.add(reader);
|
|
3806
4146
|
reader.push(this.countFrame());
|
|
3807
|
-
this.countPoller ??= new Poller((round) => this.readCounts(round
|
|
4147
|
+
this.countPoller ??= new Poller((round, forced) => this.readCounts(round, forced));
|
|
3808
4148
|
try {
|
|
3809
4149
|
yield* reader.frames();
|
|
3810
4150
|
} finally {
|
|
@@ -3851,12 +4191,20 @@ var ViewerLists = class {
|
|
|
3851
4191
|
await poller.stop();
|
|
3852
4192
|
}));
|
|
3853
4193
|
}
|
|
3854
|
-
/**
|
|
3855
|
-
|
|
3856
|
-
|
|
4194
|
+
/**
|
|
4195
|
+
* Read every list of the scope's due hosts once, of every host when `forced`.
|
|
4196
|
+
* @returns milliseconds until the scope's next host is due.
|
|
4197
|
+
*/
|
|
4198
|
+
async readScope(scope, signal, forced) {
|
|
4199
|
+
const started = Date.now();
|
|
4200
|
+
const targets = scope.targets(this.sources.sources());
|
|
4201
|
+
const repository = scope.repository === null ? null : {
|
|
4202
|
+
owner: scope.repository.owner,
|
|
4203
|
+
name: scope.repository.name
|
|
4204
|
+
};
|
|
3857
4205
|
scope.reading = true;
|
|
3858
4206
|
this.publish(scope);
|
|
3859
|
-
|
|
4207
|
+
await Promise.all(targets.filter((target) => forced || scope.schedule.due(target.key, started)).map(async ({ source, host, key }) => {
|
|
3860
4208
|
let succeeded = true;
|
|
3861
4209
|
let hostFailure;
|
|
3862
4210
|
for (const filter of FILTERS) {
|
|
@@ -3868,31 +4216,59 @@ var ViewerLists = class {
|
|
|
3868
4216
|
limit: Math.min(source.maxItems, this.timing.pageSize)
|
|
3869
4217
|
};
|
|
3870
4218
|
const result = hostFailure ?? await this.read(() => this.sources.list(source.forge, query, signal), signal);
|
|
3871
|
-
if (signal.aborted) return
|
|
4219
|
+
if (signal.aborted) return;
|
|
3872
4220
|
if ("code" in result && HOST_FAILURES.has(result.code)) hostFailure = result;
|
|
3873
4221
|
succeeded = this.settle(scope, source, host, filter, result) && succeeded;
|
|
3874
4222
|
if (repository === null && !("code" in result) && filter === "review-requested") {
|
|
3875
|
-
this.counts.set(
|
|
4223
|
+
this.counts.set(key, result.total);
|
|
3876
4224
|
this.publishCount();
|
|
3877
4225
|
}
|
|
3878
4226
|
this.publish(scope);
|
|
3879
4227
|
}
|
|
3880
|
-
|
|
3881
|
-
|
|
4228
|
+
const signIn = hostFailure?.code === "unauthenticated" ? await this.signInOf(scope, source, host, signal) : null;
|
|
4229
|
+
if (signal.aborted) return;
|
|
4230
|
+
const current = scope.hosts.get(key) ?? emptyHost(source, host);
|
|
4231
|
+
if (current.signIn !== signIn) {
|
|
4232
|
+
scope.hosts.set(key, {
|
|
4233
|
+
...current,
|
|
4234
|
+
signIn
|
|
4235
|
+
});
|
|
4236
|
+
this.publish(scope);
|
|
4237
|
+
}
|
|
4238
|
+
scope.schedule.settle(key, started, succeeded);
|
|
4239
|
+
}));
|
|
3882
4240
|
scope.reading = false;
|
|
3883
4241
|
if (!signal.aborted) this.publish(scope);
|
|
3884
|
-
return
|
|
4242
|
+
return scope.schedule.wait(targets.map((target) => target.key), Date.now());
|
|
3885
4243
|
}
|
|
3886
|
-
/**
|
|
3887
|
-
async
|
|
3888
|
-
|
|
3889
|
-
|
|
4244
|
+
/** The sign-in command the scope already holds for the host, else the one its provider names now, else null. */
|
|
4245
|
+
async signInOf(scope, source, host, signal) {
|
|
4246
|
+
const known = scope.hosts.get(hostKey(source.forge, host))?.signIn ?? null;
|
|
4247
|
+
if (known !== null) return known;
|
|
4248
|
+
const command = await this.read(() => this.sources.signIn(source.forge, host, signal), signal);
|
|
4249
|
+
return typeof command === "string" ? command : null;
|
|
4250
|
+
}
|
|
4251
|
+
/**
|
|
4252
|
+
* Read the count of every due host once, of every host when `forced`.
|
|
4253
|
+
* @returns milliseconds until the next host is due.
|
|
4254
|
+
*/
|
|
4255
|
+
async readCounts(signal, forced) {
|
|
4256
|
+
const started = Date.now();
|
|
4257
|
+
const targets = this.sources.sources().filter((source) => source.filters.has("review-requested")).flatMap((source) => source.hosts.map((host) => ({
|
|
4258
|
+
source,
|
|
4259
|
+
host,
|
|
4260
|
+
key: hostKey(source.forge, host)
|
|
4261
|
+
})));
|
|
4262
|
+
await Promise.all(targets.filter((target) => forced || this.countSchedule.due(target.key, started)).map(async ({ source, host, key }) => {
|
|
3890
4263
|
const result = await this.read(() => this.sources.count(source.forge, host, signal), signal);
|
|
3891
|
-
if (signal.aborted
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
4264
|
+
if (signal.aborted) return;
|
|
4265
|
+
if (!("code" in result)) {
|
|
4266
|
+
this.counts.set(key, result.get("review-requested") ?? 0);
|
|
4267
|
+
this.publishCount();
|
|
4268
|
+
}
|
|
4269
|
+
this.countSchedule.settle(key, started, !("code" in result));
|
|
4270
|
+
}));
|
|
4271
|
+
return this.countSchedule.wait(targets.map((target) => target.key), Date.now());
|
|
3896
4272
|
}
|
|
3897
4273
|
/** Run one read, turning a rejection into an `unavailable` failure and reporting it unless `signal` aborted. */
|
|
3898
4274
|
async read(run, signal) {
|
|
@@ -3969,6 +4345,7 @@ function emptyHost(source, host) {
|
|
|
3969
4345
|
forge: source.forge,
|
|
3970
4346
|
host,
|
|
3971
4347
|
viewer: null,
|
|
4348
|
+
signIn: null,
|
|
3972
4349
|
lists
|
|
3973
4350
|
};
|
|
3974
4351
|
}
|
|
@@ -4013,6 +4390,64 @@ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializ
|
|
|
4013
4390
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
4014
4391
|
done = true;
|
|
4015
4392
|
};
|
|
4393
|
+
var __addDisposableResource = function(env, value, async) {
|
|
4394
|
+
if (value !== null && value !== void 0) {
|
|
4395
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4396
|
+
var dispose, inner;
|
|
4397
|
+
if (async) {
|
|
4398
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
4399
|
+
dispose = value[Symbol.asyncDispose];
|
|
4400
|
+
}
|
|
4401
|
+
if (dispose === void 0) {
|
|
4402
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
4403
|
+
dispose = value[Symbol.dispose];
|
|
4404
|
+
if (async) inner = dispose;
|
|
4405
|
+
}
|
|
4406
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
4407
|
+
if (inner) dispose = function() {
|
|
4408
|
+
try {
|
|
4409
|
+
inner.call(this);
|
|
4410
|
+
} catch (e) {
|
|
4411
|
+
return Promise.reject(e);
|
|
4412
|
+
}
|
|
4413
|
+
};
|
|
4414
|
+
env.stack.push({
|
|
4415
|
+
value,
|
|
4416
|
+
dispose,
|
|
4417
|
+
async
|
|
4418
|
+
});
|
|
4419
|
+
} else if (async) env.stack.push({ async: true });
|
|
4420
|
+
return value;
|
|
4421
|
+
};
|
|
4422
|
+
var __disposeResources = (function(SuppressedError) {
|
|
4423
|
+
return function(env) {
|
|
4424
|
+
function fail(e) {
|
|
4425
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
4426
|
+
env.hasError = true;
|
|
4427
|
+
}
|
|
4428
|
+
var r, s = 0;
|
|
4429
|
+
function next() {
|
|
4430
|
+
while (r = env.stack.pop()) try {
|
|
4431
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
4432
|
+
if (r.dispose) {
|
|
4433
|
+
var result = r.dispose.call(r.value);
|
|
4434
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
4435
|
+
fail(e);
|
|
4436
|
+
return next();
|
|
4437
|
+
});
|
|
4438
|
+
} else s |= 1;
|
|
4439
|
+
} catch (e) {
|
|
4440
|
+
fail(e);
|
|
4441
|
+
}
|
|
4442
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
4443
|
+
if (env.hasError) throw env.error;
|
|
4444
|
+
}
|
|
4445
|
+
return next();
|
|
4446
|
+
};
|
|
4447
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
4448
|
+
var e = new Error(message);
|
|
4449
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4450
|
+
});
|
|
4016
4451
|
/**
|
|
4017
4452
|
* Serves the forge panel. Following a Session inspects the checkout of its
|
|
4018
4453
|
* current directory using the Session's permissions and execution world, recognizes the
|
|
@@ -4036,9 +4471,12 @@ let ForgePanelController = (() => {
|
|
|
4036
4471
|
let _reviewLists_decorators;
|
|
4037
4472
|
let _reviewCount_decorators;
|
|
4038
4473
|
let _reviewRefresh_decorators;
|
|
4474
|
+
let _hostReadiness_decorators;
|
|
4039
4475
|
let _reviewPoll_decorators;
|
|
4040
4476
|
let _reviewChangeRequest_decorators;
|
|
4041
4477
|
let _reviewDescription_decorators;
|
|
4478
|
+
let _reviewActivity_decorators;
|
|
4479
|
+
let _reviewComment_decorators;
|
|
4042
4480
|
let _reviewChecks_decorators;
|
|
4043
4481
|
let _reviewThreads_decorators;
|
|
4044
4482
|
let _reviewThreadWrite_decorators;
|
|
@@ -4050,6 +4488,7 @@ let ForgePanelController = (() => {
|
|
|
4050
4488
|
let _reviewSetViewed_decorators;
|
|
4051
4489
|
let _reviewMarkReady_decorators;
|
|
4052
4490
|
let _reviewMerge_decorators;
|
|
4491
|
+
let _reviewSetAutoMerge_decorators;
|
|
4053
4492
|
let _reviewRerunChecks_decorators;
|
|
4054
4493
|
let _reviewRequestReviews_decorators;
|
|
4055
4494
|
let _reviewReviewerCandidates_decorators;
|
|
@@ -4065,6 +4504,7 @@ let ForgePanelController = (() => {
|
|
|
4065
4504
|
let _localDiff_decorators;
|
|
4066
4505
|
let _localCommits_decorators;
|
|
4067
4506
|
let _localText_decorators;
|
|
4507
|
+
let _localWrite_decorators;
|
|
4068
4508
|
let _changeRequestChecks_decorators;
|
|
4069
4509
|
let _changeRequestCommits_decorators;
|
|
4070
4510
|
let _changeRequestDiff_decorators;
|
|
@@ -4078,6 +4518,7 @@ let ForgePanelController = (() => {
|
|
|
4078
4518
|
let _changeRequestReviewWrite_decorators;
|
|
4079
4519
|
let _markReady_decorators;
|
|
4080
4520
|
let _merge_decorators;
|
|
4521
|
+
let _setAutoMerge_decorators;
|
|
4081
4522
|
let _rerunChecks_decorators;
|
|
4082
4523
|
let _requestReviews_decorators;
|
|
4083
4524
|
let _reviewerCandidates_decorators;
|
|
@@ -4096,9 +4537,12 @@ let ForgePanelController = (() => {
|
|
|
4096
4537
|
_reviewLists_decorators = [Remote({ mode: "stream" })];
|
|
4097
4538
|
_reviewCount_decorators = [Remote({ mode: "stream" })];
|
|
4098
4539
|
_reviewRefresh_decorators = [Remote];
|
|
4540
|
+
_hostReadiness_decorators = [Remote];
|
|
4099
4541
|
_reviewPoll_decorators = [Remote];
|
|
4100
4542
|
_reviewChangeRequest_decorators = [Remote({ mode: "stream" })];
|
|
4101
4543
|
_reviewDescription_decorators = [Remote];
|
|
4544
|
+
_reviewActivity_decorators = [Remote];
|
|
4545
|
+
_reviewComment_decorators = [Remote];
|
|
4102
4546
|
_reviewChecks_decorators = [Remote];
|
|
4103
4547
|
_reviewThreads_decorators = [Remote];
|
|
4104
4548
|
_reviewThreadWrite_decorators = [Remote];
|
|
@@ -4110,6 +4554,7 @@ let ForgePanelController = (() => {
|
|
|
4110
4554
|
_reviewSetViewed_decorators = [Remote];
|
|
4111
4555
|
_reviewMarkReady_decorators = [Remote];
|
|
4112
4556
|
_reviewMerge_decorators = [Remote];
|
|
4557
|
+
_reviewSetAutoMerge_decorators = [Remote];
|
|
4113
4558
|
_reviewRerunChecks_decorators = [Remote];
|
|
4114
4559
|
_reviewRequestReviews_decorators = [Remote];
|
|
4115
4560
|
_reviewReviewerCandidates_decorators = [Remote];
|
|
@@ -4125,6 +4570,7 @@ let ForgePanelController = (() => {
|
|
|
4125
4570
|
_localDiff_decorators = [Remote];
|
|
4126
4571
|
_localCommits_decorators = [Remote];
|
|
4127
4572
|
_localText_decorators = [Remote];
|
|
4573
|
+
_localWrite_decorators = [Remote];
|
|
4128
4574
|
_changeRequestChecks_decorators = [Remote];
|
|
4129
4575
|
_changeRequestCommits_decorators = [Remote];
|
|
4130
4576
|
_changeRequestDiff_decorators = [Remote];
|
|
@@ -4138,6 +4584,7 @@ let ForgePanelController = (() => {
|
|
|
4138
4584
|
_changeRequestReviewWrite_decorators = [Remote];
|
|
4139
4585
|
_markReady_decorators = [Remote];
|
|
4140
4586
|
_merge_decorators = [Remote];
|
|
4587
|
+
_setAutoMerge_decorators = [Remote];
|
|
4141
4588
|
_rerunChecks_decorators = [Remote];
|
|
4142
4589
|
_requestReviews_decorators = [Remote];
|
|
4143
4590
|
_reviewerCandidates_decorators = [Remote];
|
|
@@ -4203,6 +4650,17 @@ let ForgePanelController = (() => {
|
|
|
4203
4650
|
},
|
|
4204
4651
|
metadata: _metadata
|
|
4205
4652
|
}, null, _instanceExtraInitializers);
|
|
4653
|
+
__esDecorate(this, null, _hostReadiness_decorators, {
|
|
4654
|
+
kind: "method",
|
|
4655
|
+
name: "hostReadiness",
|
|
4656
|
+
static: false,
|
|
4657
|
+
private: false,
|
|
4658
|
+
access: {
|
|
4659
|
+
has: (obj) => "hostReadiness" in obj,
|
|
4660
|
+
get: (obj) => obj.hostReadiness
|
|
4661
|
+
},
|
|
4662
|
+
metadata: _metadata
|
|
4663
|
+
}, null, _instanceExtraInitializers);
|
|
4206
4664
|
__esDecorate(this, null, _reviewPoll_decorators, {
|
|
4207
4665
|
kind: "method",
|
|
4208
4666
|
name: "reviewPoll",
|
|
@@ -4236,6 +4694,28 @@ let ForgePanelController = (() => {
|
|
|
4236
4694
|
},
|
|
4237
4695
|
metadata: _metadata
|
|
4238
4696
|
}, null, _instanceExtraInitializers);
|
|
4697
|
+
__esDecorate(this, null, _reviewActivity_decorators, {
|
|
4698
|
+
kind: "method",
|
|
4699
|
+
name: "reviewActivity",
|
|
4700
|
+
static: false,
|
|
4701
|
+
private: false,
|
|
4702
|
+
access: {
|
|
4703
|
+
has: (obj) => "reviewActivity" in obj,
|
|
4704
|
+
get: (obj) => obj.reviewActivity
|
|
4705
|
+
},
|
|
4706
|
+
metadata: _metadata
|
|
4707
|
+
}, null, _instanceExtraInitializers);
|
|
4708
|
+
__esDecorate(this, null, _reviewComment_decorators, {
|
|
4709
|
+
kind: "method",
|
|
4710
|
+
name: "reviewComment",
|
|
4711
|
+
static: false,
|
|
4712
|
+
private: false,
|
|
4713
|
+
access: {
|
|
4714
|
+
has: (obj) => "reviewComment" in obj,
|
|
4715
|
+
get: (obj) => obj.reviewComment
|
|
4716
|
+
},
|
|
4717
|
+
metadata: _metadata
|
|
4718
|
+
}, null, _instanceExtraInitializers);
|
|
4239
4719
|
__esDecorate(this, null, _reviewChecks_decorators, {
|
|
4240
4720
|
kind: "method",
|
|
4241
4721
|
name: "reviewChecks",
|
|
@@ -4357,6 +4837,17 @@ let ForgePanelController = (() => {
|
|
|
4357
4837
|
},
|
|
4358
4838
|
metadata: _metadata
|
|
4359
4839
|
}, null, _instanceExtraInitializers);
|
|
4840
|
+
__esDecorate(this, null, _reviewSetAutoMerge_decorators, {
|
|
4841
|
+
kind: "method",
|
|
4842
|
+
name: "reviewSetAutoMerge",
|
|
4843
|
+
static: false,
|
|
4844
|
+
private: false,
|
|
4845
|
+
access: {
|
|
4846
|
+
has: (obj) => "reviewSetAutoMerge" in obj,
|
|
4847
|
+
get: (obj) => obj.reviewSetAutoMerge
|
|
4848
|
+
},
|
|
4849
|
+
metadata: _metadata
|
|
4850
|
+
}, null, _instanceExtraInitializers);
|
|
4360
4851
|
__esDecorate(this, null, _reviewRerunChecks_decorators, {
|
|
4361
4852
|
kind: "method",
|
|
4362
4853
|
name: "reviewRerunChecks",
|
|
@@ -4522,6 +5013,17 @@ let ForgePanelController = (() => {
|
|
|
4522
5013
|
},
|
|
4523
5014
|
metadata: _metadata
|
|
4524
5015
|
}, null, _instanceExtraInitializers);
|
|
5016
|
+
__esDecorate(this, null, _localWrite_decorators, {
|
|
5017
|
+
kind: "method",
|
|
5018
|
+
name: "localWrite",
|
|
5019
|
+
static: false,
|
|
5020
|
+
private: false,
|
|
5021
|
+
access: {
|
|
5022
|
+
has: (obj) => "localWrite" in obj,
|
|
5023
|
+
get: (obj) => obj.localWrite
|
|
5024
|
+
},
|
|
5025
|
+
metadata: _metadata
|
|
5026
|
+
}, null, _instanceExtraInitializers);
|
|
4525
5027
|
__esDecorate(this, null, _changeRequestChecks_decorators, {
|
|
4526
5028
|
kind: "method",
|
|
4527
5029
|
name: "changeRequestChecks",
|
|
@@ -4665,6 +5167,17 @@ let ForgePanelController = (() => {
|
|
|
4665
5167
|
},
|
|
4666
5168
|
metadata: _metadata
|
|
4667
5169
|
}, null, _instanceExtraInitializers);
|
|
5170
|
+
__esDecorate(this, null, _setAutoMerge_decorators, {
|
|
5171
|
+
kind: "method",
|
|
5172
|
+
name: "setAutoMerge",
|
|
5173
|
+
static: false,
|
|
5174
|
+
private: false,
|
|
5175
|
+
access: {
|
|
5176
|
+
has: (obj) => "setAutoMerge" in obj,
|
|
5177
|
+
get: (obj) => obj.setAutoMerge
|
|
5178
|
+
},
|
|
5179
|
+
metadata: _metadata
|
|
5180
|
+
}, null, _instanceExtraInitializers);
|
|
4668
5181
|
__esDecorate(this, null, _rerunChecks_decorators, {
|
|
4669
5182
|
kind: "method",
|
|
4670
5183
|
name: "rerunChecks",
|
|
@@ -4899,6 +5412,10 @@ let ForgePanelController = (() => {
|
|
|
4899
5412
|
sources: () => ctx.forge.viewerSources(),
|
|
4900
5413
|
list: async (forge, query, signal) => await ctx.forge.listForViewer(forge, query, signal),
|
|
4901
5414
|
count: async (forge, host, signal) => await ctx.forge.countForViewer(forge, host, signal),
|
|
5415
|
+
signIn: async (forge, host, signal) => (await ctx.forge.readiness({
|
|
5416
|
+
forge,
|
|
5417
|
+
host
|
|
5418
|
+
}, signal)).signIn?.command ?? null,
|
|
4902
5419
|
report: (error) => {
|
|
4903
5420
|
ctx.logger.warn(`forge-panel: reading a review list failed: ${String(error)}`);
|
|
4904
5421
|
}
|
|
@@ -4993,9 +5510,11 @@ let ForgePanelController = (() => {
|
|
|
4993
5510
|
/**
|
|
4994
5511
|
* Stream the review page's lists of the signed-in user's open change requests on every host a provider lists them on:
|
|
4995
5512
|
* the lists read so far first, then a frame after each read settles. Readers of one repository scope share one
|
|
4996
|
-
* reader, which reads every `reviewListIntervalMs` while some stream lasts and
|
|
4997
|
-
*
|
|
4998
|
-
*
|
|
5513
|
+
* reader, which reads each host every `reviewListIntervalMs` while some stream lasts and reads a host whose read failed
|
|
5514
|
+
* again later each time, up to `reviewMaxBackoffMs`, without delaying the other hosts; nothing is read while no stream
|
|
5515
|
+
* lasts. The stream ends when `signal` aborts or the Remote stops.
|
|
5516
|
+
* @param repository - one repository to list in, read on its host only, or null for every repository the user can
|
|
5517
|
+
* read on every host.
|
|
4999
5518
|
* @param signal - ends the stream.
|
|
5000
5519
|
* @returns frames, each complete.
|
|
5001
5520
|
*/
|
|
@@ -5021,6 +5540,45 @@ let ForgePanelController = (() => {
|
|
|
5021
5540
|
this.viewerLists.refresh();
|
|
5022
5541
|
}
|
|
5023
5542
|
/**
|
|
5543
|
+
* Report whether a provider reaches one of its hosts with the Host's current credentials, for the host list on the
|
|
5544
|
+
* Plugins page of that provider's row. The read names no Session, so, like the review page reads, only callers that
|
|
5545
|
+
* may use the Host's code host credentials reach it.
|
|
5546
|
+
* @param forge - forge family of a registered provider, such as `gitlab`.
|
|
5547
|
+
* @param host - host name as the provider's configuration lists it.
|
|
5548
|
+
* @param signal - request cancellation.
|
|
5549
|
+
* @returns the provider's readiness for the host; `unavailable` with the reason when no provider serves the family,
|
|
5550
|
+
* the probe fails, or it runs past `readinessTimeoutMs`.
|
|
5551
|
+
*/
|
|
5552
|
+
async hostReadiness(forge, host, signal) {
|
|
5553
|
+
signal.throwIfAborted();
|
|
5554
|
+
try {
|
|
5555
|
+
const env_1 = {
|
|
5556
|
+
stack: [],
|
|
5557
|
+
error: void 0,
|
|
5558
|
+
hasError: false
|
|
5559
|
+
};
|
|
5560
|
+
try {
|
|
5561
|
+
const timeout = __addDisposableResource(env_1, deadline(signal, this.config.readinessTimeoutMs, "FORGE_PANEL_READINESS_TIMEOUT"), false);
|
|
5562
|
+
return await this.home.forge.readiness({
|
|
5563
|
+
forge,
|
|
5564
|
+
host: host.toLowerCase()
|
|
5565
|
+
}, timeout.signal);
|
|
5566
|
+
} catch (e_1) {
|
|
5567
|
+
env_1.error = e_1;
|
|
5568
|
+
env_1.hasError = true;
|
|
5569
|
+
} finally {
|
|
5570
|
+
__disposeResources(env_1);
|
|
5571
|
+
}
|
|
5572
|
+
} catch (error) {
|
|
5573
|
+
signal.throwIfAborted();
|
|
5574
|
+
return {
|
|
5575
|
+
state: "unavailable",
|
|
5576
|
+
message: messageOf(error),
|
|
5577
|
+
signIn: null
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
/**
|
|
5024
5582
|
* Poll one change request the review page shows at once; its stream reports the result.
|
|
5025
5583
|
* @param url - web URL of the change request.
|
|
5026
5584
|
* @param signal - request cancellation.
|
|
@@ -5092,6 +5650,37 @@ let ForgePanelController = (() => {
|
|
|
5092
5650
|
return result;
|
|
5093
5651
|
}
|
|
5094
5652
|
/**
|
|
5653
|
+
* Read the activity of a change request for the review page: its comments, submitted reviews, commits, and changes
|
|
5654
|
+
* of state.
|
|
5655
|
+
* @param url - web URL of the change request.
|
|
5656
|
+
* @param signal - request cancellation.
|
|
5657
|
+
* @returns the activity, or null when the change request's provider reads none.
|
|
5658
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/activity-failed` with the
|
|
5659
|
+
* host's reason when the host does not provide it.
|
|
5660
|
+
*/
|
|
5661
|
+
async reviewActivity(url, signal) {
|
|
5662
|
+
signal.throwIfAborted();
|
|
5663
|
+
const result = await this.home.forge.readActivity(this.served(url).ref, signal);
|
|
5664
|
+
if (!("code" in result)) return result;
|
|
5665
|
+
if (result.code === "unsupported") return null;
|
|
5666
|
+
throw new RemoteError("forgePanel/activity-failed", result.message, {});
|
|
5667
|
+
}
|
|
5668
|
+
/**
|
|
5669
|
+
* Add a comment to the conversation of a change request the review page shows.
|
|
5670
|
+
* @param url - web URL of the change request.
|
|
5671
|
+
* @param body - Markdown source of the comment.
|
|
5672
|
+
* @param signal - request cancellation.
|
|
5673
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` when `body` is
|
|
5674
|
+
* blank, or with the host's reason; `forgePanel/action-unknown` when the host's answer did not confirm the comment.
|
|
5675
|
+
*/
|
|
5676
|
+
async reviewComment(url, body, signal) {
|
|
5677
|
+
signal.throwIfAborted();
|
|
5678
|
+
const { ref } = this.served(url);
|
|
5679
|
+
if (body.trim() === "") throw new RemoteError("forgePanel/action-failed", "The comment is empty", {});
|
|
5680
|
+
const failure = await this.home.forge.addComment(ref, body, signal);
|
|
5681
|
+
if (failure !== void 0) throw actionError(failure);
|
|
5682
|
+
}
|
|
5683
|
+
/**
|
|
5095
5684
|
* Read every check of a change request the review page shows.
|
|
5096
5685
|
* @param url - web URL of the change request.
|
|
5097
5686
|
* @param headSha - head commit whose checks the page shows.
|
|
@@ -5143,9 +5732,9 @@ let ForgePanelController = (() => {
|
|
|
5143
5732
|
return await this.publishReview(this.served(url).ref, request, signal);
|
|
5144
5733
|
}
|
|
5145
5734
|
/**
|
|
5146
|
-
* Read the changes of a change request the review page shows,
|
|
5735
|
+
* Read the changes of a change request the review page shows, of consecutive commits of it, or of it up to one commit.
|
|
5147
5736
|
* @param url - web URL of the change request.
|
|
5148
|
-
* @param commits - consecutive commits of the change request, or null for all of it.
|
|
5737
|
+
* @param commits - consecutive commits of the change request, the commit its changes go up to, or null for all of it.
|
|
5149
5738
|
* @param signal - request cancellation.
|
|
5150
5739
|
* @returns the files and the commit they end at, without a local checkout count.
|
|
5151
5740
|
* @throws as {@link ForgePanelController.changeRequestDiff} does, with `forgePanel/unrecognized-url` in place of
|
|
@@ -5242,6 +5831,20 @@ let ForgePanelController = (() => {
|
|
|
5242
5831
|
if (failure !== void 0) throw actionError(failure);
|
|
5243
5832
|
}
|
|
5244
5833
|
/**
|
|
5834
|
+
* Turn the code host's automatic merge of a change request the review page shows on, while its head is still the
|
|
5835
|
+
* request's `headSha`, or off.
|
|
5836
|
+
* @param url - web URL of the change request.
|
|
5837
|
+
* @param request - on with the merge method and the head commit the user confirmed, or off.
|
|
5838
|
+
* @param signal - request cancellation.
|
|
5839
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
|
|
5840
|
+
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
|
|
5841
|
+
*/
|
|
5842
|
+
async reviewSetAutoMerge(url, request, signal) {
|
|
5843
|
+
signal.throwIfAborted();
|
|
5844
|
+
const failure = await this.home.forge.setAutoMerge(this.served(url).ref, request, signal);
|
|
5845
|
+
if (failure !== void 0) throw actionError(failure);
|
|
5846
|
+
}
|
|
5847
|
+
/**
|
|
5245
5848
|
* Rerun the failed checks of a change request the review page shows.
|
|
5246
5849
|
* @param url - web URL of the change request.
|
|
5247
5850
|
* @param request - the head commit whose checks the user saw.
|
|
@@ -5347,21 +5950,26 @@ let ForgePanelController = (() => {
|
|
|
5347
5950
|
])).stdout, inspection.checkout.branch, remoteOrder(inspection.upstream, inspection.remotes), query, this.config.maxBranches, (remote) => remoteRepository(remote, (url) => this.home.forge.repositoryFromRemote(url)));
|
|
5348
5951
|
}
|
|
5349
5952
|
/**
|
|
5350
|
-
* List the branches the `branch` scope
|
|
5953
|
+
* List the branches the `branch` scope can compare with, for the Session's current checkout or for a head branch
|
|
5954
|
+
* read in its place.
|
|
5351
5955
|
* @param session - Session whose checkout is read.
|
|
5956
|
+
* @param head - full ref of the branch the scope reads in place of the checked-out one, or null for the checkout.
|
|
5352
5957
|
* @param query - text the branch names must contain, ignoring case; empty for every branch.
|
|
5353
5958
|
* @param signal - request cancellation.
|
|
5354
5959
|
* @returns the automatic fork point and at most `maxBranches` remote-tracking and local branches each,
|
|
5355
|
-
* most recently committed first, without the
|
|
5356
|
-
*
|
|
5960
|
+
* most recently committed first, without the branch the scope shows and, for a head, without the Session's
|
|
5961
|
+
* checked-out branch, which the automatic fork point compares with; a local branch that a worktree has checked
|
|
5962
|
+
* out names that worktree's directory.
|
|
5963
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head does not exist; the
|
|
5964
|
+
* Git error when Git fails or the listed refs exceed `maxDiffBytes`.
|
|
5357
5965
|
*/
|
|
5358
|
-
async diffBases(session, query, signal) {
|
|
5966
|
+
async diffBases(session, head, query, signal) {
|
|
5359
5967
|
signal.throwIfAborted();
|
|
5360
|
-
const inspection = await this.
|
|
5968
|
+
const { inspection, created, tip, against } = await this.localTarget(session, head, false, signal);
|
|
5361
5969
|
return await baseBranches(gitIn(this.home, {
|
|
5362
5970
|
...this.config,
|
|
5363
5971
|
maxOutputBytes: this.config.maxDiffBytes
|
|
5364
|
-
}, session, inspection.checkout.root, signal), inspection,
|
|
5972
|
+
}, session, inspection.checkout.root, signal), inspection, created, query, this.config.maxBranches, tip, against);
|
|
5365
5973
|
}
|
|
5366
5974
|
/**
|
|
5367
5975
|
* Bind a change request to a Session by URL, or restore a dismissed binding.
|
|
@@ -5410,13 +6018,15 @@ let ForgePanelController = (() => {
|
|
|
5410
6018
|
for (const [session, panel] of this.panels) if (session.id === sessionId) await panel.revisit();
|
|
5411
6019
|
}
|
|
5412
6020
|
/**
|
|
5413
|
-
* Read the changes one scope covers in the checkout of the Session's
|
|
5414
|
-
*
|
|
6021
|
+
* Read the changes one scope covers in the checkout of the Session's current directory, or for the head branch the
|
|
6022
|
+
* scope names: in the worktree that has it checked out, else from its commits. Git uses the Session's sandbox policy.
|
|
5415
6023
|
* @param session - Session whose checkout is read.
|
|
5416
6024
|
* @param scope - which changes to read.
|
|
5417
6025
|
* @param signal - request cancellation.
|
|
5418
|
-
* @returns the files, the base of the `branch` scope,
|
|
5419
|
-
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/
|
|
6026
|
+
* @returns the files, the base of the `branch` scope, the untracked files left out, and the worktree read for a head.
|
|
6027
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head the scope names
|
|
6028
|
+
* does not exist; `forgePanel/no-working-tree` for another scope than `branch` whose head no worktree has checked
|
|
6029
|
+
* out; `forgePanel/base-missing` when the base branch
|
|
5420
6030
|
* chosen for the `branch` scope does not exist; `forgePanel/no-fork-point` for the `branch` scope without
|
|
5421
6031
|
* a fork point; `forgePanel/commits-missing` when chosen commits are not between the fork point and HEAD in order;
|
|
5422
6032
|
* `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
|
|
@@ -5425,52 +6035,85 @@ let ForgePanelController = (() => {
|
|
|
5425
6035
|
*/
|
|
5426
6036
|
async localDiff(session, scope, signal) {
|
|
5427
6037
|
signal.throwIfAborted();
|
|
5428
|
-
const inspection = await this.
|
|
6038
|
+
const { inspection, created, tip, worktree, against } = await this.localTarget(session, scope.head ?? null, scope.kind !== "branch", signal);
|
|
5429
6039
|
const root = inspection.checkout.root;
|
|
5430
6040
|
const git = gitIn(this.home, this.config, session, root, signal);
|
|
5431
|
-
const
|
|
5432
|
-
const
|
|
5433
|
-
return
|
|
6041
|
+
const fork = scope.kind !== "branch" ? null : await diffing(scope.base === null ? forkPoint(git, inspection, created, tip, against) : chosenForkPoint(git, scope.base, tip));
|
|
6042
|
+
const diff = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal, tip));
|
|
6043
|
+
return worktree === null ? diff : {
|
|
6044
|
+
...diff,
|
|
6045
|
+
worktree
|
|
6046
|
+
};
|
|
5434
6047
|
}
|
|
5435
6048
|
/**
|
|
5436
|
-
* List the commits of the `branch` scope of the Session's current checkout
|
|
5437
|
-
* several of instead of the whole scope.
|
|
6049
|
+
* List the commits of the `branch` scope of the Session's current checkout or of a head branch read in its place,
|
|
6050
|
+
* which the changes view can show one or several of instead of the whole scope.
|
|
5438
6051
|
* @param session - Session whose checkout is read.
|
|
6052
|
+
* @param head - full ref of the branch the scope reads in place of the checked-out one, or null for the checkout.
|
|
5439
6053
|
* @param base - the base ref of the `branch` scope, or null for its automatic fork point.
|
|
5440
6054
|
* @param signal - request cancellation.
|
|
5441
|
-
* @returns the newest `maxCommits` commits between the fork point and HEAD, oldest first, and
|
|
5442
|
-
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/
|
|
5443
|
-
* exist; `forgePanel/no-fork-point` without a fork point;
|
|
6055
|
+
* @returns the newest `maxCommits` commits between the fork point and the shown HEAD or branch, oldest first, and its commit.
|
|
6056
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the head does not exist;
|
|
6057
|
+
* `forgePanel/base-missing` when the base branch does not exist; `forgePanel/no-fork-point` without a fork point;
|
|
6058
|
+
* the Git error when Git fails or the listing exceeds `maxDiffBytes`.
|
|
5444
6059
|
*/
|
|
5445
|
-
async localCommits(session, base, signal) {
|
|
6060
|
+
async localCommits(session, head, base, signal) {
|
|
5446
6061
|
signal.throwIfAborted();
|
|
5447
|
-
const inspection = await this.
|
|
6062
|
+
const { inspection, created, tip, against } = await this.localTarget(session, head, false, signal);
|
|
5448
6063
|
const git = gitIn(this.home, {
|
|
5449
6064
|
...this.config,
|
|
5450
6065
|
maxOutputBytes: this.config.maxDiffBytes
|
|
5451
6066
|
}, session, inspection.checkout.root, signal);
|
|
5452
|
-
const
|
|
5453
|
-
const fork = await diffing(base === null ? forkPoint(git, inspection, created) : chosenForkPoint(git, base));
|
|
6067
|
+
const fork = await diffing(base === null ? forkPoint(git, inspection, created, tip, against) : chosenForkPoint(git, base, tip));
|
|
5454
6068
|
if (fork === null) throw new RemoteError("forgePanel/no-fork-point", "The checkout has no fork point to compare its branch with", {});
|
|
5455
|
-
return await localCommits(git, fork, this.config.maxCommits);
|
|
6069
|
+
return await localCommits(git, fork, this.config.maxCommits, tip);
|
|
5456
6070
|
}
|
|
5457
6071
|
/**
|
|
5458
6072
|
* Read the new side of one changed file in a scope, which supplies the
|
|
5459
6073
|
* unchanged lines between its hunks: the index for `staged`, the last chosen commit for chosen commits of
|
|
5460
|
-
* the `branch` scope, else the working tree.
|
|
6074
|
+
* the `branch` scope, the branch for a head read from its commits, else the working tree of the checkout the scope reads.
|
|
5461
6075
|
* @param session - Session whose checkout is read.
|
|
5462
6076
|
* @param scope - the scope the diff was read in.
|
|
5463
6077
|
* @param path - path relative to the checkout's top-level directory, as the diff names it.
|
|
5464
6078
|
* @param signal - request cancellation.
|
|
5465
6079
|
* @returns the text.
|
|
5466
|
-
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/
|
|
6080
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` and `forgePanel/no-working-tree`
|
|
6081
|
+
* as for {@link ForgePanelController.localDiff}; `forgePanel/diff-too-large` over `maxDiffBytes`;
|
|
5467
6082
|
* `forgePanel/commits-missing` for a chosen commit that is not a full object name; an error for a path outside
|
|
5468
6083
|
* the checkout, binary content, or a failed read.
|
|
5469
6084
|
*/
|
|
5470
6085
|
async localText(session, scope, path, signal) {
|
|
6086
|
+
signal.throwIfAborted();
|
|
6087
|
+
const { inspection, tip } = await this.localTarget(session, scope.head ?? null, scope.kind !== "branch", signal);
|
|
6088
|
+
return await diffing(localText(this.home, this.config, session, inspection.checkout.root, scope, path, signal, tip));
|
|
6089
|
+
}
|
|
6090
|
+
/**
|
|
6091
|
+
* Stage, unstage, or restore whole files in the checkout of the Session's current directory, or return index
|
|
6092
|
+
* entries to the tree an earlier write reported. The caller's press authorizes the write, so Git runs without the
|
|
6093
|
+
* Session's sandbox policy and under any access mode. The Session's panel inspects the checkout again afterwards,
|
|
6094
|
+
* whether or not the write succeeded.
|
|
6095
|
+
* @param session - Session whose checkout is written.
|
|
6096
|
+
* @param write - the write; `stage` and `restore` name each file with the digest of the change the reader saw.
|
|
6097
|
+
* @param signal - request cancellation.
|
|
6098
|
+
* @returns the index before a `stage` or `unstage` as a tree, for undoing it.
|
|
6099
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/local-stale` before anything is written when a
|
|
6100
|
+
* file's unstaged change is not the one the reader saw; `forgePanel/local-path-replaced` before anything is written
|
|
6101
|
+
* when a deleted file's path holds a directory; the errors of {@link ForgePanelController.localDiff} for the
|
|
6102
|
+
* `unstaged` scope; an error for a path outside the checkout, a tree that is not a full object name, a restore of a
|
|
6103
|
+
* submodule or of a file without index content, or a Git failure.
|
|
6104
|
+
*/
|
|
6105
|
+
async localWrite(session, write, signal) {
|
|
5471
6106
|
signal.throwIfAborted();
|
|
5472
6107
|
const inspection = await this.checkoutOf(session, signal);
|
|
5473
|
-
|
|
6108
|
+
try {
|
|
6109
|
+
return await diffing(localWrite(this.home, this.config, session, inspection.checkout.root, write, this.layers, signal));
|
|
6110
|
+
} catch (error) {
|
|
6111
|
+
if (error instanceof LocalChangesStale) throw new RemoteError("forgePanel/local-stale", error.message, {}, { cause: error });
|
|
6112
|
+
if (error instanceof LocalPathReplaced) throw new RemoteError("forgePanel/local-path-replaced", error.message, {}, { cause: error });
|
|
6113
|
+
throw error;
|
|
6114
|
+
} finally {
|
|
6115
|
+
this.panels.get(session)?.reinspect();
|
|
6116
|
+
}
|
|
5474
6117
|
}
|
|
5475
6118
|
/**
|
|
5476
6119
|
* Load complete checks for the change request whose list the user opened.
|
|
@@ -5510,20 +6153,25 @@ let ForgePanelController = (() => {
|
|
|
5510
6153
|
* of the commit the diff ends at. Without `commits` the diff covers the change
|
|
5511
6154
|
* request at the head commit of its latest status; a patch already read at the
|
|
5512
6155
|
* same head commit and base branch is reused from memory with its attributes, for
|
|
5513
|
-
* any Session, until `maxCachedDiffBytes` evicts it. With `commits`, it covers those
|
|
5514
|
-
* commits, from the first one's first parent to the last
|
|
6156
|
+
* any Session, until `maxCachedDiffBytes` evicts it. With consecutive `commits`, it covers those
|
|
6157
|
+
* commits, from the first one's first parent to the last; with `commits` up to one commit, it covers
|
|
6158
|
+
* the change request as that commit ended it, from the merge base of the status's base commit with
|
|
6159
|
+
* that commit, which the host reads by name whether or not the change request still lists it. Either
|
|
6160
|
+
* is read every time.
|
|
5515
6161
|
* @param session - Session the change request is bound to.
|
|
5516
6162
|
* @param url - binding URL of the change request.
|
|
5517
|
-
* @param commits - consecutive commits of the change request, or null for all of it.
|
|
6163
|
+
* @param commits - consecutive commits of the change request, the commit its changes go up to, or null for all of it.
|
|
5518
6164
|
* @param signal - request cancellation.
|
|
5519
6165
|
* @returns the files, the commit they end at, each file's web page, and the commits the checkout has beyond the head.
|
|
5520
6166
|
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
5521
|
-
* `forgePanel/commits-missing` when chosen commits are not among the change request's commits in order
|
|
6167
|
+
* `forgePanel/commits-missing` when chosen commits are not among the change request's commits in order, and for a
|
|
6168
|
+
* commit to go up to that is not a full object name or that the host does not have;
|
|
5522
6169
|
* `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
|
|
5523
6170
|
* `forgePanel/stale-head` without `commits` when the head moved past the latest status, which is then polled again;
|
|
5524
6171
|
* `forgePanel/diff-too-large` when the host or its provider refuses the diff over a size limit;
|
|
5525
|
-
* `forgePanel/diff-failed` before its status was read, for a first chosen commit without a parent,
|
|
5526
|
-
*
|
|
6172
|
+
* `forgePanel/diff-failed` before its status was read, for a first chosen commit without a parent, for changes up
|
|
6173
|
+
* to a commit while the status names no base commit, and when the host does not provide the commits, the merge
|
|
6174
|
+
* base, the diff, or an existing `.gitattributes` otherwise.
|
|
5527
6175
|
*/
|
|
5528
6176
|
async changeRequestDiff(session, url, commits, signal) {
|
|
5529
6177
|
signal.throwIfAborted();
|
|
@@ -5758,6 +6406,23 @@ let ForgePanelController = (() => {
|
|
|
5758
6406
|
if (failure !== void 0) throw actionError(failure);
|
|
5759
6407
|
}
|
|
5760
6408
|
/**
|
|
6409
|
+
* Turn the code host's automatic merge of a change request of a Session on, while its head is still the request's
|
|
6410
|
+
* `headSha`, or off; the change request is polled again once the host answers.
|
|
6411
|
+
* @param session - Session the change request is bound to.
|
|
6412
|
+
* @param url - binding URL of the change request.
|
|
6413
|
+
* @param request - on with the merge method and the head commit the user confirmed, or off.
|
|
6414
|
+
* @param signal - request cancellation.
|
|
6415
|
+
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
6416
|
+
* `forgePanel/stale-head` when the head moved past the request's `headSha`; `forgePanel/action-failed` with the
|
|
6417
|
+
* host's reason when the host refuses otherwise, cannot be reached, or sets no automatic merge;
|
|
6418
|
+
* `forgePanel/action-unknown` when the host's answer did not confirm the change.
|
|
6419
|
+
*/
|
|
6420
|
+
async setAutoMerge(session, url, request, signal) {
|
|
6421
|
+
signal.throwIfAborted();
|
|
6422
|
+
const failure = await this.home.forge.setAutoMerge(this.bound(session, url).ref, request, signal);
|
|
6423
|
+
if (failure !== void 0) throw actionError(failure);
|
|
6424
|
+
}
|
|
6425
|
+
/**
|
|
5761
6426
|
* Rerun the failed checks of a change request of a Session while its head is still the commit whose checks the user
|
|
5762
6427
|
* saw; the change request is polled again once the host answers.
|
|
5763
6428
|
* @param session - Session the change request is bound to.
|
|
@@ -6008,6 +6673,30 @@ let ForgePanelController = (() => {
|
|
|
6008
6673
|
};
|
|
6009
6674
|
}
|
|
6010
6675
|
/**
|
|
6676
|
+
* The files of a change request up to a commit, from the merge base of the status's base commit with it, which is
|
|
6677
|
+
* returned too. The provider reads that commit by name, so it may have left the change request's listed commits; a
|
|
6678
|
+
* commit the host does not have is refused as `forgePanel/commits-missing`.
|
|
6679
|
+
*/
|
|
6680
|
+
async filesUpTo(ref, snapshot, commit, signal) {
|
|
6681
|
+
if (!isCommit(commit)) throw new RemoteError("forgePanel/commits-missing", "The chosen commit is not a full object name", {});
|
|
6682
|
+
if (snapshot.baseSha === void 0) throw new RemoteError("forgePanel/diff-failed", "The code host provider reports no base commit to compare from", {});
|
|
6683
|
+
const base = await this.home.forge.mergeBase(ref, snapshot.baseSha, commit, signal);
|
|
6684
|
+
if (typeof base !== "string") throw upToError(base);
|
|
6685
|
+
const { patch, attributes } = await this.patchAt(ref, commit, async (operation) => {
|
|
6686
|
+
const compared = await this.home.forge.compare(ref, base, commit, operation);
|
|
6687
|
+
if (typeof compared !== "string") throw upToError(compared);
|
|
6688
|
+
return compared;
|
|
6689
|
+
}, signal);
|
|
6690
|
+
return {
|
|
6691
|
+
files: this.layers.classify(parseDiff(patch), attributes),
|
|
6692
|
+
parent: base
|
|
6693
|
+
};
|
|
6694
|
+
}
|
|
6695
|
+
/** The files of chosen commits of a change request with the commit their old side shows. */
|
|
6696
|
+
async chosenFiles(ref, snapshot, commits, signal) {
|
|
6697
|
+
return "upTo" in commits ? await this.filesUpTo(ref, snapshot, commits.upTo, signal) : await this.commitFiles(ref, commits, signal);
|
|
6698
|
+
}
|
|
6699
|
+
/**
|
|
6011
6700
|
* Read a patch that ends at `commit` together with the root `.gitattributes` at that commit. A failed patch read
|
|
6012
6701
|
* cancels the attributes read. Both reads end before the result: the patch's failure passes on first, and the
|
|
6013
6702
|
* attributes failure only after the patch was read, so the outcome does not depend on which read ends first.
|
|
@@ -6043,6 +6732,49 @@ let ForgePanelController = (() => {
|
|
|
6043
6732
|
if (attributes.code === "not-found") return "";
|
|
6044
6733
|
throw readError(attributes);
|
|
6045
6734
|
}
|
|
6735
|
+
/**
|
|
6736
|
+
* Resolve what a local read targets: the Session's own checkout with the worktree it created; for a head branch,
|
|
6737
|
+
* the worktree of the repository that has it checked out, read as a checkout; or, when none has, the verified
|
|
6738
|
+
* branch itself, read from its commits. A head branch also carries the Session's own HEAD, which is what it is
|
|
6739
|
+
* compared with while no base branch is chosen.
|
|
6740
|
+
* @param working - whether the read needs a working tree, as every scope but `branch` does.
|
|
6741
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/head-missing` when the branch does not exist;
|
|
6742
|
+
* `forgePanel/no-working-tree` when `working` and no worktree has the branch checked out.
|
|
6743
|
+
*/
|
|
6744
|
+
async localTarget(session, head, working, signal) {
|
|
6745
|
+
const own = await this.checkoutOf(session, signal);
|
|
6746
|
+
const ownTarget = {
|
|
6747
|
+
inspection: own,
|
|
6748
|
+
created: this.worktreeState(session).created,
|
|
6749
|
+
tip: "HEAD",
|
|
6750
|
+
worktree: null,
|
|
6751
|
+
against: null
|
|
6752
|
+
};
|
|
6753
|
+
if (head === null) return ownTarget;
|
|
6754
|
+
const git = gitIn(this.home, {
|
|
6755
|
+
...this.config,
|
|
6756
|
+
maxOutputBytes: this.config.maxDiffBytes
|
|
6757
|
+
}, session, own.checkout.root, signal);
|
|
6758
|
+
const tip = await diffing(branchTip(git, head));
|
|
6759
|
+
const against = await sessionHead(git, own.checkout);
|
|
6760
|
+
const directory = head.startsWith("refs/heads/") ? (await branchWorktrees(git)).get(head) : void 0;
|
|
6761
|
+
const inspection = directory === void 0 || await this.home.fs.lstat(directory, void 0, signal) === void 0 ? void 0 : await inspectCheckout(this.home, this.config, session, directory, signal);
|
|
6762
|
+
if (inspection?.commonDir === own.commonDir && inspection.checkout.branch === head.slice(11)) return inspection.checkout.root === own.checkout.root ? ownTarget : {
|
|
6763
|
+
inspection,
|
|
6764
|
+
created: null,
|
|
6765
|
+
tip: "HEAD",
|
|
6766
|
+
worktree: inspection.checkout.root,
|
|
6767
|
+
against
|
|
6768
|
+
};
|
|
6769
|
+
if (working) throw new RemoteError("forgePanel/no-working-tree", "No worktree has the branch checked out, so it has no working tree", {});
|
|
6770
|
+
return {
|
|
6771
|
+
inspection: own,
|
|
6772
|
+
created: null,
|
|
6773
|
+
tip,
|
|
6774
|
+
worktree: null,
|
|
6775
|
+
against
|
|
6776
|
+
};
|
|
6777
|
+
}
|
|
6046
6778
|
/** Inspect the checkout of the Session's current directory, which local diffs read. */
|
|
6047
6779
|
async checkoutOf(session, signal) {
|
|
6048
6780
|
const inspection = await inspectCheckout(this.home, this.config, session, this.home.workingDirectory.get(session), signal);
|
|
@@ -6057,18 +6789,18 @@ let ForgePanelController = (() => {
|
|
|
6057
6789
|
if (result.headSha !== headSha) throw new RemoteError("forgePanel/stale-head", "The change request head changed; refresh its status", {});
|
|
6058
6790
|
return result;
|
|
6059
6791
|
}
|
|
6060
|
-
/** Read the changes of a change request at the head of its latest status, or of chosen commits; `ahead` counts local commits. */
|
|
6792
|
+
/** Read the changes of a change request at the head of its latest status, or of its chosen commits; `ahead` counts local commits. */
|
|
6061
6793
|
async readDiff(target, commits, signal, ahead) {
|
|
6062
6794
|
const { ref, update } = target;
|
|
6063
6795
|
if (update === null || !("snapshot" in update)) throw new RemoteError("forgePanel/diff-failed", "The change request status has not been read yet", {});
|
|
6064
6796
|
if (commits !== null) {
|
|
6065
|
-
const { files } = await this.
|
|
6066
|
-
const
|
|
6797
|
+
const { files } = await this.chosenFiles(ref, update.snapshot, commits, signal);
|
|
6798
|
+
const end = lastOf(commits);
|
|
6067
6799
|
return {
|
|
6068
|
-
headSha:
|
|
6800
|
+
headSha: end,
|
|
6069
6801
|
files,
|
|
6070
6802
|
localAhead: null,
|
|
6071
|
-
fileUrls
|
|
6803
|
+
fileUrls: Object.fromEntries(files.map((file) => [file.path, this.home.forge.fileUrl(ref, end, file.path)]))
|
|
6072
6804
|
};
|
|
6073
6805
|
}
|
|
6074
6806
|
const { headSha, headBranch } = update.snapshot;
|
|
@@ -6223,7 +6955,7 @@ let ForgePanelController = (() => {
|
|
|
6223
6955
|
await work(agent, signal);
|
|
6224
6956
|
});
|
|
6225
6957
|
} catch (error) {
|
|
6226
|
-
throw new RemoteError("forgePanel/session-busy",
|
|
6958
|
+
throw new RemoteError("forgePanel/session-busy", `The Session is busy: ${messageOf(error)}`, {}, { cause: error });
|
|
6227
6959
|
}
|
|
6228
6960
|
await running;
|
|
6229
6961
|
}
|
|
@@ -6301,11 +7033,11 @@ let ForgePanelController = (() => {
|
|
|
6301
7033
|
/** The files a lens request names with their reader and the key results for them are kept under. */
|
|
6302
7034
|
async lensSubject(session, source, signal) {
|
|
6303
7035
|
if (source.kind === "local") {
|
|
6304
|
-
const inspection = await this.checkoutOf(session, signal);
|
|
6305
|
-
const root = inspection.checkout.root;
|
|
6306
7036
|
const { scope } = source;
|
|
6307
|
-
const
|
|
6308
|
-
const
|
|
7037
|
+
const { inspection, created, tip, against } = await this.localTarget(session, scope.head ?? null, scope.kind !== "branch", signal);
|
|
7038
|
+
const root = inspection.checkout.root;
|
|
7039
|
+
const fork = scope.kind !== "branch" ? null : await diffing(scope.base === null ? forkPoint(gitIn(this.home, this.config, session, root, signal), inspection, created, tip, against) : chosenForkPoint(gitIn(this.home, this.config, session, root, signal), scope.base, tip));
|
|
7040
|
+
const { files } = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal, tip));
|
|
6309
7041
|
return {
|
|
6310
7042
|
key: JSON.stringify([
|
|
6311
7043
|
"local",
|
|
@@ -6319,7 +7051,7 @@ let ForgePanelController = (() => {
|
|
|
6319
7051
|
files,
|
|
6320
7052
|
read: async (side, file, inner) => {
|
|
6321
7053
|
if (file.binary || (side === "old" ? file.status === "added" : file.status === "deleted")) return null;
|
|
6322
|
-
return side === "new" ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner)) : await diffing(localOldText(this.home, this.config, session, root, scope, fork, file.previousPath ?? file.path, inner));
|
|
7054
|
+
return side === "new" ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner, tip)) : await diffing(localOldText(this.home, this.config, session, root, scope, fork, file.previousPath ?? file.path, inner));
|
|
6323
7055
|
}
|
|
6324
7056
|
};
|
|
6325
7057
|
}
|
|
@@ -6330,6 +7062,8 @@ let ForgePanelController = (() => {
|
|
|
6330
7062
|
let files;
|
|
6331
7063
|
let newCommit;
|
|
6332
7064
|
let oldCommit;
|
|
7065
|
+
let shownHead = snapshot.headSha;
|
|
7066
|
+
let shownRange = null;
|
|
6333
7067
|
if (commits === null) {
|
|
6334
7068
|
files = await this.headFiles(ref, snapshot, signal);
|
|
6335
7069
|
newCommit = snapshot.headSha;
|
|
@@ -6344,10 +7078,12 @@ let ForgePanelController = (() => {
|
|
|
6344
7078
|
}
|
|
6345
7079
|
};
|
|
6346
7080
|
} else {
|
|
6347
|
-
const read = await this.
|
|
7081
|
+
const read = await this.chosenFiles(ref, snapshot, commits, signal);
|
|
6348
7082
|
files = read.files;
|
|
6349
|
-
newCommit = commits
|
|
7083
|
+
newCommit = lastOf(commits);
|
|
6350
7084
|
oldCommit = () => Promise.resolve(read.parent);
|
|
7085
|
+
if ("upTo" in commits) shownHead = commits.upTo;
|
|
7086
|
+
else shownRange = commits;
|
|
6351
7087
|
}
|
|
6352
7088
|
return {
|
|
6353
7089
|
key: JSON.stringify([
|
|
@@ -6359,8 +7095,8 @@ let ForgePanelController = (() => {
|
|
|
6359
7095
|
source: {
|
|
6360
7096
|
kind: "change",
|
|
6361
7097
|
ref,
|
|
6362
|
-
headSha:
|
|
6363
|
-
commits
|
|
7098
|
+
headSha: shownHead,
|
|
7099
|
+
commits: shownRange
|
|
6364
7100
|
},
|
|
6365
7101
|
files,
|
|
6366
7102
|
read: async (side, file, inner) => {
|
|
@@ -6399,6 +7135,14 @@ let ForgePanelController = (() => {
|
|
|
6399
7135
|
};
|
|
6400
7136
|
})();
|
|
6401
7137
|
/**
|
|
7138
|
+
* Name the commit that chosen commits of a change request end at.
|
|
7139
|
+
* @param commits - the chosen commits.
|
|
7140
|
+
* @returns the last commit's object name.
|
|
7141
|
+
*/
|
|
7142
|
+
function lastOf(commits) {
|
|
7143
|
+
return "upTo" in commits ? commits.upTo : commits.to;
|
|
7144
|
+
}
|
|
7145
|
+
/**
|
|
6402
7146
|
* Whether a value names a full commit object name.
|
|
6403
7147
|
* @param value - the value from the browser.
|
|
6404
7148
|
* @returns whether it is 40 or 64 hexadecimal digits.
|
|
@@ -6452,6 +7196,14 @@ function readError(failure) {
|
|
|
6452
7196
|
}
|
|
6453
7197
|
}
|
|
6454
7198
|
/**
|
|
7199
|
+
* Report why the code host did not provide the merge base or the diff of the changes up to a commit.
|
|
7200
|
+
* @param failure - the provider's failure.
|
|
7201
|
+
* @returns `forgePanel/commits-missing` when the host does not have the commit, else what {@link readError} reports.
|
|
7202
|
+
*/
|
|
7203
|
+
function upToError(failure) {
|
|
7204
|
+
return failure.code === "not-found" ? new RemoteError("forgePanel/commits-missing", failure.message, {}) : readError(failure);
|
|
7205
|
+
}
|
|
7206
|
+
/**
|
|
6455
7207
|
* Report why the code host did not provide review threads.
|
|
6456
7208
|
* @param failure - the provider's failure.
|
|
6457
7209
|
* @returns `forgePanel/stale-head` for a head that moved, `forgePanel/review-unsupported` for a provider without
|
|
@@ -6471,8 +7223,8 @@ function reviewError(failure) {
|
|
|
6471
7223
|
}
|
|
6472
7224
|
}
|
|
6473
7225
|
/**
|
|
6474
|
-
* Settle a diff read, reporting its size limit, its filter configuration, a missing fork point, a missing base branch,
|
|
6475
|
-
* commits that are not on the branch as Remote errors.
|
|
7226
|
+
* Settle a diff read, reporting its size limit, its filter configuration, a missing fork point, a missing base branch, a missing
|
|
7227
|
+
* head, and chosen commits that are not on the branch as Remote errors.
|
|
6476
7228
|
* @param reading - the read.
|
|
6477
7229
|
* @returns what the read returned.
|
|
6478
7230
|
*/
|
|
@@ -6484,6 +7236,7 @@ async function diffing(reading) {
|
|
|
6484
7236
|
if (error instanceof DiffTooLarge) throw new RemoteError("forgePanel/diff-too-large", error.message, {}, { cause: error });
|
|
6485
7237
|
if (error instanceof NoForkPoint) throw new RemoteError("forgePanel/no-fork-point", error.message, {}, { cause: error });
|
|
6486
7238
|
if (error instanceof BaseMissing) throw new RemoteError("forgePanel/base-missing", error.message, {}, { cause: error });
|
|
7239
|
+
if (error instanceof HeadMissing) throw new RemoteError("forgePanel/head-missing", error.message, {}, { cause: error });
|
|
6487
7240
|
if (error instanceof CommitsMissing) throw new RemoteError("forgePanel/commits-missing", error.message, {}, { cause: error });
|
|
6488
7241
|
if (error instanceof CommitsNotLinear) throw new RemoteError("forgePanel/commits-not-linear", error.message, {}, { cause: error });
|
|
6489
7242
|
throw error;
|