From 911b09cca960a35b90e5b9d631da09f5d7950c2e Mon Sep 17 00:00:00 2001 From: Maples7 Date: Sat, 16 May 2026 13:42:41 +0800 Subject: [PATCH] fix: clarify land wrong-branch diagnostic --- CHANGELOG.md | 5 +++++ Sources/VibeChardCore/Domain/Errors.swift | 2 +- .../Domain/ErrorsTests.swift | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d0939..b42ee1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ The English README is the source of truth; localized READMEs may lag. ## Unreleased +### Fixed +- Clarified `vch land` wrong-branch diagnostics so resolved `--into` + failures show the target branch and no longer suggest passing + `--into` again (#124). + ## 0.9.1 - 2026-05-15 ### Changed diff --git a/Sources/VibeChardCore/Domain/Errors.swift b/Sources/VibeChardCore/Domain/Errors.swift index fae87e3..bb9d977 100644 --- a/Sources/VibeChardCore/Domain/Errors.swift +++ b/Sources/VibeChardCore/Domain/Errors.swift @@ -198,7 +198,7 @@ public enum VibeChardError: Error, CustomStringConvertible { return "no log file at \(path) — \(hint)" case let .landMainNotOnInto(currentBranch, want): let cur = currentBranch.map { "'\($0)'" } ?? "(detached HEAD)" - return "refusing to land: main worktree is on \(cur), not '\(want)' (use `git switch \(want)` first or pass --into)" + return "refusing to land: target branch is '\(want)', but the main worktree is currently on \(cur); run `git switch \(want)` first from the main worktree" case let .landMergeOverlap(paths): let listing = paths.map { " \($0)" }.joined(separator: "\n") return "refusing to land: \(paths.count) file\(paths.count == 1 ? "" : "s") in main worktree overlap the task branch's diff (stash or commit them, or pass --allow-dirty):\n\(listing)" diff --git a/Tests/VibeChardCoreTests/Domain/ErrorsTests.swift b/Tests/VibeChardCoreTests/Domain/ErrorsTests.swift index ccc4677..5c2f5e5 100644 --- a/Tests/VibeChardCoreTests/Domain/ErrorsTests.swift +++ b/Tests/VibeChardCoreTests/Domain/ErrorsTests.swift @@ -4,6 +4,25 @@ import XCTest final class ErrorsTests: XCTestCase { + // MARK: - land diagnostics (#124) + + func testLandMainNotOnIntoMessageNamesTargetAndCurrentBranch() { + let err = VibeChardError.landMainNotOnInto( + currentBranch: "v3.1.0", + want: "main" + ) + let msg = err.description + + XCTAssertTrue(msg.contains("target branch is 'main'"), + "expected target branch in: \(msg)") + XCTAssertTrue(msg.contains("main worktree is currently on 'v3.1.0'"), + "expected current branch in: \(msg)") + XCTAssertTrue(msg.contains("git switch main"), + "expected direct switch hint in: \(msg)") + XCTAssertFalse(msg.contains("pass --into"), + "must not suggest --into after the target has already been resolved; got: \(msg)") + } + // MARK: - worktreeBusy (#65) func testWorktreeBusyMessageRecommendsForceFlag() {