From d7d84de73f5ab8f05506496203fcf3fcaee44c5b Mon Sep 17 00:00:00 2001 From: Kyle Farnung Date: Fri, 16 Jun 2017 18:44:16 -0700 Subject: [PATCH] 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: https://github.com/nodejs/node-chakracore/pull/308 Reviewed-By: Kunal Pathak Reviewed-By: Oguz Bastemur --- deps/chakrashim/tools/update-changelog.js | 34 +++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/deps/chakrashim/tools/update-changelog.js b/deps/chakrashim/tools/update-changelog.js index 7cd1a5dbab6..5c92ff04f70 100644 --- a/deps/chakrashim/tools/update-changelog.js +++ b/deps/chakrashim/tools/update-changelog.js @@ -56,6 +56,7 @@ function loadChangelogFile() { while (changeLog.length < 2) { changeLog.push(''); } + loadGitReleaseTags(); }); } @@ -84,8 +85,19 @@ function filterReleaseTags(releaseTag) { return branches.split(/\n/).some((x) => {return x.startsWith('* ');}); } +function compareReleasesByDate(a, b) { + if (a.date < b.date) { + return -1; + } else if (a.date > b.date) { + return 1; + } else { + return 0; + } +} + // Match last release, figure out next release and update ranges function matchReleases(releaseTags, lastRelease) { + releaseTags.sort(compareReleasesByDate); releaseTags = releaseTags.filter(filterReleaseTags); var ver; command_pipe(process.argv[0], ['--version'], @@ -119,6 +131,9 @@ function matchReleases(releaseTags, lastRelease) { 'Please fetch release tags (git fetch --tags ...)'); } releaseTags.splice(0, lastIndex); + } else { + // Don't look at commits older than `47000c74f4~1` + releaseTags.splice(0, 0, { commit: "47000c74f4~1" }); } // Last range to be updated @@ -147,14 +162,17 @@ function updateChangelogs(releaseTags) { } }, () => { - var output = '## ' + next.date + ", " + next.name + - '\n\n### Commits\n\n'; - commits.forEach(c => { - const sha = c.commit; - output += `* [[\`${sha}\`] (${commitUrl + sha})] - ${c.subject}\n`; - }); - - changeLog.splice(2, 0, output); + if (commits.length > 0) { + var output = '## ' + next.date + ", " + next.name + + '\n\n### Commits\n\n'; + commits.forEach(c => { + const sha = c.commit; + output += `* [[\`${sha}\`](${commitUrl + sha})] - ${c.subject}\n`; + }); + + changeLog.splice(2, 0, output); + } + updateChangelogs(releaseTags); }); } else {