Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Add support for exclude: true (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Oct 21, 2020
1 parent 8d79eb1 commit f9cec2b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion distribution/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion generate-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const execFile = util.promisify(require('child_process').execFile);

const repoURL = process.env.GITHUB_SERVER_URL + '/' + process.env.GITHUB_REPOSITORY;

const excludePreset = /^meta|^document|^lint|^refactor|readme|dependencies|^v?\d+\.\d+\.\d+/i;

async function generateReleaseNotes({
range,
exclude = '',
Expand All @@ -17,7 +19,8 @@ async function generateReleaseNotes({
}));

if (exclude) {
const regex = new RegExp(exclude);
// Booleans aren't currently supported: https://github.com/actions/toolkit/issues/361
const regex = exclude === 'true' || exclude === true ? excludePreset : new RegExp(exclude);
commits = commits.filter(({title}) => !regex.test(title));
}

Expand Down
15 changes: 15 additions & 0 deletions generate-release-notes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,18 @@ test('generates changelog with custom exclude', async () => {
- Fix padding issue in Milestones
`));
});

test('generates changelog with exclude preset', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {title}',
releaseTemplate: '{commits}',
exclude: 'true'
});

expect(output).toEqual(dedent(`
- Enable \`bypass-checks\` on more commit statuses (#3610)
- Add tooltip to \`table-input\` button (#3615)
- Fix padding issue in Milestones
`));
});
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ Markdown template for each commit entry in release notes. Available replacements
### exclude

Default: `''` <br>
Example: `'^Meta:'`
Example: `'^Meta:'` <br>
Example: `true`

Regex to exclude commits based on their title (don't include the initial and final `/`).

Setting this to `true` will enable the default preset, which may change over time, but is currently: `/^meta|^document|^lint|^refactor|readme|dependencies|^v?\d+\.\d+\.\d+/i`

### tag

Default: _latest tag available_
Expand Down

0 comments on commit f9cec2b

Please sign in to comment.