Skip to content

Commit 74d8b23

Browse files
AndrewKushnirkara
authored andcommitted
fix(dev-infra): misc fixes for the compare master and patch script (angular#37150)
This commit includes a couple minor fixes for the script that compares master and patch branch: - take only relevant release commit into account while generating the diff - fix the initial version display (avoid '+' sign from being added) - removes obsolete parameter that was needed for v9.0.x branch only PR Close angular#37150
1 parent 7543e59 commit 74d8b23

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

scripts/compare-master-to-patch.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ const ignorePatterns = [
3434
'build(docs-infra): upgrade cli command docs sources',
3535
];
3636

37-
// Limit the log history to start from v9.0.0 release date.
38-
// Note: this is needed only for 9.0.x branch to avoid RC history.
39-
// Remove it once `9.1.x` branch is created.
40-
const after = '--after="2020-02-05"';
37+
// String to be displayed as a version for initial commits in a branch
38+
// (before first release from that branch).
39+
const initialVersion = 'initial';
4140

4241
// Helper methods
4342

@@ -55,7 +54,7 @@ function toArray(rawGitCommandOutput) {
5554
}
5655

5756
function maybeExtractReleaseVersion(commit) {
58-
const versionRegex = /release: cut the (.*?) release|docs: release notes for the (.*?) release/;
57+
const versionRegex = /release: cut the (.*?) release/;
5958
const matches = commit.match(versionRegex);
6059
return matches ? matches[1] || matches[2] : null;
6160
}
@@ -67,7 +66,7 @@ function maybeExtractReleaseVersion(commit) {
6766
function collectCommitsAsMap(rawGitCommits) {
6867
const commits = toArray(rawGitCommits);
6968
const commitsMap = new Map();
70-
let version = 'initial';
69+
let version = initialVersion;
7170
commits.reverse().forEach((item) => {
7271
const skip = ignorePatterns.some(pattern => item.indexOf(pattern) > -1);
7372
// Keep track of the current version while going though the list of commits, so that we can use
@@ -89,7 +88,8 @@ function collectCommitsAsMap(rawGitCommits) {
8988
}
9089

9190
function getCommitInfoAsString(version, commitInfo) {
92-
return `[${version}+] ${commitInfo}`;
91+
const formattedVersion = version === initialVersion ? version : `${version}+`;
92+
return `[${formattedVersion}] ${commitInfo}`;
9393
}
9494

9595
/**
@@ -149,9 +149,9 @@ function main() {
149149

150150
// Extract master-only and patch-only commits using `git log` command.
151151
const masterCommits = execGitCommand(
152-
`git log --cherry-pick --oneline --right-only ${after} upstream/${branch}...upstream/master`);
152+
`git log --cherry-pick --oneline --right-only upstream/${branch}...upstream/master`);
153153
const patchCommits = execGitCommand(
154-
`git log --cherry-pick --oneline --left-only ${after} upstream/${branch}...upstream/master`);
154+
`git log --cherry-pick --oneline --left-only upstream/${branch}...upstream/master`);
155155

156156
// Post-process commits and convert raw data into a Map, so that we can diff it easier.
157157
const masterCommitsMap = collectCommitsAsMap(masterCommits);

0 commit comments

Comments
 (0)