Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 360e93e

Browse files
committed
chakrashim: more update-changelog fixes
* Allow the script to find the logs for the first tag * Sort the tags by date before processing * Don't emit any empty tags PR-URL: #308 Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com> Reviewed-By: Oguz Bastemur <ogbastem@microsoft.com>
1 parent 1c364f5 commit 360e93e

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

deps/chakrashim/tools/update-changelog.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function loadChangelogFile() {
5656
while (changeLog.length < 2) {
5757
changeLog.push('');
5858
}
59+
5960
loadGitReleaseTags();
6061
});
6162
}
@@ -84,8 +85,19 @@ function filterReleaseTags(releaseTag) {
8485
return branches.split(/\n/).some((x) => {return x.startsWith('* ');});
8586
}
8687

88+
function compareReleasesByDate(a, b) {
89+
if (a.date < b.date) {
90+
return -1;
91+
} else if (a.date > b.date) {
92+
return 1;
93+
} else {
94+
return 0;
95+
}
96+
}
97+
8798
// Match last release, figure out next release and update ranges
8899
function matchReleases(releaseTags, lastRelease) {
100+
releaseTags.sort(compareReleasesByDate);
89101
releaseTags = releaseTags.filter(filterReleaseTags);
90102
var ver;
91103
command_pipe(process.argv[0], ['--version'],
@@ -119,6 +131,9 @@ function matchReleases(releaseTags, lastRelease) {
119131
'Please fetch release tags (git fetch --tags ...)');
120132
}
121133
releaseTags.splice(0, lastIndex);
134+
} else {
135+
// Don't look at commits older than `47000c74f4~1`
136+
releaseTags.splice(0, 0, { commit: "47000c74f4~1" });
122137
}
123138

124139
// Last range to be updated
@@ -147,14 +162,17 @@ function updateChangelogs(releaseTags) {
147162
}
148163
},
149164
() => {
150-
var output = '## ' + next.date + ", " + next.name +
151-
'\n\n### Commits\n\n';
152-
commits.forEach(c => {
153-
const sha = c.commit;
154-
output += `* [[\`${sha}\`] (${commitUrl + sha})] - ${c.subject}\n`;
155-
});
156-
157-
changeLog.splice(2, 0, output);
165+
if (commits.length > 0) {
166+
var output = '## ' + next.date + ", " + next.name +
167+
'\n\n### Commits\n\n';
168+
commits.forEach(c => {
169+
const sha = c.commit;
170+
output += `* [[\`${sha}\`](${commitUrl + sha})] - ${c.subject}\n`;
171+
});
172+
173+
changeLog.splice(2, 0, output);
174+
}
175+
158176
updateChangelogs(releaseTags);
159177
});
160178
} else {

0 commit comments

Comments
 (0)