@@ -24,7 +24,7 @@ const semver = require('semver');
2424
2525// Ignore commits that have specific patterns in commit message, it's ok for these commits to be
2626// present only in one branch. Ignoring them reduced the "noise" in the final output.
27- const ignorePatterns = [
27+ const ignoreCommitPatterns = [
2828 'release:' ,
2929 'docs: release notes' ,
3030 // These commits are created to update cli command docs sources with the most recent sha (stored
@@ -34,6 +34,13 @@ const ignorePatterns = [
3434 'build(docs-infra): upgrade cli command docs sources' ,
3535] ;
3636
37+ // Ignore feature commits that have specific patterns in commit message, it's ok for these commits
38+ // to be present in patch branch.
39+ const ignoreFeatureCheckPatterns = [
40+ // It is ok and in fact desirable for dev-infra features to be on the patch branch.
41+ 'feat(dev-infra):'
42+ ] ;
43+
3744// String to be displayed as a version for initial commits in a branch
3845// (before first release from that branch).
3946const initialVersion = 'initial' ;
@@ -59,6 +66,11 @@ function maybeExtractReleaseVersion(commit) {
5966 return matches ? matches [ 1 ] || matches [ 2 ] : null ;
6067}
6168
69+ // Checks whether commit message matches any patterns in ignore list.
70+ function shouldIgnoreCommit ( commitMessage , ignorePatterns ) {
71+ return ignorePatterns . some ( pattern => commitMessage . indexOf ( pattern ) > - 1 ) ;
72+ }
73+
6274/**
6375 * @param rawGitCommits
6476 * @returns {Map<string, [string, string]> } - Map of commit message to [commit info, version]
@@ -67,21 +79,21 @@ function collectCommitsAsMap(rawGitCommits) {
6779 const commits = toArray ( rawGitCommits ) ;
6880 const commitsMap = new Map ( ) ;
6981 let version = initialVersion ;
70- commits . reverse ( ) . forEach ( ( item ) => {
71- const skip = ignorePatterns . some ( pattern => item . indexOf ( pattern ) > - 1 ) ;
82+ commits . reverse ( ) . forEach ( ( commit ) => {
83+ const ignore = shouldIgnoreCommit ( commit , ignoreCommitPatterns ) ;
7284 // Keep track of the current version while going though the list of commits, so that we can use
7385 // this information in the output (i.e. display a version when a commit was introduced).
74- version = maybeExtractReleaseVersion ( item ) || version ;
75- if ( ! skip ) {
86+ version = maybeExtractReleaseVersion ( commit ) || version ;
87+ if ( ! ignore ) {
7688 // Extract original commit description from commit message, so that we can find matching
7789 // commit in other commit range. For example, for the following commit message:
7890 //
7991 // 15d3e741e9 feat: update the locale files (#33556)
8092 //
8193 // we extract only "feat: update the locale files" part and use it as a key, since commit SHA
8294 // and PR number may be different for the same commit in master and patch branches.
83- const key = item . slice ( 11 ) . replace ( / \( \# \d + \) / g, '' ) . trim ( ) ;
84- commitsMap . set ( key , [ item , version ] ) ;
95+ const key = commit . slice ( 11 ) . replace ( / \( \# \d + \) / g, '' ) . trim ( ) ;
96+ commitsMap . set ( key , [ commit , version ] ) ;
8597 }
8698 } ) ;
8799 return commitsMap ;
@@ -113,7 +125,7 @@ function diff(mapA, mapB) {
113125 */
114126function listFeatures ( commitsMap ) {
115127 return Array . from ( commitsMap . keys ( ) ) . reduce ( ( result , key ) => {
116- if ( key . startsWith ( 'feat' ) ) {
128+ if ( key . startsWith ( 'feat' ) && ! shouldIgnoreCommit ( key , ignoreFeatureCheckPatterns ) ) {
117129 const value = commitsMap . get ( key ) ;
118130 result . push ( getCommitInfoAsString ( value [ 1 ] , value [ 0 ] ) ) ;
119131 }
0 commit comments