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