From 3e44fbbdb5fcf8245d2d415acd73f8170f5143a3 Mon Sep 17 00:00:00 2001 From: ybx <3046829330@qq.com> Date: Sun, 16 Aug 2026 21:35:21 +0800 Subject: [PATCH] Fix Windows tag checkout result --- .../src/platform/core-result-adapter.test.ts | 30 +++++++++++++++++++ .../tauri/src/platform/core-result-adapter.ts | 7 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/windows/tauri/src/platform/core-result-adapter.test.ts b/windows/tauri/src/platform/core-result-adapter.test.ts index 503dbc1ed..de15fba87 100644 --- a/windows/tauri/src/platform/core-result-adapter.test.ts +++ b/windows/tauri/src/platform/core-result-adapter.test.ts @@ -37,6 +37,36 @@ describe("git checkout result adaptation", () => { }); }); +describe("git tag checkout result adaptation", () => { + test("maps a successful core tag checkout to the UI checkout result", () => { + const result = adaptCoreResult( + "git_checkout_tag", + { repoPath: "C:/work", name: "v0.3.0" }, + { output: "HEAD is now at abc1234 Release 0.3.0\n", exitCode: 0 }, + ); + + expect(result).toEqual({ + success: true, + hasChanges: false, + message: "HEAD is now at abc1234 Release 0.3.0", + }); + }); + + test("reports failure when the core tag checkout exited non-zero", () => { + const result = adaptCoreResult( + "git_checkout_tag", + { repoPath: "C:/work", name: "missing-tag" }, + { output: "error: pathspec 'missing-tag' did not match", exitCode: 1 }, + ); + + expect(result).toEqual({ + success: false, + hasChanges: false, + message: "error: pathspec 'missing-tag' did not match", + }); + }); +}); + describe("git checkout preflight adaptation", () => { test("reports blocked paths returned by the shared core", () => { const result = adaptCoreResult( diff --git a/windows/tauri/src/platform/core-result-adapter.ts b/windows/tauri/src/platform/core-result-adapter.ts index 8b525ff28..db30362ce 100644 --- a/windows/tauri/src/platform/core-result-adapter.ts +++ b/windows/tauri/src/platform/core-result-adapter.ts @@ -229,8 +229,11 @@ export function adaptCoreResult( : []; return { blocked: blockingPaths.length > 0, blockingPaths } as T; } - case "git_checkout_tag": - return { success: true, hasChanges: false, message: "" } as T; + case "git_checkout_tag": { + const exitCode = typeof data.exitCode === "number" ? data.exitCode : 0; + const output = typeof data.output === "string" ? data.output.trim() : ""; + return { success: exitCode === 0, hasChanges: false, message: output } as T; + } case "git_operation_state": { const kind = typeof data.kind === "string" ? data.kind : ""; if (!kind) {