Add check for logJSON (#306)

Fixes #305
This commit is contained in:
Rhys Arkins 2017-06-15 20:57:18 +02:00 committed by GitHub
parent 5befcc58f4
commit 7e43fce47b

View file

@ -58,33 +58,36 @@ async function ensurePr(upgrades) {
upgrade.changeLogToVersion upgrade.changeLogToVersion
); );
// Store changelog markdown for backwards compatibility // Store changelog markdown for backwards compatibility
config.changelog = config.changelog || changelogHelper.getMarkdown(logJSON); if (logJSON) {
upgrade.repositoryUrl = logJSON.project.repository; config.changelog =
upgrade.githubName = logJSON.project.github; config.changelog || changelogHelper.getMarkdown(logJSON);
upgrade.releases = []; upgrade.repositoryUrl = logJSON.project.repository;
logJSON.versions.forEach(version => { upgrade.githubName = logJSON.project.github;
const release = Object.assign({}, version); upgrade.releases = [];
release.date = version.date.toISOString().slice(0, 10); logJSON.versions.forEach(version => {
release.commits = []; const release = Object.assign({}, version);
if (release.changes) { release.date = version.date.toISOString().slice(0, 10);
release.changes.forEach(change => { release.commits = [];
const commit = Object.assign({}, change); if (release.changes) {
delete commit.date; release.changes.forEach(change => {
commit.shortSha = change.sha.slice(0, 7); const commit = Object.assign({}, change);
commit.url = `${logJSON.project.repository}/commit/${change.sha}`; delete commit.date;
if (change.message) { commit.shortSha = change.sha.slice(0, 7);
commit.message = change.message.split('\n')[0]; commit.url = `${logJSON.project.repository}/commit/${change.sha}`;
const re = /([\s(])#(\d+)([)\s]?)/g; if (change.message) {
commit.message = commit.message.replace( commit.message = change.message.split('\n')[0];
re, const re = /([\s(])#(\d+)([)\s]?)/g;
`$1[#$2](${upgrade.repositoryUrl}/issues/$2)$3` commit.message = commit.message.replace(
); re,
} `$1[#$2](${upgrade.repositoryUrl}/issues/$2)$3`
release.commits.push(commit); );
}); }
} release.commits.push(commit);
upgrade.releases.push(release); });
}); }
upgrade.releases.push(release);
});
}
config.upgrades.push(upgrade); config.upgrades.push(upgrade);
} }