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

Commit

Permalink
🐛 Fix release note return null when not found
Browse files Browse the repository at this point in the history
Fixed #62
  • Loading branch information
Leko committed Jul 4, 2018
1 parent 6cb29e0 commit 6f6f5a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/hothouse/src/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ export default class Engine {

createBranchName(updateChunk: UpdateChunk): string {
const now = new Date();
const branchName = `hothouse-${now.getFullYear()}${now.getMonth() +
1}${now.getDate()}`;
const branchName = `hothouse-${[
now.getFullYear(),
String(now.getMonth()).padStart(2, "0"),
String(now.getDate()).padStart(2, "0"),
String(now.getHours()).padStart(2, "0"),
String(now.getMinutes()).padStart(2, "0"),
String(now.getSeconds()).padStart(2, "0")
].join("")}`;
debug(`Branch name created: ${branchName} with ${now.toISOString()}`);
return `${branchName}-${updateChunk.slugify()}`;
}
Expand Down Expand Up @@ -328,7 +334,7 @@ export default class Engine {
meta.repository.url,
latestTag
);
return md2html(releaseNote);
return releaseNote ? md2html(releaseNote) : null;
} catch (error) {
debug(
`An error occured during fetch release note in ${meta.name}@${
Expand Down
4 changes: 3 additions & 1 deletion packages/hothouse/src/Hosting/GitHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export default class GitHub implements Hosting {
const client = this.prepare(token);
const [owner, repo] = parseRepositoryUrl(repositoryUrl);
try {
return await client.repos.getReleaseByTag({ owner, repo, tag });
const release = await client.repos.getReleaseByTag({ owner, repo, tag });
const markdown = `# ${release.data.name}\n${release.data.body}`;
return markdown;
} catch (error) {
if (JSON.parse(error.message).message === "Not Found") {
return null;
Expand Down

0 comments on commit 6f6f5a5

Please sign in to comment.