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
17 changes: 16 additions & 1 deletion apps/server/src/git/GitManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4191,7 +4191,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
}),
);

it.effect("generates PR content against the remote base when the local base is stale", () =>
it.effect("generates PR content from branch changes when the remote base advances", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
yield* initRepo(repoDir);
Expand Down Expand Up @@ -4223,14 +4223,24 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["push", "-u", "origin", "feature/remote-base"]);
yield* runGit(repoDir, ["config", "branch.feature/remote-base.gh-merge-base", "main"]);

NodeFS.writeFileSync(NodePath.join(peerDir, "later-main.txt"), "unrelated\n");
yield* runGit(peerDir, ["add", "later-main.txt"]);
yield* runGit(peerDir, ["commit", "-m", "Later main commit"]);
yield* runGit(peerDir, ["push", "origin", "main"]);
yield* runGit(repoDir, ["fetch", "origin"]);

let generatedCommitSummary = "";
let generatedDiffSummary = "";
let generatedDiffPatch = "";
const { manager } = yield* makeManager({
ghScenario: {
prListSequence: ["[]", "[]"],
},
textGeneration: {
generatePrContent: (input) => {
generatedCommitSummary = input.commitSummary;
generatedDiffSummary = input.diffSummary;
generatedDiffPatch = input.diffPatch;
return Effect.succeed({ title: "Feature PR", body: "Feature body" });
},
},
Expand All @@ -4244,6 +4254,11 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
expect(result.pr.status).toBe("created");
expect(generatedCommitSummary).toContain("Feature commit");
expect(generatedCommitSummary).not.toContain("Remote base commit");
expect(generatedCommitSummary).not.toContain("Later main commit");
expect(generatedDiffSummary).toContain("feature.txt");
expect(generatedDiffSummary).not.toContain("later-main.txt");
expect(generatedDiffPatch).toContain("feature.txt");
expect(generatedDiffPatch).not.toContain("later-main.txt");
}),
);

Expand Down
10 changes: 6 additions & 4 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2282,13 +2282,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const readRangeContext: GitVcsDriver.GitVcsDriver["Service"]["readRangeContext"] = Effect.fn(
"readRangeContext",
)(function* (cwd, baseRef) {
const range = `${baseRef}..HEAD`;
const commitRange = `${baseRef}..HEAD`;
// PR diffs start at the common ancestor when the base branch has advanced.
const diffRange = `${baseRef}...HEAD`;
const [commitSummary, diffSummary, diffPatch] = yield* Effect.all(
[
runGitStdoutWithOptions(
"GitVcsDriver.readRangeContext.log",
cwd,
["log", "--oneline", range],
["log", "--oneline", commitRange],
{
maxOutputBytes: RANGE_COMMIT_SUMMARY_MAX_OUTPUT_BYTES,
appendTruncationMarker: true,
Expand All @@ -2297,7 +2299,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
runGitStdoutWithOptions(
"GitVcsDriver.readRangeContext.diffStat",
cwd,
["diff", "--stat", range],
["diff", "--stat", diffRange],
{
maxOutputBytes: RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES,
appendTruncationMarker: true,
Expand All @@ -2306,7 +2308,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
runGitStdoutWithOptions(
"GitVcsDriver.readRangeContext.diffPatch",
cwd,
["diff", "--no-ext-diff", "--patch", "--minimal", range],
["diff", "--no-ext-diff", "--patch", "--minimal", diffRange],
{
maxOutputBytes: RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES,
appendTruncationMarker: true,
Expand Down
Loading