Skip to content

Commit 69da639

Browse files
atscottthePunderWoman
authored andcommitted
build: improve changelog generation and tag fetching in release script
- Fetch tags explicitly to ensure local availability. - Implement `getPreviousTag` to reliably determine the base for changelog generation, falling back to the latest `vsix-*` tag if the specific previous version tag is missing. - Filter changelog commits by subject to exclude duplicates (e.g. cherry-picks) that are already present in the previous release history but have different hashes.
1 parent 7875577 commit 69da639

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

vscode-ng-language-service/tools/release.mts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,39 @@ async function prepareReleasePullRequest(
241241
*/
242242
async function generateChangelog(fromVersion: string, toVersion: string): Promise<string> {
243243
const previousTag = await getPreviousTag(fromVersion);
244-
let {stdout: commits} = await exec(
244+
245+
// Get all subjects from the previous release to filter out duplicates (cherry-picks).
246+
const {stdout: existingSubjectsOutput} = await exec(
247+
`git log ${previousTag} -E ` +
248+
'--grep="^(feat|fix|perf)\\((vscode-extension|language-server|language-service)\\):" ' +
249+
'--format="%s"',
250+
);
251+
const existingSubjects = new Set(
252+
existingSubjectsOutput
253+
.trim()
254+
.split('\n')
255+
.map((s) => s.trim()),
256+
);
257+
258+
const {stdout: newCommitsRaw} = await exec(
245259
`git log --left-only FETCH_HEAD...${previousTag} -E ` +
246260
'--grep="^(feat|fix|perf)\\((vscode-extension|language-server|language-service)\\):" ' +
247-
'--format="format:- %s ([%h](https://github.com/angular/angular/commit/%H))"',
261+
'--format="%s|%h|%H"',
248262
);
249263

250-
commits = commits.trim();
264+
const commits = newCommitsRaw
265+
.trim()
266+
.split('\n')
267+
.filter((line) => {
268+
if (!line) return false;
269+
const [subject, shortHash, hash] = line.split('|');
270+
return !existingSubjects.has(subject.trim());
271+
})
272+
.map((line) => {
273+
const [subject, shortHash, hash] = line.split('|');
274+
return `- ${subject} ([${shortHash}](https://github.com/angular/angular/commit/${hash}))`;
275+
})
276+
.join('\n');
251277

252278
const now = new Date();
253279
const date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;

0 commit comments

Comments
 (0)