fix(dev-infra): misc fixes for the compare master and patch script (#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 #37150
This commit is contained in:
parent
89995075e6
commit
8004eb0eec
|
@ -34,10 +34,9 @@ const ignorePatterns = [
|
||||||
'build(docs-infra): upgrade cli command docs sources',
|
'build(docs-infra): upgrade cli command docs sources',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Limit the log history to start from v9.0.0 release date.
|
// String to be displayed as a version for initial commits in a branch
|
||||||
// Note: this is needed only for 9.0.x branch to avoid RC history.
|
// (before first release from that branch).
|
||||||
// Remove it once `9.1.x` branch is created.
|
const initialVersion = 'initial';
|
||||||
const after = '--after="2020-02-05"';
|
|
||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ function toArray(rawGitCommandOutput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybeExtractReleaseVersion(commit) {
|
function maybeExtractReleaseVersion(commit) {
|
||||||
const versionRegex = /release: cut the (.*?) release|docs: release notes for the (.*?) release/;
|
const versionRegex = /release: cut the (.*?) release/;
|
||||||
const matches = commit.match(versionRegex);
|
const matches = commit.match(versionRegex);
|
||||||
return matches ? matches[1] || matches[2] : null;
|
return matches ? matches[1] || matches[2] : null;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +66,7 @@ function maybeExtractReleaseVersion(commit) {
|
||||||
function collectCommitsAsMap(rawGitCommits) {
|
function collectCommitsAsMap(rawGitCommits) {
|
||||||
const commits = toArray(rawGitCommits);
|
const commits = toArray(rawGitCommits);
|
||||||
const commitsMap = new Map();
|
const commitsMap = new Map();
|
||||||
let version = 'initial';
|
let version = initialVersion;
|
||||||
commits.reverse().forEach((item) => {
|
commits.reverse().forEach((item) => {
|
||||||
const skip = ignorePatterns.some(pattern => item.indexOf(pattern) > -1);
|
const skip = ignorePatterns.some(pattern => item.indexOf(pattern) > -1);
|
||||||
// Keep track of the current version while going though the list of commits, so that we can use
|
// 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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommitInfoAsString(version, commitInfo) {
|
function getCommitInfoAsString(version, commitInfo) {
|
||||||
return `[${version}+] ${commitInfo}`;
|
const formattedVersion = version === initialVersion ? version : `${version}+`;
|
||||||
|
return `[${formattedVersion}] ${commitInfo}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,9 +149,9 @@ function main() {
|
||||||
|
|
||||||
// Extract master-only and patch-only commits using `git log` command.
|
// Extract master-only and patch-only commits using `git log` command.
|
||||||
const masterCommits = execGitCommand(
|
const masterCommits = execGitCommand(
|
||||||
`git log --cherry-pick --oneline --right-only ${after} upstream/${branch}...upstream/master`);
|
`git log --cherry-pick --oneline --right-only upstream/${branch}...upstream/master`);
|
||||||
const patchCommits = execGitCommand(
|
const patchCommits = execGitCommand(
|
||||||
`git log --cherry-pick --oneline --left-only ${after} upstream/${branch}...upstream/master`);
|
`git log --cherry-pick --oneline --left-only upstream/${branch}...upstream/master`);
|
||||||
|
|
||||||
// Post-process commits and convert raw data into a Map, so that we can diff it easier.
|
// Post-process commits and convert raw data into a Map, so that we can diff it easier.
|
||||||
const masterCommitsMap = collectCommitsAsMap(masterCommits);
|
const masterCommitsMap = collectCommitsAsMap(masterCommits);
|
||||||
|
|
Loading…
Reference in New Issue