Skip to content

Commit dc3e13e

Browse files
committed
fix(server): retain review guide excerpt length clamp
1 parent a3a3aa3 commit dc3e13e

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

‎apps/server/src/pullRequest/pullRequestReviewGuideNormalize.test.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,8 @@ describe("normalizeReviewGuide", () => {
190190
"diff --git a/src/a.ts b/src/a.ts\n--- a/src/a.ts\n+++ b/src/a.ts\n@@ -0,0 +1,60 @@\n+added",
191191
),
192192
);
193-
expect(wide.stops[0]?.excerpts).toEqual([
194-
{ ...excerpt("src/a.ts", 1, 25), caption: "Second" },
195-
{ ...excerpt("src/a.ts", 26, 45), caption: "Second" },
196-
]);
197-
expect(wide.stops[0]?.notes).toEqual([tailNote]);
193+
expect(wide.stops[0]?.excerpts).toEqual([{ ...excerpt("src/a.ts", 1, 25), caption: "Second" }]);
194+
expect(wide.stops[0]?.notes).toEqual([]);
198195
});
199196

200197
it("drops notes outside the stop's remaining excerpts", () => {

‎apps/server/src/pullRequest/pullRequestReviewGuideNormalize.ts‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,10 @@ function mergeExcerpts(
111111
other === first ? [combined] : touches(other) ? [] : [other],
112112
);
113113
}
114-
return merged.flatMap((excerpt) => {
115-
const chunks: Array<PullRequestReviewGuideExcerpt> = [];
116-
for (let start = excerpt.start; start <= excerpt.end; start += MAX_EXCERPT_LINES) {
117-
chunks.push({
118-
...excerpt,
119-
start,
120-
end: Math.min(excerpt.end, start + MAX_EXCERPT_LINES - 1),
121-
});
122-
}
123-
return chunks;
124-
});
114+
return merged.map((excerpt) => ({
115+
...excerpt,
116+
end: Math.min(excerpt.end, excerpt.start + MAX_EXCERPT_LINES - 1),
117+
}));
125118
}
126119

127120
const nonEmpty = (value: string) => value.trim() !== "";

0 commit comments

Comments
 (0)