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

Commit

Permalink
chakrashim: more update-changelog fixes
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Reviewed-By: Oguz Bastemur <[email protected]>
  • Loading branch information
kfarnung committed Jun 19, 2017
1 parent cc4fa1f commit d7d84de
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions deps/chakrashim/tools/update-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function loadChangelogFile() {
while (changeLog.length < 2) {
changeLog.push('');
}

loadGitReleaseTags();
});
}
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d7d84de

Please sign in to comment.