Skip to content

Commit 416b60e

Browse files
authored
Merge pull request #23 from kubit-ui/fix/changeset-links-changelog
fix: modify changelog showing links
2 parents 5cd9930 + 6a3108f commit 416b60e

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

.changeset/changelog-formatter.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
/**
22
* Custom Changesets changelog formatter
3-
* Generates clean, professional changelog entries without technical noise
3+
* Generates clean, professional changelog entries with PR links
44
*/
55

6-
const getReleaseLine = async (changeset, _type) => {
6+
const getReleaseLine = async (changeset, _type, options) => {
77
const [firstLine, ...futureLines] = changeset.summary.split('\n').map(l => l.trimEnd());
88

9-
// Clean up the first line - remove conventional commit prefix if present
9+
// Extract PR number if present (format: "PR: #123")
10+
const prMatch = changeset.summary.match(/PR:\s*#(\d+)/);
11+
const prNumber = prMatch ? prMatch[1] : null;
12+
13+
// Clean up the first line - remove conventional commit prefix and PR reference
1014
let cleanFirstLine = firstLine
1115
.replace(
1216
/^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|break|breaking)(\(.+?\))?:\s*/i,
1317
''
1418
)
19+
.replace(/PR:\s*#\d+/g, '')
1520
.trim();
1621

1722
// Capitalize first letter
1823
cleanFirstLine = cleanFirstLine.charAt(0).toUpperCase() + cleanFirstLine.slice(1);
1924

25+
// Build the changelog entry
2026
let returnVal = `- ${cleanFirstLine}`;
2127

22-
if (futureLines.length > 0) {
23-
returnVal += `\n${futureLines.map(l => ` ${l}`).join('\n')}`;
28+
// Add PR link if available
29+
if (prNumber && options?.repo) {
30+
returnVal += ` ([#${prNumber}](https://github.com/${options.repo}/pull/${prNumber}))`;
31+
}
32+
33+
// Add additional lines if present (excluding PR reference line)
34+
const additionalLines = futureLines.filter(line => !line.match(/PR:\s*#\d+/));
35+
if (additionalLines.length > 0) {
36+
returnVal += `\n${additionalLines.map(l => ` ${l}`).join('\n')}`;
2437
}
2538

2639
return returnVal;

.changeset/config.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3-
"changelog": ["./changelog-formatter.js", null],
3+
"changelog": [
4+
"./changelog-formatter.js",
5+
{
6+
"repo": "kubit-ui/vscode-kubito"
7+
}
8+
],
49
"commit": false,
510
"fixed": [],
611
"linked": [],

0 commit comments

Comments
 (0)