Skip to content

Commit 3c7fd33

Browse files
authored
test(version): a changelog-only commit owes no changelog entry (#191)
The guard ate its own tail. A PR that adds a missing entry is itself a merged PR with no entry, and so is the PR that adds THAT one. Three PRs into v0.9.0 before the regress was recognised as structural rather than one more edge case. A commit that changed nothing but CHANGELOG.md has no change to describe — it IS the description. Exempted, alongside the release cut, which is recognised as before by touching CHANGELOG.md and version.go together. The two rules are separate on purpose. The cut may carry other files and still be a cut (v0.9.0's carried this very test), while changelog-only means exactly that: one file, or the exemption does not apply. #189 changed only version_test.go and owed an entry under both rules, which is the right answer. Both exemptions mutation-checked: disabling either turns the test red, so neither is defensive decoration. Honest cost, recorded: this guard caught five genuinely missing entries in v0.9.0 — including two user-visible fixes that would have shipped a release page that never mentioned them — and its edges then cost three round trips. Worth it, but not free, and the edges were all in the same place: commits whose subject is the changelog itself. Signed-off-by: jitokim <pigberger70@gmail.com>
1 parent c1f0b23 commit 3c7fd33

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

cmd/oh-my-graph/version_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,39 @@ func TestPluginManifestsMatchVersion(t *testing.T) {
182182
// Recognised by what it touched, not by how its subject is worded: only a
183183
// release cut changes CHANGELOG.md and version.go together. A wording rule
184184
// would be a second thing to keep in sync with a habit.
185+
// It also exempts a commit that changed NOTHING BUT the changelog. Such a
186+
// commit has no change to describe — it IS the description — and demanding an
187+
// entry for it makes the check eat its own tail: the PR that adds a missing
188+
// entry is itself missing one, and so is the PR that adds THAT. Three PRs into
189+
// v0.9.0 before the regress was recognised as structural rather than another
190+
// edge case.
185191
func isReleaseCut(sha string) bool {
186192
out, err := exec.Command("git", "show", "--name-only", "--format=", sha).Output()
187193
if err != nil {
188194
return false
189195
}
190196
files := strings.Fields(string(out))
191-
var changelog, version bool
197+
if len(files) == 0 {
198+
return false
199+
}
200+
var changelog, version, other bool
192201
for _, f := range files {
193202
switch f {
194203
case "CHANGELOG.md":
195204
changelog = true
196205
case "cmd/oh-my-graph/version.go":
197206
version = true
207+
default:
208+
other = true
198209
}
199210
}
200-
return changelog && version
211+
// A release cut writes the heading and bumps the constant together, which
212+
// nothing else does — it may carry other files and still be one.
213+
if changelog && version {
214+
return true
215+
}
216+
// Changelog-only maintenance.
217+
return changelog && !other
201218
}
202219

203220
func TestEveryMergedPRIsInTheChangelog(t *testing.T) {

0 commit comments

Comments
 (0)