GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(vcs): keep emoji intact in review commit subjects (#43030) · patroza/t3code@b9b1f57

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/vcs
    • GitVcsDriverCore.test.ts
    • GitVcsDriverCore.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriverCore.test.ts
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,6 +3759,27 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
37593759
}),
37603760
);
37613761

3762+
it.effect("cuts long commit subjects without splitting an emoji", () =>
3763+
Effect.gen(function* () {
3764+
const cwd = yield* makeTmpDir();
3765+
const { initialBranch } = yield* initRepoWithCommit(cwd);
3766+
const driver = yield* GitVcsDriver.GitVcsDriver;
3767+
yield* git(cwd, ["checkout", "-b", "feature/emoji-subject"]);
3768+
yield* git(cwd, ["commit", "--allow-empty", "-m", `${"a".repeat(299)}😀 tail`]);
3769+
const sha = yield* git(cwd, ["rev-parse", "HEAD"]);
3770+
3771+
const branch = yield* driver.getReviewBranchCommits({ cwd, baseRef: initialBranch });
3772+
const preview = yield* driver.getReviewDiffPreview({ cwd, commitSha: sha });
3773+
const commitSubject = preview.sources.find(
3774+
(candidate) => candidate.kind === "commit",
3775+
)?.commitSubject;
3776+
assert.deepStrictEqual(
3777+
[branch.commits[0]?.subject, commitSubject],
3778+
["a".repeat(299), "a".repeat(299)],
3779+
);
3780+
}),
3781+
);
3782+
37623783
it.effect("previews one selected commit, a merge against its first parent", () =>
37633784
Effect.gen(function* () {
37643785
const cwd = yield* makeTmpDir();
Collapse file

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriverCore.ts
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
trimAsciiWhitespace,
3838
type VcsRef,
3939
} from "@t3tools/contracts";
40+
import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations";
4041
import { dedupeRemoteBranchesWithLocalMatches } from "@t3tools/shared/git";
4142
import * as HostProcess from "@t3tools/shared/HostProcess";
4243
import { compactTraceAttributes } from "@t3tools/shared/observability";
@@ -104,6 +105,13 @@ const REVIEW_DIFF_FILE_MAX_OUTPUT_BYTES = 1024 * 1024;
104105
const GIT_IDENT_KEYWORD = /\$Id:[^$\n]*\$/g;
105106
const REVIEW_BRANCH_COMMIT_LIMIT = 100;
106107
const REVIEW_BRANCH_SUBJECT_LIMIT = 300;
108+
const truncateReviewSubject = (subject: string) =>
109+
subject.slice(
110+
0,
111+
splitsSurrogatePair(subject, REVIEW_BRANCH_SUBJECT_LIMIT)
112+
? REVIEW_BRANCH_SUBJECT_LIMIT - 1
113+
: REVIEW_BRANCH_SUBJECT_LIMIT,
114+
);
107115
const REVIEW_BRANCH_COMMIT_MAX_OUTPUT_BYTES = 128 * 1024;
108116
// Client patch parsers require a/ and b/ prefixes; override user diff prefix settings.
109117
export const PATCH_RENDER_PREFIX_ARGS = ["--src-prefix=a/", "--dst-prefix=b/"] as const;
@@ -5011,7 +5019,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
50115019
);
50125020
const endOfSubject = result.stdout.indexOf("\n");
50135021
return {
5014-
subject: result.stdout.slice(0, endOfSubject < 0 ? undefined : endOfSubject).slice(0, 300),
5022+
subject: truncateReviewSubject(
5023+
result.stdout.slice(0, endOfSubject < 0 ? undefined : endOfSubject),
5024+
),
50155025
};
50165026
});
50175027

@@ -5077,7 +5087,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
50775087
) {
50785088
return yield* reviewCommitError(cwd, "Could not read branch commit metadata.");
50795089
}
5080-
commits.push({ sha, subject: subject.slice(0, REVIEW_BRANCH_SUBJECT_LIMIT), committedAt });
5090+
commits.push({ sha, subject: truncateReviewSubject(subject), committedAt });
50815091
}
50825092
if (result.stdoutTruncated && commits.length === 0) {
50835093
return yield* reviewCommitError(cwd, "Branch commit metadata exceeds the response limit.");

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.