@firstpick/pi-package-webui 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEVELOPMENT.md +181 -12
- package/README.md +41 -9
- package/TECHNICAL.md +91 -8
- package/bin/pi-webui.mjs +5432 -11428
- package/index.ts +10 -3
- package/lib/codex-cli-usage.mjs +232 -0
- package/lib/codex-usage-auth.mjs +39 -3
- package/lib/codex-usage-source.mjs +36 -0
- package/lib/component-update-state.mjs +2 -2
- package/lib/git-workflow-preference-values.mjs +122 -0
- package/lib/git-workflow-preferences.mjs +35 -563
- package/lib/package-updates.mjs +260 -0
- package/lib/rpc-supervisor-client.mjs +8 -4
- package/lib/server/app-runners.mjs +1667 -0
- package/lib/server/codex-fast-mode.mjs +161 -0
- package/lib/server/conversation-mode.mjs +218 -0
- package/lib/server/conversation-voice.mjs +318 -0
- package/lib/server/extension-ui-requests.mjs +114 -0
- package/lib/server/git-generation.mjs +459 -0
- package/lib/server/git-mutations.mjs +1827 -0
- package/lib/server/git-reads.mjs +608 -0
- package/lib/server/git-worktree-sessions.mjs +408 -0
- package/lib/server/helper-requests.mjs +82 -0
- package/lib/server/no-project-workspaces.mjs +103 -0
- package/lib/server/rpc-transports.mjs +394 -0
- package/lib/server/settings-store.mjs +544 -0
- package/lib/server/sse-delivery.mjs +138 -0
- package/lib/server/workspace-files.mjs +563 -0
- package/lib/update/supervisor.mjs +4 -0
- package/lib/webui-workspaces.mjs +2 -0
- package/package.json +5 -5
- package/public/activity-agents-controller.mjs +269 -0
- package/public/activity-events-controller.mjs +236 -0
- package/public/activity-intercom-controller.mjs +627 -0
- package/public/activity-queue-controller.mjs +534 -0
- package/public/activity-todo-view.mjs +89 -0
- package/public/activity-usage-controller.mjs +589 -0
- package/public/app.js +3761 -3878
- package/public/conversation-overview.css +84 -0
- package/public/conversation-overview.mjs +193 -0
- package/public/draft-conversations.mjs +135 -0
- package/public/focused-composer-controls.css +111 -0
- package/public/focused-composer-controls.mjs +143 -0
- package/public/focused-composer-disclosure.mjs +223 -0
- package/public/focused-shell-adapter.css +264 -0
- package/public/focused-shell-adapter.mjs +257 -0
- package/public/index.html +137 -80
- package/public/model-catalog-order.mjs +63 -0
- package/public/platform-event-stream.mjs +64 -0
- package/public/project-artifact-controller.mjs +218 -0
- package/public/project-file-viewer-controller.mjs +383 -0
- package/public/project-git-tools-controller.mjs +181 -0
- package/public/project-runners-controller.mjs +220 -0
- package/public/service-worker.js +52 -1
- package/public/session-attention-scheduler.mjs +182 -0
- package/public/session-composer-store.mjs +56 -0
- package/public/session-context.mjs +51 -0
- package/public/session-extension-requests.mjs +63 -0
- package/public/session-shelf-state.mjs +151 -0
- package/public/session-shelves.css +171 -0
- package/public/session-shelves.mjs +95 -0
- package/public/settings-navigation-controller.mjs +249 -0
- package/public/settings-navigation.css +61 -0
- package/public/settings-resource-controller.mjs +232 -0
- package/public/settings-workspace.css +19 -0
- package/public/settings-workspace.mjs +175 -0
- package/public/shell-actions.mjs +87 -0
- package/public/shell-attention-inbox.css +72 -0
- package/public/shell-attention-inbox.mjs +198 -0
- package/public/shell-context-actions.css +61 -0
- package/public/shell-context-actions.mjs +168 -0
- package/public/shell-inspector-resize.mjs +124 -0
- package/public/shell-navigation-resize.mjs +107 -0
- package/public/shell-navigation.mjs +127 -0
- package/public/shell-preferences.mjs +108 -0
- package/public/shell-surfaces.mjs +99 -0
- package/public/shell-tools-launcher.css +97 -0
- package/public/shell-tools-launcher.mjs +222 -0
- package/public/shell-view-host.mjs +115 -0
- package/public/shell-workspace.css +266 -0
- package/public/shell-workspace.mjs +402 -0
- package/public/sidebar-update-menu.css +190 -0
- package/public/sidebar-update-menu.mjs +512 -0
- package/public/styles.css +320 -169
- package/public/subagent-launch-slot-state.mjs +2 -2
- package/public/theme-contract.mjs +1 -1
- package/public/themed-selects.css +156 -0
- package/public/workspace-choices.mjs +104 -0
- package/tests/activity-agents-controller.test.mjs +652 -0
- package/tests/activity-events-controller.test.mjs +511 -0
- package/tests/app-runner-terminal-static.test.mjs +3 -3
- package/tests/append-system-http.test.mjs +7 -6
- package/tests/append-system-selector-static.test.mjs +6 -6
- package/tests/aur-review-widget-static.test.mjs +11 -3
- package/tests/boot-failure-diagnostics.test.mjs +8 -3
- package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
- package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
- package/tests/browser/activity-owner-integration.spec.mjs +201 -0
- package/tests/browser/activity-queue-controller.spec.mjs +405 -0
- package/tests/browser/activity-section-picker.spec.mjs +294 -0
- package/tests/browser/activity-todo-view.spec.mjs +60 -0
- package/tests/browser/activity-usage-controller.spec.mjs +416 -0
- package/tests/browser/compact-layout-integration.spec.mjs +58 -0
- package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
- package/tests/browser/composer-disclosure.spec.mjs +389 -0
- package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
- package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
- package/tests/browser/control-visibility.spec.mjs +5 -0
- package/tests/browser/controls-layout.spec.mjs +21 -2
- package/tests/browser/conversation-overview.spec.mjs +251 -0
- package/tests/browser/draft-conversations.spec.mjs +276 -0
- package/tests/browser/empty-startup-fixture.mjs +135 -0
- package/tests/browser/empty-startup.spec.mjs +282 -0
- package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
- package/tests/browser/focused-composer-more.spec.mjs +127 -0
- package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
- package/tests/browser/focused-navigation-fixture.mjs +32 -0
- package/tests/browser/focused-project-activity.spec.mjs +111 -0
- package/tests/browser/focused-shell-integration.spec.mjs +208 -0
- package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
- package/tests/browser/folder-picker-layout.spec.mjs +302 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
- package/tests/browser/git-setup-cancel.spec.mjs +251 -0
- package/tests/browser/guided-git-fallback.spec.mjs +40 -21
- package/tests/browser/inspector-header.spec.mjs +221 -0
- package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
- package/tests/browser/inspector-resize.spec.mjs +227 -0
- package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
- package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
- package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
- package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
- package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
- package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
- package/tests/browser/interaction-continuity.spec.mjs +50 -26
- package/tests/browser/interaction-model-picker.spec.mjs +86 -0
- package/tests/browser/last-terminal-close.spec.mjs +280 -0
- package/tests/browser/mobile-foundation.spec.mjs +172 -20
- package/tests/browser/model-catalog-groups.spec.mjs +104 -0
- package/tests/browser/more-row-menus.spec.mjs +258 -0
- package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
- package/tests/browser/no-project-conversation.spec.mjs +113 -0
- package/tests/browser/optimistic-prompt.spec.mjs +3 -0
- package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
- package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
- package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
- package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
- package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
- package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
- package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
- package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
- package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
- package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
- package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
- package/tests/browser/project-artifact-controller.spec.mjs +324 -0
- package/tests/browser/project-artifact-integration.spec.mjs +103 -0
- package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
- package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
- package/tests/browser/session-fixture.mjs +118 -0
- package/tests/browser/session-ownership.spec.mjs +175 -0
- package/tests/browser/session-shelves-integration.spec.mjs +219 -0
- package/tests/browser/session-shelves.spec.mjs +340 -0
- package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
- package/tests/browser/session-summary.spec.mjs +17 -12
- package/tests/browser/settings-complete-home.spec.mjs +463 -0
- package/tests/browser/settings-entrypoint.spec.mjs +104 -0
- package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
- package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
- package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
- package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
- package/tests/browser/shell-ownership.spec.mjs +398 -0
- package/tests/browser/shell-rollout-fixture.mjs +259 -0
- package/tests/browser/shell-rollout.spec.mjs +357 -0
- package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
- package/tests/browser/shell-workspace.spec.mjs +433 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
- package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
- package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
- package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
- package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
- package/tests/browser/stream-output-isolation.spec.mjs +6 -3
- package/tests/browser/themed-selects.spec.mjs +297 -0
- package/tests/browser/thread-start-flow.spec.mjs +481 -0
- package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
- package/tests/browser/ui-polish-features.spec.mjs +85 -0
- package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
- package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
- package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
- package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
- package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
- package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
- package/tests/browser/windows-drive-parent.spec.mjs +4 -2
- package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
- package/tests/codex-cli-usage.test.mjs +189 -0
- package/tests/codex-fast-mode-static.test.mjs +16 -11
- package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
- package/tests/codex-usage-auth.test.mjs +168 -9
- package/tests/codex-usage-http.test.mjs +124 -0
- package/tests/codex-usage-source.test.mjs +146 -0
- package/tests/component-update-api-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +9 -4
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +5 -5
- package/tests/conversation-overview-adapter.test.mjs +100 -0
- package/tests/document-artifact-static.test.mjs +2 -1
- package/tests/draft-conversations.test.mjs +205 -0
- package/tests/empty-startup-launcher.test.mjs +197 -0
- package/tests/events-tree-context-menu-static.test.mjs +22 -18
- package/tests/fake-pi-session-ownership.test.mjs +302 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
- package/tests/file-viewer-image-static.test.mjs +15 -11
- package/tests/file-viewer-search-static.test.mjs +5 -5
- package/tests/fixtures/fake-codex-app-server.mjs +61 -0
- package/tests/fixtures/fake-pi.mjs +41 -9
- package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
- package/tests/git-footer-context-menu-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +41 -48
- package/tests/git-panel-live-updates-static.test.mjs +2 -1
- package/tests/git-workflow-dispatch.test.mjs +66 -0
- package/tests/git-workflow-preferences.test.mjs +9 -1
- package/tests/guided-git-activation-static.test.mjs +14 -11
- package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
- package/tests/guided-git-message-reliability-static.test.mjs +10 -6
- package/tests/guided-git-publication-backend-static.test.mjs +16 -11
- package/tests/http-endpoints-harness.test.mjs +29 -9
- package/tests/interaction-state-stability-static.test.mjs +4 -3
- package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
- package/tests/intercom-tag-layout-static.test.mjs +13 -12
- package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
- package/tests/main-output-loading-static.test.mjs +4 -4
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -2
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +10 -7
- package/tests/mobile-phone-experience-static.test.mjs +3 -2
- package/tests/mobile-static.test.mjs +173 -135
- package/tests/model-catalog-order.test.mjs +103 -0
- package/tests/native-parity.test.mjs +6 -4
- package/tests/native-session-choice-owner.test.mjs +102 -0
- package/tests/native-update-lifecycle.test.mjs +10 -5
- package/tests/no-project-http-harness.test.mjs +328 -0
- package/tests/no-project-navigation.test.mjs +54 -0
- package/tests/no-project-workspaces.test.mjs +77 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +4 -4
- package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
- package/tests/package-updates.test.mjs +630 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/platform-event-stream.test.mjs +253 -0
- package/tests/project-file-viewer-controller.test.mjs +652 -0
- package/tests/project-git-tools-adapter.test.mjs +103 -0
- package/tests/project-git-tools-controller.test.mjs +577 -0
- package/tests/project-runners-controller.test.mjs +453 -0
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
- package/tests/questionnaire-dialog.test.mjs +6 -6
- package/tests/queue-edit-reorder-static.test.mjs +48 -51
- package/tests/rpc-supervisor-host.test.mjs +4 -1
- package/tests/safety-guard-auto-review-static.test.mjs +1 -1
- package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
- package/tests/server-app-runners.test.mjs +536 -0
- package/tests/server-codex-fast-mode.test.mjs +346 -0
- package/tests/server-conversation-mode.test.mjs +386 -0
- package/tests/server-conversation-voice.test.mjs +426 -0
- package/tests/server-extension-ui-requests.test.mjs +357 -0
- package/tests/server-git-generation.test.mjs +558 -0
- package/tests/server-git-mutations.test.mjs +729 -0
- package/tests/server-git-reads.test.mjs +381 -0
- package/tests/server-git-worktree-sessions.test.mjs +502 -0
- package/tests/server-helper-requests.test.mjs +364 -0
- package/tests/server-rpc-transports.test.mjs +553 -0
- package/tests/server-settings-store.test.mjs +132 -0
- package/tests/server-shell-rollout.test.mjs +478 -0
- package/tests/server-sse-delivery.test.mjs +410 -0
- package/tests/server-workspace-files.test.mjs +546 -0
- package/tests/session-attention-scheduler.test.mjs +514 -0
- package/tests/session-composer-store.test.mjs +153 -0
- package/tests/session-context.test.mjs +134 -0
- package/tests/session-extension-requests.test.mjs +193 -0
- package/tests/session-ownership-adapter.test.mjs +130 -0
- package/tests/session-sampling-ui-static.test.mjs +10 -4
- package/tests/session-send-lifetime.test.mjs +140 -0
- package/tests/session-shelf-state.test.mjs +348 -0
- package/tests/session-shelves-adapter.test.mjs +79 -0
- package/tests/session-summary-lifetime.test.mjs +54 -0
- package/tests/settings-resource-controller.test.mjs +548 -0
- package/tests/shell-action-adapter.test.mjs +169 -0
- package/tests/shell-actions.test.mjs +182 -0
- package/tests/shell-navigation.test.mjs +348 -0
- package/tests/shell-preferences.test.mjs +367 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-output-isolation-static.test.mjs +1 -1
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slot-state.test.mjs +2 -2
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagent-reliability-integration.test.mjs +13 -30
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +1 -1
- package/tests/tab-metadata-ordering.test.mjs +99 -0
- package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
- package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
- package/tests/terminal-tab-workspace-static.test.mjs +5 -4
- package/tests/terminal-tabs-resize-static.test.mjs +1 -1
- package/tests/theme-contract.test.mjs +10 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thread-display-title.test.mjs +44 -0
- package/tests/update-api-harness.test.mjs +15 -14
- package/tests/update-tab-restore-harness.test.mjs +3 -0
- package/tests/webui-settings-locking.test.mjs +2 -2
- package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
- package/tests/workspace-choices.test.mjs +114 -0
- package/tests/workspace-save-load-static.test.mjs +7 -4
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import test from "node:test";
|
|
8
|
+
import { createGitReadService } from "../lib/server/git-reads.mjs";
|
|
9
|
+
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
11
|
+
const ok = (stdout = "", extra = {}) => ({ exitCode: 0, stdout, stderr: "", ...extra });
|
|
12
|
+
const failure = { exitCode: 128, stdout: "", stderr: "repository unavailable" };
|
|
13
|
+
|
|
14
|
+
function service(runCommand = realRunCommand) {
|
|
15
|
+
return createGitReadService({
|
|
16
|
+
runCommand,
|
|
17
|
+
makeHttpError: (statusCode, message) => Object.assign(new Error(message), { statusCode }),
|
|
18
|
+
makeUserFacingError: (message) => Object.assign(new Error(message), { userFacing: true }),
|
|
19
|
+
formatBytes: (bytes) => `${bytes} bytes`,
|
|
20
|
+
sanitizeError: (error) => error.message || String(error),
|
|
21
|
+
formatGitCommand: (args) => `git ${args.join(" ")}`,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function realRunCommand(command, args, options = {}) {
|
|
26
|
+
const { cwd, timeoutMs = 2000, maxOutputLength = 20_000, env = {}, input } = options;
|
|
27
|
+
const child = execFileAsync(command, args, {
|
|
28
|
+
cwd,
|
|
29
|
+
timeout: timeoutMs,
|
|
30
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
31
|
+
env: { ...process.env, ...env, LC_ALL: "C", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: os.devNull },
|
|
32
|
+
encoding: "utf8",
|
|
33
|
+
});
|
|
34
|
+
if (input !== undefined) child.child.stdin.end(input);
|
|
35
|
+
try {
|
|
36
|
+
const { stdout, stderr } = await child;
|
|
37
|
+
return ok(stdout.slice(-maxOutputLength), { stderr, stdoutTruncated: stdout.length > maxOutputLength });
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return { exitCode: error.code, stdout: error.stdout || "", stderr: error.stderr || "", timedOut: error.killed };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function repository(t) {
|
|
44
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "webui-git-reads-"));
|
|
45
|
+
t.after(() => rm(root, { recursive: true, force: true }));
|
|
46
|
+
const git = async (...args) => {
|
|
47
|
+
const result = await realRunCommand("git", args, { cwd: root, timeoutMs: 5000 });
|
|
48
|
+
assert.equal(result.exitCode, 0, result.stderr);
|
|
49
|
+
return result.stdout.trim();
|
|
50
|
+
};
|
|
51
|
+
await git("init", "-b", "main");
|
|
52
|
+
await git("config", "user.name", "Fixture Author");
|
|
53
|
+
await git("config", "user.email", "fixture@example.invalid");
|
|
54
|
+
return { root, git };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
test("factory construction is lazy and exposes exactly the contracted service", () => {
|
|
58
|
+
const reads = service(() => { assert.fail("factory must not execute commands"); });
|
|
59
|
+
const names = [
|
|
60
|
+
"getGitRoot", "runGitReadCommandDetailed", "runGitReadCommand", "readGitChanges", "readGitFileDiff",
|
|
61
|
+
"readGitPanel", "readGitCommit", "readGitUntrackedFile", "readWorkspaceGitStatusIndex",
|
|
62
|
+
"readWorkspaceGitIgnoredPaths", "withFileTreeGitStatus", "withFileTreeGitIgnored", "fileTreeGitStatusPayload",
|
|
63
|
+
"resolveGitRelativePath", "normalizeGitRelativePath", "isLikelyBinaryBuffer", "parseGitPorcelainZEntries",
|
|
64
|
+
"gitBranchFromPorcelainStatus", "summarizeGitPorcelainStatus", "gitUpstreamRef",
|
|
65
|
+
];
|
|
66
|
+
assert.deepEqual(Object.keys(reads).sort(), names.sort());
|
|
67
|
+
for (const name of names) assert.equal(typeof reads[name], "function");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("read command bounds, optional locks, truncation and user-facing errors", async () => {
|
|
71
|
+
const calls = [];
|
|
72
|
+
let result = ok("tail", { stdoutTruncated: true });
|
|
73
|
+
const reads = service(async (...args) => { calls.push(args); return result; });
|
|
74
|
+
assert.deepEqual(await reads.runGitReadCommandDetailed("/repo", ["diff"]), {
|
|
75
|
+
output: "tail", truncated: true, capBytes: 500_000,
|
|
76
|
+
});
|
|
77
|
+
assert.deepEqual(calls[0], ["git", ["diff"], {
|
|
78
|
+
cwd: "/repo", timeoutMs: 5000, maxOutputLength: 500_000, env: { GIT_OPTIONAL_LOCKS: "0" },
|
|
79
|
+
}]);
|
|
80
|
+
assert.equal(await reads.runGitReadCommand("/repo", ["status"], { timeoutMs: 13, maxOutputLength: 17 }), "tail");
|
|
81
|
+
assert.equal(calls[1][2].timeoutMs, 13);
|
|
82
|
+
assert.equal(calls[1][2].maxOutputLength, 17);
|
|
83
|
+
for (const [failed, message] of [
|
|
84
|
+
[ok("", { timedOut: true }), "git diff timed out"],
|
|
85
|
+
[failure, "repository unavailable"],
|
|
86
|
+
[{ exitCode: 2, stdout: " stdout failure \n" }, "stdout failure"],
|
|
87
|
+
[ok("", { error: "spawn error" }), "spawn error"],
|
|
88
|
+
[{ exitCode: 9 }, "git diff failed with exit code 9"],
|
|
89
|
+
[{}, "git diff failed with exit code unknown"],
|
|
90
|
+
]) {
|
|
91
|
+
result = failed;
|
|
92
|
+
await assert.rejects(reads.runGitReadCommandDetailed("/repo", ["diff"]), (error) => {
|
|
93
|
+
assert.equal(error.message, message);
|
|
94
|
+
assert.equal(error.userFacing, true);
|
|
95
|
+
return true;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
result = ok(" /repo \n");
|
|
99
|
+
assert.equal(await reads.getGitRoot("/repo/sub"), path.resolve("/repo"));
|
|
100
|
+
assert.deepEqual(calls.at(-1), ["git", ["rev-parse", "--show-toplevel"], { cwd: "/repo/sub", timeoutMs: 2000 }]);
|
|
101
|
+
result = failure;
|
|
102
|
+
await assert.rejects(reads.getGitRoot("/repo"), /repository unavailable/);
|
|
103
|
+
result = { exitCode: 1 };
|
|
104
|
+
await assert.rejects(reads.getGitRoot("/repo"), /Not inside a git repository/);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("porcelain parser preserves NUL-delimited rename, copy and unusual paths", () => {
|
|
108
|
+
const reads = service();
|
|
109
|
+
const unusual = "dir/tab\tand\nnewline ü.txt";
|
|
110
|
+
assert.deepEqual(reads.parseGitPorcelainZEntries(`R ${unusual}\0old name\0C copy\0source\0?? -leading\0x\0`), [
|
|
111
|
+
{ x: "R", y: " ", path: unusual, oldPath: "old name" },
|
|
112
|
+
{ x: "C", y: " ", path: "copy", oldPath: "source" },
|
|
113
|
+
{ x: "?", y: "?", path: "-leading" },
|
|
114
|
+
{ x: "", y: "", path: "x", unsupported: true },
|
|
115
|
+
]);
|
|
116
|
+
assert.deepEqual(reads.parseGitPorcelainZEntries(), []);
|
|
117
|
+
assert.equal(reads.gitBranchFromPorcelainStatus("# branch.head main\r\n"), "main");
|
|
118
|
+
assert.equal(reads.gitBranchFromPorcelainStatus("# branch.head (detached)\n"), "detached");
|
|
119
|
+
assert.equal(reads.gitBranchFromPorcelainStatus(""), "detached");
|
|
120
|
+
assert.deepEqual(reads.summarizeGitPorcelainStatus([
|
|
121
|
+
"# branch.ab +2 -3", "1 M. tracked", "2 .M renamed", "1 MM both", "u UU conflict", "? new",
|
|
122
|
+
].join("\n")), { staged: 2, unstaged: 2, untracked: 1, conflicted: 1, ahead: 2, behind: 3 });
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("path and binary helpers retain lexical validation", () => {
|
|
126
|
+
const reads = service();
|
|
127
|
+
const root = path.resolve(os.tmpdir(), "git-read-root");
|
|
128
|
+
assert.equal(reads.resolveGitRelativePath(root, " ./folder/../file "), path.join(root, "file"));
|
|
129
|
+
assert.equal(reads.normalizeGitRelativePath(root, "./folder/file"), "folder/file");
|
|
130
|
+
assert.equal(reads.normalizeGitRelativePath(root, "."), "");
|
|
131
|
+
for (const invalid of ["", " ", "file\0suffix"]) {
|
|
132
|
+
assert.throws(() => reads.resolveGitRelativePath(root, invalid), /Invalid git path/);
|
|
133
|
+
}
|
|
134
|
+
assert.throws(() => reads.resolveGitRelativePath(root, "../git-read-root-other/file"), /escapes repository/);
|
|
135
|
+
assert.equal(reads.isLikelyBinaryBuffer(Buffer.from([1, 0, 2])), true);
|
|
136
|
+
assert.equal(reads.isLikelyBinaryBuffer(Buffer.from("text")), false);
|
|
137
|
+
assert.equal(reads.isLikelyBinaryBuffer("\0"), false);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test("real panel and commit reads retain status, rename stats, binary stats and history", async (t) => {
|
|
141
|
+
const { root, git } = await repository(t);
|
|
142
|
+
const reads = service();
|
|
143
|
+
await mkdir(path.join(root, "sub"));
|
|
144
|
+
const original = "sub/original\tü.txt";
|
|
145
|
+
const renamed = "sub/renamed\nü.txt";
|
|
146
|
+
await writeFile(path.join(root, original), "one\ntwo\n");
|
|
147
|
+
await writeFile(path.join(root, "binary"), Buffer.from([0, 1]));
|
|
148
|
+
await git("add", "--", original, "binary");
|
|
149
|
+
await git("commit", "-m", "Fixture subject");
|
|
150
|
+
const hash = await git("rev-parse", "HEAD");
|
|
151
|
+
await git("mv", "--", original, renamed);
|
|
152
|
+
await writeFile(path.join(root, renamed), "one\nthree\n");
|
|
153
|
+
await writeFile(path.join(root, "binary"), Buffer.from([0, 2]));
|
|
154
|
+
await writeFile(path.join(root, "-new.txt"), "new\n");
|
|
155
|
+
const before = await readFile(path.join(root, ".git", "index"));
|
|
156
|
+
const panel = await reads.readGitPanel(path.join(root, "sub"));
|
|
157
|
+
assert.equal(panel.cwd, path.join(root, "sub"));
|
|
158
|
+
assert.equal(panel.root, root);
|
|
159
|
+
assert.equal(panel.branch, "main");
|
|
160
|
+
assert.equal(panel.history[0].hash, hash);
|
|
161
|
+
assert.equal(panel.history[0].author, "Fixture Author");
|
|
162
|
+
assert.equal(panel.history[0].subject, "Fixture subject");
|
|
163
|
+
assert.deepEqual(panel.summary, { staged: 1, unstaged: 2, untracked: 1, conflicted: 0, ahead: 0, behind: 0 });
|
|
164
|
+
const rename = panel.changes.find((entry) => entry.path === renamed);
|
|
165
|
+
assert.equal(rename.oldPath, original);
|
|
166
|
+
assert.equal(rename.status, "RM");
|
|
167
|
+
assert.equal(rename.staged, true);
|
|
168
|
+
assert.equal(rename.unstaged, true);
|
|
169
|
+
assert.equal(rename.additions, 3);
|
|
170
|
+
assert.equal(rename.deletions, 3);
|
|
171
|
+
assert.equal(rename.unstagedAdditions, 1);
|
|
172
|
+
assert.equal(rename.unstagedDeletions, 1);
|
|
173
|
+
assert.equal(panel.changes.find((entry) => entry.path === "binary").binary, true);
|
|
174
|
+
assert.equal(panel.changes.find((entry) => entry.path === "-new.txt").untracked, true);
|
|
175
|
+
const commit = await reads.readGitCommit(root, hash.toUpperCase());
|
|
176
|
+
assert.equal(commit.commit.hash, hash);
|
|
177
|
+
assert.equal(commit.sections[0].key, "commit");
|
|
178
|
+
assert.match(commit.sections[0].diff, /Fixture|original/);
|
|
179
|
+
assert.equal(commit.sections[0].capBytes, 500_000);
|
|
180
|
+
assert.deepEqual(commit.untracked, []);
|
|
181
|
+
assert.deepEqual(await readFile(path.join(root, ".git", "index")), before);
|
|
182
|
+
for (const invalid of ["HEAD", hash.slice(0, 12), "-x", "g".repeat(40)]) {
|
|
183
|
+
await assert.rejects(reads.readGitCommit(root, invalid), { statusCode: 400 });
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("real status and ignored decorations use workspace-relative paths and retain unrelated entries", async (t) => {
|
|
188
|
+
const { root, git } = await repository(t);
|
|
189
|
+
const reads = service();
|
|
190
|
+
await mkdir(path.join(root, "sub"));
|
|
191
|
+
const name = "sub/tab\tline\nü.txt";
|
|
192
|
+
await writeFile(path.join(root, name), "before\n");
|
|
193
|
+
await writeFile(path.join(root, ".gitignore"), "sub/cache ü/\n");
|
|
194
|
+
await git("add", ".");
|
|
195
|
+
await git("commit", "-m", "Initial");
|
|
196
|
+
await writeFile(path.join(root, name), "after\n");
|
|
197
|
+
await mkdir(path.join(root, "sub", "cache ü"));
|
|
198
|
+
const entries = [{ path: "tab\tline\nü.txt" }, { path: "cache ü" }, { path: "../../outside" }, { name: "no path" }];
|
|
199
|
+
const status = await reads.readWorkspaceGitStatusIndex(root);
|
|
200
|
+
const decorated = reads.withFileTreeGitStatus(entries, path.join(root, "sub"), status);
|
|
201
|
+
assert.deepEqual(decorated[0].gitStatus, { changed: true, kind: "modified", status: "M", direct: true, changedDescendants: 0 });
|
|
202
|
+
assert.equal(decorated[2], entries[2]);
|
|
203
|
+
assert.equal(status.entries.get("sub").changedDescendants, 1);
|
|
204
|
+
const payload = reads.fileTreeGitStatusPayload(path.join(root, "sub"), status);
|
|
205
|
+
assert.equal(payload.root, root);
|
|
206
|
+
assert.equal(payload.entries.some((entry) => entry.path === "tab\tline\nü.txt"), true);
|
|
207
|
+
assert.equal(payload.entries.some((entry) => entry.path === ".gitignore"), false);
|
|
208
|
+
const ignored = await reads.readWorkspaceGitIgnoredPaths(path.join(root, "sub"), entries, root);
|
|
209
|
+
assert.deepEqual([...ignored.paths], ["sub/cache ü"]);
|
|
210
|
+
const ignoredEntries = reads.withFileTreeGitIgnored(entries, path.join(root, "sub"), ignored);
|
|
211
|
+
assert.equal(ignoredEntries[1].gitIgnored, true);
|
|
212
|
+
assert.equal(ignoredEntries[0], entries[0]);
|
|
213
|
+
assert.equal(ignoredEntries[2], entries[2]);
|
|
214
|
+
assert.equal(reads.withFileTreeGitStatus(entries, root, null), entries);
|
|
215
|
+
assert.equal(reads.withFileTreeGitIgnored(entries, root, null), entries);
|
|
216
|
+
assert.equal(reads.fileTreeGitStatusPayload(root, null), null);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("status decoration aggregates rank, conflict and old-path ancestors", async () => {
|
|
220
|
+
const root = path.resolve(os.tmpdir(), "git-read-status");
|
|
221
|
+
const reads = service(async (_command, args) => ok(args[0] === "rev-parse" ? root : [
|
|
222
|
+
"?? dir/new", " M dir/modified", "M dir/staged", "UU dir/conflict", "R dest/file", "old/file",
|
|
223
|
+
].join("\0") + "\0"));
|
|
224
|
+
const status = await reads.readWorkspaceGitStatusIndex(root);
|
|
225
|
+
assert.deepEqual(status.entries.get("dir"), { changed: true, kind: "conflicted", status: "", direct: false, changedDescendants: 4 });
|
|
226
|
+
assert.equal(status.entries.get("dir/staged").kind, "staged");
|
|
227
|
+
assert.equal(status.entries.get("dir/new").kind, "untracked");
|
|
228
|
+
assert.equal(status.entries.get("old").changedDescendants, 1);
|
|
229
|
+
assert.equal(status.entries.has("old/file"), false);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("nullable decorations and upstream failures preserve fallback semantics and ignored bounds", async () => {
|
|
233
|
+
const root = path.resolve(os.tmpdir(), "git-read-ignored");
|
|
234
|
+
const calls = [];
|
|
235
|
+
let result = failure;
|
|
236
|
+
const reads = service(async (...args) => { calls.push(args); return result; });
|
|
237
|
+
assert.equal(await reads.readWorkspaceGitStatusIndex(root), null);
|
|
238
|
+
assert.equal(await reads.gitUpstreamRef(root), "");
|
|
239
|
+
assert.equal(await reads.readWorkspaceGitIgnoredPaths(root, [{ path: "file" }], root), null);
|
|
240
|
+
for (const extra of [{ timedOut: true }, { error: "spawn failure" }, { stdoutTruncated: true }]) {
|
|
241
|
+
result = ok("file\0", extra);
|
|
242
|
+
assert.equal(await reads.readWorkspaceGitIgnoredPaths(root, [{ path: "file" }], root), null);
|
|
243
|
+
}
|
|
244
|
+
result = ok("", { exitCode: 1 });
|
|
245
|
+
assert.equal((await reads.readWorkspaceGitIgnoredPaths(root, [{ path: "file" }], root)).paths.size, 0);
|
|
246
|
+
assert.deepEqual(calls.at(-1), ["git", ["check-ignore", "-z", "--stdin"], {
|
|
247
|
+
cwd: root, timeoutMs: 5000, maxOutputLength: 20_000, env: { GIT_OPTIONAL_LOCKS: "0" }, input: "file\0", utf8Output: true,
|
|
248
|
+
}]);
|
|
249
|
+
const count = calls.length;
|
|
250
|
+
assert.equal(await reads.readWorkspaceGitIgnoredPaths(root, [{ path: "../outside" }, { path: "." }], root), null);
|
|
251
|
+
assert.equal(calls.length, count);
|
|
252
|
+
const unusual = "tab\tline\nü.txt";
|
|
253
|
+
result = ok(`${unusual}\0`);
|
|
254
|
+
assert.equal((await reads.readWorkspaceGitIgnoredPaths(root, [{ path: unusual }], root)).paths.has(unusual), true);
|
|
255
|
+
assert.equal(calls.at(-1)[2].input, `${unusual}\0`);
|
|
256
|
+
const longName = "x".repeat(20_001);
|
|
257
|
+
await reads.readWorkspaceGitIgnoredPaths(root, [{ path: longName }], root);
|
|
258
|
+
assert.equal(calls.at(-1)[2].maxOutputLength, longName.length + 2);
|
|
259
|
+
const throwing = service(async () => { throw new Error("command rejected"); });
|
|
260
|
+
assert.equal(await throwing.readWorkspaceGitStatusIndex(root), null);
|
|
261
|
+
assert.equal(await throwing.readWorkspaceGitIgnoredPaths(root, [{ path: "file" }], root), null);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("real untracked previews and per-file diffs retain size, binary, categories and refusal contracts", async (t) => {
|
|
265
|
+
const { root, git } = await repository(t);
|
|
266
|
+
const reads = service();
|
|
267
|
+
await writeFile(path.join(root, "tracked.txt"), "before\n");
|
|
268
|
+
await git("add", ".");
|
|
269
|
+
await git("commit", "-m", "Initial");
|
|
270
|
+
await writeFile(path.join(root, "tracked.txt"), "staged\n");
|
|
271
|
+
await git("add", ".");
|
|
272
|
+
await writeFile(path.join(root, "tracked.txt"), "unstaged\n");
|
|
273
|
+
await writeFile(path.join(root, "new file.txt"), "new text\n");
|
|
274
|
+
await writeFile(path.join(root, "binary"), Buffer.from([0, 1]));
|
|
275
|
+
assert.equal((await reads.readGitUntrackedFile(root, "new file.txt")).content, "new text\n");
|
|
276
|
+
assert.equal((await reads.readGitUntrackedFile(root, "binary")).binary, true);
|
|
277
|
+
assert.equal((await reads.readGitUntrackedFile(root, "binary")).content, "");
|
|
278
|
+
assert.match((await reads.readGitUntrackedFile(root, "new file.txt", { maxBytes: 2 })).error, /limit 2 bytes/);
|
|
279
|
+
await assert.rejects(reads.readGitUntrackedFile(root, "tracked.txt"), /Not an untracked file/);
|
|
280
|
+
await assert.rejects(reads.readGitUntrackedFile(root, "../outside"), /escapes repository/);
|
|
281
|
+
await assert.rejects(reads.readGitFileDiff(root, "tracked.txt", "invalid"), /category must be/);
|
|
282
|
+
for (const [category, expected] of [["staged", "+staged"], ["unstaged", "+unstaged"], ["conflicted", ""]]) {
|
|
283
|
+
const diff = await reads.readGitFileDiff(root, "tracked.txt", category);
|
|
284
|
+
assert.equal(diff.category, category);
|
|
285
|
+
assert.equal(diff.truncated, false);
|
|
286
|
+
assert.equal(diff.capBytes, 500_000);
|
|
287
|
+
if (expected) assert.ok(diff.diff.includes(expected));
|
|
288
|
+
}
|
|
289
|
+
const preview = await reads.readGitFileDiff(root, "new file.txt", "untracked");
|
|
290
|
+
assert.equal(preview.label, "Untracked");
|
|
291
|
+
assert.equal(preview.diff, "");
|
|
292
|
+
assert.equal(preview.content, "new text\n");
|
|
293
|
+
const changes = await reads.readGitChanges(root);
|
|
294
|
+
assert.deepEqual(changes.sections.map((section) => section.key), ["staged", "unstaged"]);
|
|
295
|
+
assert.equal(changes.summary.staged, 1);
|
|
296
|
+
assert.equal(changes.summary.unstaged, 1);
|
|
297
|
+
assert.equal(changes.untracked.length, 2);
|
|
298
|
+
assert.equal(changes.remote.upstream, "");
|
|
299
|
+
assert.equal(changes.remote.canPull, false);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test("file diff command construction retains category flags, path separation and truncated tails", async () => {
|
|
303
|
+
const root = path.resolve(os.tmpdir(), "git-read-diff");
|
|
304
|
+
const calls = [];
|
|
305
|
+
const reads = service(async (_command, args, options) => {
|
|
306
|
+
calls.push({ args, options });
|
|
307
|
+
return args[0] === "rev-parse" ? ok(root) : ok("tail\n\n", { stdoutTruncated: true });
|
|
308
|
+
});
|
|
309
|
+
for (const [category, flags] of [["staged", ["--cached"]], ["unstaged", []], ["conflicted", ["--cc"]]]) {
|
|
310
|
+
const diff = await reads.readGitFileDiff(root, "-strange\tpath\nü", category);
|
|
311
|
+
assert.deepEqual(calls.at(-1).args, [
|
|
312
|
+
"diff", ...flags, "--no-ext-diff", "--no-textconv", "--no-color", "--unified=3", "--src-prefix=a/", "--dst-prefix=b/", "--", "-strange\tpath\nü",
|
|
313
|
+
]);
|
|
314
|
+
assert.equal(diff.diff, "tail");
|
|
315
|
+
assert.equal(diff.truncated, true);
|
|
316
|
+
assert.equal(diff.capBytes, 500_000);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test("incoming reads retain diverged/canPull flags, bounded sections and read error payloads", async () => {
|
|
321
|
+
const root = path.resolve(os.tmpdir(), "git-read-incoming");
|
|
322
|
+
let ahead = 0;
|
|
323
|
+
let incomingFails = false;
|
|
324
|
+
const reads = service(async (_command, args) => {
|
|
325
|
+
if (args[0] === "rev-parse") return ok(args.includes("--show-toplevel") ? root : "origin/main\n");
|
|
326
|
+
if (args.includes("--porcelain=2")) return ok(`# branch.head main\n# branch.ab +${ahead} -2\n`);
|
|
327
|
+
if (args.includes("HEAD..@{upstream}")) return incomingFails ? failure : ok("incoming\n", { stdoutTruncated: true });
|
|
328
|
+
if (args[0] === "diff") return ok("diff\n", { stdoutTruncated: true });
|
|
329
|
+
return ok("");
|
|
330
|
+
});
|
|
331
|
+
const changes = await reads.readGitChanges(root);
|
|
332
|
+
assert.equal(changes.remote.canPull, true);
|
|
333
|
+
assert.equal(changes.sections[0].key, "incoming");
|
|
334
|
+
assert.equal(changes.sections[0].diff, "incoming");
|
|
335
|
+
assert.equal(changes.sections[0].truncated, true);
|
|
336
|
+
assert.equal(changes.sections[0].capBytes, 500_000);
|
|
337
|
+
assert.equal(changes.sections[1].truncated, true);
|
|
338
|
+
ahead = 1;
|
|
339
|
+
const diverged = await reads.readGitChanges(root);
|
|
340
|
+
assert.equal(diverged.remote.diverged, true);
|
|
341
|
+
assert.equal(diverged.remote.canPull, false);
|
|
342
|
+
incomingFails = true;
|
|
343
|
+
const failed = await reads.readGitChanges(root);
|
|
344
|
+
assert.equal(failed.remote.error, "repository unavailable");
|
|
345
|
+
assert.deepEqual(failed.sections.map((section) => section.key), ["staged", "unstaged"]);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
test("commit fallback supports full SHA-256 hashes and retains command limits and truncation", async () => {
|
|
349
|
+
const root = path.resolve(os.tmpdir(), "git-read-commit");
|
|
350
|
+
const hash = "a".repeat(64);
|
|
351
|
+
const calls = [];
|
|
352
|
+
const reads = service(async (_command, args, options) => {
|
|
353
|
+
calls.push({ args, options });
|
|
354
|
+
if (args.includes("--show-toplevel")) return ok(root);
|
|
355
|
+
if (args.includes("--verify")) return ok(hash);
|
|
356
|
+
if (args.includes("--format=")) return ok("diff tail\n", { stdoutTruncated: true });
|
|
357
|
+
return ok("");
|
|
358
|
+
});
|
|
359
|
+
const commit = await reads.readGitCommit(root, hash);
|
|
360
|
+
assert.deepEqual(commit.commit, { hash, shortHash: hash.slice(0, 12), author: "", authoredAt: "", subject: "" });
|
|
361
|
+
assert.equal(commit.sections[0].diff, "diff tail");
|
|
362
|
+
assert.equal(commit.sections[0].truncated, true);
|
|
363
|
+
assert.equal(calls.find(({ args }) => args.includes("--verify")).options.maxOutputLength, 1000);
|
|
364
|
+
assert.equal(calls.find(({ args }) => args.includes("-s")).options.maxOutputLength, 20_000);
|
|
365
|
+
assert.equal(calls.find(({ args }) => args.includes("--format=")).options.maxOutputLength, 500_000);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
test("unborn history, missing untracked entries and commit verification keep existing fallbacks", async (t) => {
|
|
369
|
+
const { root } = await repository(t);
|
|
370
|
+
assert.deepEqual((await service().readGitPanel(root)).history, []);
|
|
371
|
+
const reads = service(async (_command, args) => {
|
|
372
|
+
if (args.includes("--show-toplevel")) return ok(root);
|
|
373
|
+
if (args.includes("--verify")) return ok("b".repeat(40));
|
|
374
|
+
if (args[0] === "ls-files") return ok("missing\n.git\n");
|
|
375
|
+
return ok("");
|
|
376
|
+
});
|
|
377
|
+
await assert.rejects(reads.readGitCommit(root, "a".repeat(40)), { statusCode: 404 });
|
|
378
|
+
const changes = await reads.readGitChanges(root);
|
|
379
|
+
assert.match(changes.untracked[0].error, /ENOENT/);
|
|
380
|
+
assert.equal(changes.untracked[1].error, "Not a regular file");
|
|
381
|
+
});
|