Skip to content

Commit

Permalink
Pull out dependencies into their own section
Browse files Browse the repository at this point in the history
Collapse it by default because it's not really that interesting
  • Loading branch information
jrjohnson committed Feb 7, 2019
1 parent 0a5cda0 commit aaf3c32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
18 changes: 9 additions & 9 deletions lib/generateReleaseNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,27 @@ const getClosedIssues = async (octokit, owner, repo, since) => {
return {title, number, url: html_url, pull_request, user: minimalUser, labels: labelTitles};
});
const skippedIssues = minimalIssues.filter(({labels}) => {
return !labels.includes('greenkeeper') &&
!labels.includes('duplicate') &&
return !labels.includes('duplicate') &&
!labels.includes('wontfix/works for me')
;
});
const pullRequests = skippedIssues.filter(({pull_request}) => pull_request);
const bugs = skippedIssues.filter(obj => obj.labels.includes('bug') && !pullRequests.includes(obj));
const enhancements = skippedIssues.filter(obj => obj.labels.includes('enhancement') && !bugs.includes(obj) && !pullRequests.includes(obj));
const remaining = skippedIssues.filter(obj => !pullRequests.includes(obj) && !bugs.includes(obj) && !enhancements.includes(obj));
const dependencies = skippedIssues.filter(obj => obj.labels.includes('dependencies'));
const pullRequests = skippedIssues.filter(obj => obj.pull_request && !dependencies.includes(obj));
const bugs = skippedIssues.filter(obj => obj.labels.includes('bug') && !pullRequests.includes(obj) && !dependencies.includes(obj));
const enhancements = skippedIssues.filter(obj => obj.labels.includes('enhancement') && !bugs.includes(obj) && !pullRequests.includes(obj) && !dependencies.includes(obj));
const remaining = skippedIssues.filter(obj => !dependencies.includes(obj) && !pullRequests.includes(obj) && !bugs.includes(obj) && !enhancements.includes(obj));

return {pullRequests, bugs, enhancements, remaining};
return { dependencies, pullRequests, bugs, enhancements, remaining };
};

const generateReleaseNotes = async (octokit, owner, repo, sinceTagName, releaseTagName) => {
debug(`Creating ${releaseTagName} release notes for ${owner}/${repo} at ${releaseTagName}`);
const sinceTag = await getTagInfo(octokit, owner, repo, sinceTagName);
const {pullRequests, bugs, enhancements, remaining} = await getClosedIssues(octokit, owner, repo, sinceTag.date);
const {dependencies, pullRequests, bugs, enhancements, remaining} = await getClosedIssues(octokit, owner, repo, sinceTag.date);
const template = await fs.readFile(path.join(__dirname, '../templates/release-notes.hbs'));
const hbs = Handlebars.compile(template.toString());
const repositoryUrl = `https://github.com/${owner}/${repo}`;
const markdown = hbs({pullRequests, bugs, enhancements, remaining, releaseTagName, sinceTagName, repositoryUrl});
const markdown = hbs({dependencies, pullRequests, bugs, enhancements, remaining, releaseTagName, sinceTagName, repositoryUrl});

return markdown;
};
Expand Down
16 changes: 11 additions & 5 deletions templates/release-notes.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# {{releaseTagName}}

## [{{releaseTagName}}]({{repositoryUrl}}/tree/{{releaseTagName}})

[Full Changelog]({{repositoryUrl}}/compare/{{sinceTagName}}...{{releaseTagName}})
Expand All @@ -12,21 +10,29 @@
- {{issue.title}} [\#{{issue.number}}]({{issue.url}})
{{/each}}
{{/if}}

{{/inline}}

{{> issueBlock title='Fixed Bugs' issues=bugs}}

{{> issueBlock title='Added Enhancements' issues=enhancements}}

{{> issueBlock title='Closed issues' issues=remaining}}

{{#if pullRequests.length}}
**Merged pull requests:**

{{#each pullRequests as |issue|}}
- {{issue.title}} [\#{{issue.number}}]({{issue.url}}) [@{{issue.user.login}}]({{issue.user.url}})
{{/each}}

{{/if}}
{{#if dependencies.length}}
<details>
<summary>Updated Dependencies:</summary>

{{#each dependencies as |issue|}}
- {{issue.title}} [\#{{issue.number}}]({{issue.url}})
{{/each}}

</details>

{{/if}}
\* *These notes were automatically created by [generate-github-release-notes](https://github.com/jrjohnson/generate-github-release-notes)*

0 comments on commit aaf3c32

Please sign in to comment.