Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull out dependencies into their own section #5

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)*