Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@ describe("what to say when an action fails", () => {
const reason = "The worktree directory already exists. Choose another directory.";
expect(checkoutFailureDescription(diagnostic(reason))).toBe(reason);
expect(checkoutFailureDescription(diagnostic("x".repeat(900)))).toBe(`${"x".repeat(319)}…`);
expect(checkoutFailureDescription(diagnostic(`${"x".repeat(318)}😀 tail`))).toBe(
`${"x".repeat(318)}…`,
);
for (const failure of [undefined, diagnostic(""), diagnostic("exited with code 1")]) {
expect(checkoutFailureDescription(failure)).toBe(
"Check that the branch still exists and is not checked out elsewhere, then try again.",
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/components/pullRequest/pullRequestDetail.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1569,11 +1569,11 @@ export function readableFailure(failure: unknown, hint: string): string {
failure instanceof Error ? failure.message : typeof failure === "string" ? failure : "";
const detail = raw.replace(OPERATION_PREFIX, "").trim();
if (detail.length === 0 || TOOL_NOISE.some((pattern) => pattern.test(detail))) return hint;
const bounded =
detail.length <= FAILURE_DETAIL_MAX_LENGTH
? detail
: `${detail.slice(0, FAILURE_DETAIL_MAX_LENGTH - 1)}…`;
return bounded;
if (detail.length <= FAILURE_DETAIL_MAX_LENGTH) return detail;
let end = FAILURE_DETAIL_MAX_LENGTH - 1;
const last = detail.charCodeAt(end - 1);
if (last >= 0xd800 && last <= 0xdbff) end -= 1;
return `${detail.slice(0, end)}…`;
}

const isGitCommandError = Schema.is(GitCommandError);
Expand Down
Loading