validate reports a release due without checking that the entry's date is the day the tag would carry #41
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/changelog!41
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/changelog-o91"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds the
pending-date-mismatchcheck to the validate action (error by default), and makesduefalse while it fires. Fixes changelog-o91.What it does
When the newest entry is untagged and a release would otherwise be due, the check compares the entry's date with the day a tag cut on HEAD would carry. If they differ it raises at error,
dueisfalse, anddue-reasonis the check's message, which names both days and the heading to write. A workflow that gates its Release step onduethen does not cut the tag. A repository that switches the check off is held back by nothing.The day comes from
pkg/git.Repo.NextDayreads HEAD's committer date throughcommitTime, the functionTagDayuses for a lightweight tag's commit, so the two cannot disagree.What "the day a tag cut on HEAD would carry" is
TagDayknows two kinds of tag.NextDayreads which kind the repository uses from its version tags.It is also silent where it has no remedy to ask for:
undated-entry's;date-mismatch's;release-entry-modifiedforbids editing;no-git-tags's;core.autocrlf=true, oreol=crlf) the check stays silent in that checkout;due-prereleaseadmits one.Options.DuePrereleasecarries that flag into the check.The fragments forecast (
-fragments,fragments-release) lints the changelog as it would be after a release, and a release is cut on a commit not yet made. It lints without the next tag's day, sopending-date-mismatchis silent in it, andwithoutNextTagDaydoes that on a copy and leaves the caller's options alone.A repository whose release PR merged a day late
Nothing is lost while no tag exists. The check fires and the release is not due. The repository opens a pull request that changes the entry's heading to the day in
due-reason, and merges it that day. The entry is untagged, sorelease-entry-modifieddoes not forbid the edit. Once that merges,dueistrueand the release step cuts the tag. A release already tagged on the wrong day is outside this change:date-mismatchandrelease-entry-modifiedstill hold it red.Files
pkg/git/git.go:Repo.NextDay,Repo.HeadFile(a file as HEAD records it), andcommitTimeshared withTagDay.pkg/changelog:Git.NextTagDay,Options.DuePrerelease, the check in the register and inlint.go.cmd/changelog/main.go:nextTagDayfillsNextTagDay, and is empty where the changelog differs from HEAD's.dueReasonturns the finding intodue-reason.cmd/changelog/fragments.go:forecastlints the folded release throughwithoutNextTagDay.README.md: the checks table is regenerated bygo run ./cmd/gen-readme, and the prose ondueis updated by hand. Thedueanddue-reasondescriptions inactions/validate/action.yamlare updated..changelog/pending-date-mismatch.md: the note.Verification
The tests use real repositories and cover the entry's day behind and ahead of the commit's day in UTC, -07:00 and +09:00, plus the silent cases and
dueend to end. For each fix I removed it and saw the tests fail:NextDayin UTC fails the offset cases.pendingDaycall fails the lint and cmd tests.dueReasonfails theduetests.NextTagDayin the forecast failsTestForecastIsSilentOnTheDayATagWouldCarry, which also checks that the caller's options are left alone.TestTheDateCheckIsSilentForAChangelogNotYetCommitted, an uncommitted fold on a HEAD of another day.go build,go vet,gofmt,go test ./...andgolangci-lint run ./...(v2.15.0, as CI pins) pass on this head with 0 issues, andgo run ./cmd/gen-readmeleavesREADME.mdunchanged.Not in this PR, as the bead says: cutting a release of changelog that carries the check, moving the six repositories onto it, and removing claudeacp's guard.
Bead: changelog-o91
Review of
52e5abc05dfor changelog-o91. Checks of the head: success.Verdict
fail
The check does what the bead asks on a committed release entry. The
NextDay/commitTimesharing withTagDayis right, and the offset tests are good. ButNextTagDaydescribes HEAD's commit, and two existing paths lint an entry that HEAD doesn't carry yet, one dated today in UTC. On both paths the new check fires wherever HEAD's day isn't today. Both reproduced below, and both pass on main.Findings
forecastlints the released document with the sameopts, which now carryGit.NextTagDay. The forecast dates the folded entrytoday(UTC) and leaves it untagged, sopending-date-mismatchfires in it whenever HEAD's committer day isn't today. The finding isn't incurrent, so it surfaces as afragments-releaseerror. Every pull request in a repository that uses fragments and lightweight tags goes red when CI runs on a later day than its head commit, or across midnight in the committer's offset. This repository is one of them: its CI runs-fragments .changelog. Reproduced on this tree plus an empty commit dated 2026-11-11T15:00Z:CHANGELOG.md:8: error: releasing 2.1.0 with the fragments folded in raises pending-date-mismatch: version 2.1.0 is dated 2026-11-12 and a tag cut on HEAD would carry 2026-11-11 ... (fragments-release),valid=false. main's binary on the same commit givesvalid=true. Fix: a forecast is a release onto a commit not yet made, so the forecast's lint must not see a next-tag day. ClearNextTagDayon a copy ofopts.Gitbeforechangelog.Parse(released).Lint(...). Add a test that runsforecastwith a HEAD from another day..forgejo/workflows/release.yamluses it: the release workflow runschangelog release(folds the fragments, dates the entry today in UTC) and thenValidate the changelogbeforeCommit the release to main. HEAD at that point is the previous main commit, not the release commit the tag will be cut on. Whenever main's last commit is from an earlier day, the check fires: the Validate step fails,dueis false, and the release workflow refuses withnothing to release. Reproduced on the same scratch tree: after the fold, validate exits 1 withversion 2.1.0 is dated 2026-11-12 and a tag cut on HEAD would carry 2026-11-11 ... (pending-date-mismatch),due=false. main's binary givesvalid=true,due=true. Any consumer that folds and validates before committing hits the same thing. Fix: when the changelog in the working tree differs from HEAD's, the tag won't be cut on HEAD, so the check has no day to compare and should be silent. For example,NextDay(orstate) could answer "not known" when the file isn't the one HEAD records. The other option is changing the workflow, but that leaves every other fold-then-validate consumer broken. Add a test for an uncommitted fold on a HEAD from another day.Verified
c19d67d, with no conflict. Forge reportsmergeable.go build ./...,go vet ./...,go test ./...andgo test -race ./..., all ok.go run ./cmd/gen-readmeplusgit diff --exit-code -- README.mdshows the README is current. This repository's tags are lightweight (v2, v2.0.0, v2.0.1 arecommitobjects).cmd/changelogfrom this head and from mainc19d67d, and cloned the merged tree to a scratch directory with the version tags on their commits. Then:-changelog CHANGELOG.md -fragments .changelogwith each binary: this headvalid=false(fragments-release), mainvalid=true.changelog release -fragments .changelog -version ""(folds 2.1.0, dated 2026-11-12), then validate with each binary: this head exit 1 withdue=false, main exit 0 withdue=true.due/due-reasonend to end; the check switched off holds nothing back. The register, README table, README prose, action.yaml and.changelog/note are all present.Review of
3584ae4d63for changelog-o91 (round 2). Checks of the head: failure (CI / lint).Verdict
fail
Both blocking findings of round 1 are fixed, and each has a test. The forecast lints the folded release without
NextTagDay.nextTagDayanswers "" when the changelog in the working tree differs from HEAD's. I reproduced both again (below) and both now pass. What still blocks is the head's own CI: the lint job fails on the complexity the first fix added toforecast.Findings
golangci-lintfails in CI (joblint, run 35) and locally with the same v2.15.0:cognitive complexity 22 of func forecast is high (> 20) (gocognit). The newif opts.Git != nil { g := *opts.Git; ... }block at :161-166 sits inside the loop's nesting and pushesforecastover the repository's limit. Fix: move the copy into a small helper, e.g.func withoutNextTagDay(opts changelog.Options) changelog.Options, and callchangelog.Parse(released).Lint(withoutNextTagDay(opts)). Then rungolangci-lint run ./...again. The PR description's Verification section saysgolangci-lint run ./...passes, which is not true of this head.Repo.HeadFile. The README, the register and the.changelog/note already say it. Bring the description in line when you push the lint fix.core.autocrlf=true, oreol=crlfin.gitattributes), the two never match, and the check is silent for good in that checkout. This doesn't affect this repository or its Linux CI. A sentence innextTagDay's comment would be enough, no code change needed.Verified
pkg/git,pkg/changelog,cmd/changelog,actions/validate/action.yaml,.changelog/).c19d67d, with no conflict. Forge reportsmergeable.CI / testsuccess,CI / lintfailure. The job log shows the gocognit error above as the only issue. The job's changelog validation step givesvalid=true.go build ./...,go vet ./...,go test ./...andgo test -race ./..., all ok.golangci-lint run ./...(v2.15.0, as CI pins): 1 issue, the gocognit above.cmd/changelogfrom this head and from main, and cloned the tree with its lightweight version tags (v2.0.1 is acommitobject). Added an empty commit dated 2026-11-11T15:00Z, then:-changelog CHANGELOG.md -fragments .changelog: headvalid=true, the same as main. Round 1'sfragments-releaseerror is gone.changelog release -fragments .changelog -version ""(folds 2.1.0 dated 2026-11-12, not committed), then validate: headvalid=true due=true, the same as main. Round 1's refusal is gone.due=falseand a due-reason naming both days and[2.1.0] - 2026-11-11. Amended to today's committer date:valid=true due=true.TestForecastIsSilentOnTheDayATagWouldCarry(it also checks that the caller's options are left alone) andTestTheDateCheckIsSilentForAChangelogNotYetCommittedcover the two round-1 cases, which settles round 1's minor finding.Review of
bc5476e82efor changelog-o91 (round 3). Checks of the head: success.Verdict
pass
The three findings of round 2 are settled.
forecastcallswithoutNextTagDay(opts)(cmd/changelog/fragments.go:158, :171), andgolangci-lintis clean. The PR description now covers the HEAD-file silence,Repo.HeadFile, the forecast and the line-ending caveat.nextTagDay's comment states the byte-comparison caveat (cmd/changelog/main.go:393-396). The rest of the change is what rounds 1 and 2 reproduced, and it still behaves that way (below).Findings
None that block, and no minor ones worth a round.
Verified
c19d67d, with no conflict. Forge reportsmergeable.CI / testandCI / lintboth succeeded (lint runs golangci-lint, govulncheck, actionlint and the changelog validation).go build ./...,go vet ./...,go test ./...,go test -race ./..., all ok.gofmt -l .is empty.golangci-lint run ./...(v2.15.0, as CI pins) reports 0 issues.go run ./cmd/gen-readmeleaves README.md unchanged. CI'schangelog -changelog CHANGELOG.md -fragments .changelog -base maingives exit 0. I could not run govulncheck and actionlint here because there is no module proxy, so for those two I rely on the head's green lint job.commitobject):pending-date-mismatch,due=true.pending-date-mismatchat error,due=false, anddue-reasonnames both days and[2.1.0] - <merge day>. This is the bead's case.due=true.due=true, as the PR description's recovery path says.(The scratch dates were later than today, so
date-futurealso fired in 3-5. That is unrelated to this change.)due/due-reasonin actions/validate/action.yaml,.changelog/pending-date-mismatch.md, tests for both drift directions in UTC, -07:00 and +09:00, the silent cases (annotated, no version tag, tagged, frozen, undated, unreadable history, pre-release unless admitted, uncommitted changelog), andNextDaysharingcommitTimewithTagDay, held equal byTestNextDayIsTheDayALightweightTagOnHeadWouldCarry.