pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/angular/angular/commit/82a2207f4a5cc92d57400d3e60c5aecff7b2f173

97560d244c08.css" /> build: filter out duplicate cherry-picked commits in changelog (#37956) · angular/angular@82a2207 · GitHub
Skip to content

Commit 82a2207

Browse files
devversionalxhub
authored andcommitted
build: filter out duplicate cherry-picked commits in changelog (#37956)
Often changelogs are generated from the patch branch and then cherry-picked into the `CHANGELOG.md` file in `master` for better access and readability. This is problematic though as `conventional-changelog` (the tool we use for generating the changelog), will duplicate commits when a future changelog is generated from `master` then (i.e. for a new minor release). This happens because conventional-changelog always generates the changelog from the latest tag in a given branch to `HEAD`. The tag in the patch branch does not correspond to any SHA in `master` so the intersection of commits is not automatically omitted. We work around this naively (until we have a better tool provided by dev-infra), by deduping commits that are already part of the changelog. This has proven to work as expected in the components repo. PR Close #37956
1 parent 289a96b commit 82a2207

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

tools/gulp-tasks/changelog.js

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
const {readFileSync} = require('fs');
10+
const {bold, yellow} = require('chalk');
11+
912
module.exports = (gulp) => () => {
1013
const conventionalChangelog = require('gulp-conventional-changelog');
1114
const ignoredScopes = [
@@ -16,11 +19,55 @@ module.exports = (gulp) => () => {
1619
];
1720

1821
return gulp.src('CHANGELOG.md')
19-
.pipe(conventionalChangelog({preset: 'angular'}, {}, {
20-
// Ignore commits that start with `<type>(<scope>)` for any of the ignored scopes.
21-
extendedRegexp: true,
22-
grep: `^[^(]+\\((${ignoredScopes.join('|')})\\)`,
23-
invertGrep: true,
24-
}))
22+
.pipe(conventionalChangelog(
23+
/* core options */ {preset: 'angular'},
24+
/* context options */ {},
25+
/* raw-commit options */ {
26+
// Ignore commits that start with `<type>(<scope>)` for any of the ignored scopes.
27+
extendedRegexp: true,
28+
grep: `^[^(]+\\((${ignoredScopes.join('|')})\\)`,
29+
invertGrep: true,
30+
},
31+
/* commit parser options */ null,
32+
/* writer options*/ createDedupeWriterOptions()))
2533
.pipe(gulp.dest('./'));
2634
};
35+
36+
/**
37+
* Creates changelog writer options which ensure that commits are not showing up multiple times.
38+
* Commits can show up multiple times if a changelog has been generated on a publish branch
39+
* and has been cherry-picked into "master". In that case, the changelog will already contain
40+
* commits from master which might be added to the changelog again. This is because usually
41+
* patch and minor releases are tagged from the publish branches and therefore
42+
* conventional-changelog tries to build the changelog from last minor version to HEAD when a
43+
* new minor version is being published from the "master" branch. We naively match commit
44+
* headers as otherwise we would need to query Git and diff commits between a given patch branch.
45+
* The commit header is reliable enough as it contains a direct reference to the source PR.
46+
*/
47+
function createDedupeWriterOptions() {
48+
const existingChangelogContent = readFileSync('CHANGELOG.md', 'utf8');
49+
50+
return {
51+
// Specify a writer option that can be used to modify the content of a new changelog section.
52+
// See: conventional-changelog/tree/master/packages/conventional-changelog-writer
53+
finalizeContext: (context) => {
54+
context.commitGroups = context.commitGroups.filter((group) => {
55+
group.commits = group.commits.filter((commit) => {
56+
// NOTE: We cannot compare the SHAs because the commits will have a different SHA
57+
// if they are being cherry-picked into a different branch.
58+
if (existingChangelogContent.includes(commit.subject)) {
59+
console.info(yellow(` ↺ Skipping duplicate: "${bold(commit.header)}"`));
60+
return false;
61+
}
62+
return true;
63+
});
64+
65+
// Filter out commit groups which don't have any commits. Commit groups will become
66+
// empty if we filter out all duplicated commits.
67+
return group.commits.length !== 0;
68+
});
69+
70+
return context;
71+
}
72+
};
73+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy