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

fix: dont create chore only PRs #433

Merged
merged 1 commit into from
Apr 22, 2024
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
10 changes: 5 additions & 5 deletions lib/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ module.exports = {
},
allowedPackages: [],
changelogTypes: [
{ type: 'feat', section: 'Features', hidden: false, collapse: false },
{ type: 'fix', section: 'Bug Fixes', hidden: false, collapse: false },
{ type: 'docs', section: 'Documentation', hidden: false, collapse: false },
{ type: 'deps', section: 'Dependencies', hidden: false, collapse: false },
{ type: 'chore', section: 'Chores', hidden: false, collapse: false },
{ type: 'feat', section: 'Features', hidden: false },
{ type: 'fix', section: 'Bug Fixes', hidden: false },
{ type: 'docs', section: 'Documentation', hidden: false },
{ type: 'deps', section: 'Dependencies', hidden: false },
{ type: 'chore', section: 'Chores', hidden: true },
],
}
28 changes: 14 additions & 14 deletions lib/release/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ class Changelog {
}

#getEntries (type) {
const section = this.#sections[type]
const entries = this.#entries[type].map(list)
// Ignoring coverage until we use this again
/* istanbul ignore next */
if (section?.collapse) {
entries.unshift('<details><summary>Commits</summary>\n')
entries.push('\n</details>')
}
return entries.join('\n')
return this.#entries[type].map(list).join('\n')
}

toString () {
const body = [this.#title]
const includedTypes = []

for (const type of this.#types) {
const title = this.#titles[type]
if (this.#entries[type]?.length) {
body.push(
`### ${title}`,
this.#getEntries(type)
)
includedTypes.push(type)
body.push(`### ${this.#titles[type]}`, this.#getEntries(type))
}
}

// If every commit is from a hidden section then we return an
// empty string which will skip the release PR being created.
// We do this because we don't want PRs opened if they only contain
// chores but we do want to rebuild existing PRs if chores are added.
if (includedTypes.every((type) => this.#sections[type]?.hidden)) {
return ''
}

return body.join('\n\n').trim()
}
}
Expand Down
15 changes: 5 additions & 10 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
{
"type": "feat",
"section": "Features",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "chore",
"section": "Chores",
"hidden": false,
"collapse": false
"hidden": true
}
],
"packages": {
Expand Down
45 changes: 15 additions & 30 deletions tap-snapshots/test/apply/source-snapshots.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,32 +1368,27 @@ release-please-config.json
{
"type": "feat",
"section": "Features",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "chore",
"section": "Chores",
"hidden": false,
"collapse": false
"hidden": true
}
],
"prerelease-type": "pre",
Expand Down Expand Up @@ -3031,32 +3026,27 @@ release-please-config.json
{
"type": "feat",
"section": "Features",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "chore",
"section": "Chores",
"hidden": false,
"collapse": false
"hidden": true
}
],
"prerelease-type": "pre",
Expand Down Expand Up @@ -4410,32 +4400,27 @@ release-please-config.json
{
"type": "feat",
"section": "Features",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false,
"collapse": false
"hidden": false
},
{
"type": "chore",
"section": "Chores",
"hidden": false,
"collapse": false
"hidden": true
}
],
"prerelease-type": "pre",
Expand Down
22 changes: 22 additions & 0 deletions test/release/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ t.test('filters out multiple template oss commits', async t => {
const changelog = await mockChangelog({
authors: false,
commits: [{
sha: 'z',
type: 'fix',
bareMessage: 'just a fix',
}, {
sha: 'a',
type: 'chore',
bareMessage: 'postinstall for dependabot template-oss PR',
Expand Down Expand Up @@ -152,10 +156,28 @@ t.test('filters out multiple template oss commits', async t => {
})
t.strictSame(changelog, [
'## [1.0.0](https://github.com/npm/cli/compare/v0.1.0...v1.0.0) (DATE)',
'### Bug Fixes',
'* [`z`](https://github.com/npm/cli/commit/z) just a fix',
'### Chores',
// eslint-disable-next-line max-len
'* [`b`](https://github.com/npm/cli/commit/b) [#101](https://github.com/npm/cli/pull/101) postinstall for dependabot template-oss PR',
// eslint-disable-next-line max-len
'* [`c`](https://github.com/npm/cli/commit/c) [#101](https://github.com/npm/cli/pull/101) bump @npmcli/template-oss from 1 to 2',
])
})

t.test('empty change log with only chore commits', async t => {
const changelog = await mockChangelog({
authors: false,
commits: [{
sha: 'a',
type: 'chore',
bareMessage: 'some chore',
}, {
sha: 'a',
type: 'chore',
bareMessage: 'another chore',
}],
})
t.strictSame(changelog, [])
})
Loading