Skip to content

Commit c7ebb3a

Browse files
committed
fix(github): separate as-is packages from real releases in PR body
generatePullRequestBody now splits updates into three template variables: - it.releases — packages with an actual version bump - it.asIs — packages keeping their current version (changeKind === "as-is") - it.packages — all updates (preserved for custom template backward compat) The default PR body template uses it.releases for the main release list and shows as-is packages in a separate "keeping their current version" section. Previously as-is packages rendered as "1.0.0 → 1.0.0 (none)" in the main list, which made it look like nothing was being released. Closes #13
1 parent 9422729 commit c7ebb3a

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

src/core/github.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,18 @@ export function generatePullRequestBody(updates: PackageRelease[], body?: string
429429

430430
const bodyTemplate = body ? dedentString(body) : DEFAULT_PR_BODY_TEMPLATE;
431431

432+
const allPackages = updates.map((u) => ({
433+
name: u.package.name,
434+
currentVersion: u.currentVersion,
435+
newVersion: u.newVersion,
436+
bumpType: u.bumpType,
437+
hasDirectChanges: u.hasDirectChanges,
438+
changeKind: u.changeKind,
439+
}));
440+
432441
return eta.renderString(bodyTemplate, {
433-
packages: updates.map((u) => ({
434-
name: u.package.name,
435-
currentVersion: u.currentVersion,
436-
newVersion: u.newVersion,
437-
bumpType: u.bumpType,
438-
hasDirectChanges: u.hasDirectChanges,
439-
})),
442+
packages: allPackages,
443+
releases: allPackages.filter((p) => p.changeKind !== "as-is"),
444+
asIs: allPackages.filter((p) => p.changeKind === "as-is"),
440445
});
441446
}

src/options.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,23 @@ export type NormalizedReleaseScriptsOptions = DeepRequired<Omit<ReleaseScriptsOp
6969
export const DEFAULT_PR_BODY_TEMPLATE = dedent`
7070
This PR was automatically generated by the UCD release scripts.
7171
72+
<% if (it.releases.length > 0) { %>
7273
The following packages have been prepared for release:
7374
74-
<% if (it.packages.length > 0) { %>
75-
<% it.packages.forEach((pkg) => { %>
75+
<% it.releases.forEach((pkg) => { %>
7676
- **<%= pkg.name %>**: <%= pkg.currentVersion %> → <%= pkg.newVersion %> (<%= pkg.bumpType %>)
7777
<% }) %>
7878
<% } else { %>
7979
There are no packages to release.
8080
<% } %>
81+
<% if (it.asIs.length > 0) { %>
82+
83+
The following packages are keeping their current version:
84+
85+
<% it.asIs.forEach((pkg) => { %>
86+
- **<%= pkg.name %>**: <%= pkg.currentVersion %> (as-is)
87+
<% }) %>
88+
<% } %>
8189
8290
Please review the changes and merge when ready.
8391

test/core/github.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,44 @@ describe("generatePullRequestBody", () => {
287287
);
288288
expect(body).toContain("@scope/pkg → 1.1.0");
289289
});
290+
291+
it("separates as-is packages from real releases in the default template", () => {
292+
const body = generatePullRequestBody([
293+
{
294+
package: { name: "@scope/released", version: "1.0.0", path: "/workspace/a", packageJson: { name: "@scope/released", version: "1.0.0" }, workspaceDependencies: [], workspaceDevDependencies: [] },
295+
currentVersion: "1.0.0",
296+
newVersion: "2.0.0",
297+
bumpType: "major",
298+
hasDirectChanges: true,
299+
changeKind: "auto",
300+
},
301+
{
302+
package: { name: "@scope/kept", version: "3.0.0", path: "/workspace/b", packageJson: { name: "@scope/kept", version: "3.0.0" }, workspaceDependencies: [], workspaceDevDependencies: [] },
303+
currentVersion: "3.0.0",
304+
newVersion: "3.0.0",
305+
bumpType: "none",
306+
hasDirectChanges: true,
307+
changeKind: "as-is",
308+
},
309+
]);
310+
expect(body).toContain("@scope/released");
311+
expect(body).toContain("1.0.0 → 2.0.0 (major)");
312+
expect(body).toContain("@scope/kept");
313+
expect(body).toContain("3.0.0 (as-is)");
314+
expect(body).toContain("keeping their current version");
315+
});
316+
317+
it("shows 'no packages to release' when all updates are as-is", () => {
318+
const body = generatePullRequestBody([{
319+
package: { name: "@scope/kept", version: "1.0.0", path: "/workspace", packageJson: { name: "@scope/kept", version: "1.0.0" }, workspaceDependencies: [], workspaceDevDependencies: [] },
320+
currentVersion: "1.0.0",
321+
newVersion: "1.0.0",
322+
bumpType: "none",
323+
hasDirectChanges: true,
324+
changeKind: "as-is",
325+
}]);
326+
expect(body).toContain("no packages to release");
327+
expect(body).toContain("@scope/kept");
328+
expect(body).toContain("keeping their current version");
329+
});
290330
});

0 commit comments

Comments
 (0)