Skip to content

Commit e92f7d2

Browse files
committed
fix: dont create chore only PRs
1 parent 2e7a6dd commit e92f7d2

File tree

5 files changed

+61
-59
lines changed

5 files changed

+61
-59
lines changed

lib/content/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ module.exports = {
199199
},
200200
allowedPackages: [],
201201
changelogTypes: [
202-
{ type: 'feat', section: 'Features', hidden: false, collapse: false },
203-
{ type: 'fix', section: 'Bug Fixes', hidden: false, collapse: false },
204-
{ type: 'docs', section: 'Documentation', hidden: false, collapse: false },
205-
{ type: 'deps', section: 'Dependencies', hidden: false, collapse: false },
206-
{ type: 'chore', section: 'Chores', hidden: false, collapse: false },
202+
{ type: 'feat', section: 'Features', hidden: false },
203+
{ type: 'fix', section: 'Bug Fixes', hidden: false },
204+
{ type: 'docs', section: 'Documentation', hidden: false },
205+
{ type: 'deps', section: 'Dependencies', hidden: false },
206+
{ type: 'chore', section: 'Chores', hidden: true },
207207
],
208208
}

lib/release/changelog.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ class Changelog {
2929
}
3030

3131
#getEntries (type) {
32-
const section = this.#sections[type]
33-
const entries = this.#entries[type].map(list)
34-
// Ignoring coverage until we use this again
35-
/* istanbul ignore next */
36-
if (section?.collapse) {
37-
entries.unshift('<details><summary>Commits</summary>\n')
38-
entries.push('\n</details>')
39-
}
40-
return entries.join('\n')
32+
return this.#entries[type].map(list).join('\n')
4133
}
4234

4335
toString () {
4436
const body = [this.#title]
37+
const includedTypes = []
38+
4539
for (const type of this.#types) {
46-
const title = this.#titles[type]
4740
if (this.#entries[type]?.length) {
48-
body.push(
49-
`### ${title}`,
50-
this.#getEntries(type)
51-
)
41+
includedTypes.push(type)
42+
body.push(`### ${this.#titles[type]}`, this.#getEntries(type))
5243
}
5344
}
45+
46+
// If every commit is from a hidden section then we return an
47+
// empty string which will skip the release PR being created.
48+
// We do this because we don't want PRs opened if they only contain
49+
// chores but we do want to rebuild existing PRs if chores are added.
50+
if (includedTypes.every((type) => this.#sections[type]?.hidden)) {
51+
return ''
52+
}
53+
5454
return body.join('\n\n').trim()
5555
}
5656
}

release-please-config.json

+5-10
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,27 @@
33
{
44
"type": "feat",
55
"section": "Features",
6-
"hidden": false,
7-
"collapse": false
6+
"hidden": false
87
},
98
{
109
"type": "fix",
1110
"section": "Bug Fixes",
12-
"hidden": false,
13-
"collapse": false
11+
"hidden": false
1412
},
1513
{
1614
"type": "docs",
1715
"section": "Documentation",
18-
"hidden": false,
19-
"collapse": false
16+
"hidden": false
2017
},
2118
{
2219
"type": "deps",
2320
"section": "Dependencies",
24-
"hidden": false,
25-
"collapse": false
21+
"hidden": false
2622
},
2723
{
2824
"type": "chore",
2925
"section": "Chores",
30-
"hidden": false,
31-
"collapse": false
26+
"hidden": true
3227
}
3328
],
3429
"packages": {

tap-snapshots/test/apply/source-snapshots.js.test.cjs

+15-30
Original file line numberDiff line numberDiff line change
@@ -1368,32 +1368,27 @@ release-please-config.json
13681368
{
13691369
"type": "feat",
13701370
"section": "Features",
1371-
"hidden": false,
1372-
"collapse": false
1371+
"hidden": false
13731372
},
13741373
{
13751374
"type": "fix",
13761375
"section": "Bug Fixes",
1377-
"hidden": false,
1378-
"collapse": false
1376+
"hidden": false
13791377
},
13801378
{
13811379
"type": "docs",
13821380
"section": "Documentation",
1383-
"hidden": false,
1384-
"collapse": false
1381+
"hidden": false
13851382
},
13861383
{
13871384
"type": "deps",
13881385
"section": "Dependencies",
1389-
"hidden": false,
1390-
"collapse": false
1386+
"hidden": false
13911387
},
13921388
{
13931389
"type": "chore",
13941390
"section": "Chores",
1395-
"hidden": false,
1396-
"collapse": false
1391+
"hidden": true
13971392
}
13981393
],
13991394
"prerelease-type": "pre",
@@ -3031,32 +3026,27 @@ release-please-config.json
30313026
{
30323027
"type": "feat",
30333028
"section": "Features",
3034-
"hidden": false,
3035-
"collapse": false
3029+
"hidden": false
30363030
},
30373031
{
30383032
"type": "fix",
30393033
"section": "Bug Fixes",
3040-
"hidden": false,
3041-
"collapse": false
3034+
"hidden": false
30423035
},
30433036
{
30443037
"type": "docs",
30453038
"section": "Documentation",
3046-
"hidden": false,
3047-
"collapse": false
3039+
"hidden": false
30483040
},
30493041
{
30503042
"type": "deps",
30513043
"section": "Dependencies",
3052-
"hidden": false,
3053-
"collapse": false
3044+
"hidden": false
30543045
},
30553046
{
30563047
"type": "chore",
30573048
"section": "Chores",
3058-
"hidden": false,
3059-
"collapse": false
3049+
"hidden": true
30603050
}
30613051
],
30623052
"prerelease-type": "pre",
@@ -4410,32 +4400,27 @@ release-please-config.json
44104400
{
44114401
"type": "feat",
44124402
"section": "Features",
4413-
"hidden": false,
4414-
"collapse": false
4403+
"hidden": false
44154404
},
44164405
{
44174406
"type": "fix",
44184407
"section": "Bug Fixes",
4419-
"hidden": false,
4420-
"collapse": false
4408+
"hidden": false
44214409
},
44224410
{
44234411
"type": "docs",
44244412
"section": "Documentation",
4425-
"hidden": false,
4426-
"collapse": false
4413+
"hidden": false
44274414
},
44284415
{
44294416
"type": "deps",
44304417
"section": "Dependencies",
4431-
"hidden": false,
4432-
"collapse": false
4418+
"hidden": false
44334419
},
44344420
{
44354421
"type": "chore",
44364422
"section": "Chores",
4437-
"hidden": false,
4438-
"collapse": false
4423+
"hidden": true
44394424
}
44404425
],
44414426
"prerelease-type": "pre",

test/release/changelog.js

+22
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ t.test('filters out multiple template oss commits', async t => {
121121
const changelog = await mockChangelog({
122122
authors: false,
123123
commits: [{
124+
sha: 'z',
125+
type: 'fix',
126+
bareMessage: 'just a fix',
127+
}, {
124128
sha: 'a',
125129
type: 'chore',
126130
bareMessage: 'postinstall for dependabot template-oss PR',
@@ -152,10 +156,28 @@ t.test('filters out multiple template oss commits', async t => {
152156
})
153157
t.strictSame(changelog, [
154158
'## [1.0.0](https://github.com/npm/cli/compare/v0.1.0...v1.0.0) (DATE)',
159+
'### Bug Fixes',
160+
'* [`z`](https://github.com/npm/cli/commit/z) just a fix',
155161
'### Chores',
156162
// eslint-disable-next-line max-len
157163
'* [`b`](https://github.com/npm/cli/commit/b) [#101](https://github.com/npm/cli/pull/101) postinstall for dependabot template-oss PR',
158164
// eslint-disable-next-line max-len
159165
'* [`c`](https://github.com/npm/cli/commit/c) [#101](https://github.com/npm/cli/pull/101) bump @npmcli/template-oss from 1 to 2',
160166
])
161167
})
168+
169+
t.test('empty change log with only chore commits', async t => {
170+
const changelog = await mockChangelog({
171+
authors: false,
172+
commits: [{
173+
sha: 'a',
174+
type: 'chore',
175+
bareMessage: 'some chore',
176+
}, {
177+
sha: 'a',
178+
type: 'chore',
179+
bareMessage: 'another chore',
180+
}],
181+
})
182+
t.strictSame(changelog, [])
183+
})

0 commit comments

Comments
 (0)