@@ -14,7 +14,7 @@ const CHANGELOG = (v, body = "Faster renders.") =>
1414 `<Update\n label="HyperFrames v${ v } "\n>\n${ body } \n</Update>\n` ;
1515
1616/** A repo whose HEAD~1 is the base: `change` edits the worktree, then it is committed as the "release". */
17- function repo ( change ) {
17+ function repo ( change , between ) {
1818 const root = mkdtempSync ( join ( tmpdir ( ) , "release-only-" ) ) ;
1919 const git = ( ...args ) => execFileSync ( "git" , args , { cwd : root , encoding : "utf8" } ) ;
2020 const write = ( path , text ) => {
@@ -31,6 +31,7 @@ function repo(change) {
3131 write ( "docs/changelog.mdx" , CHANGELOG ( "0.8.1" ) ) ;
3232 git ( "add" , "-A" ) ;
3333 git ( "commit" , "-qm" , "base" ) ;
34+ if ( between ) between ( write , git ) ;
3435 change ( write ) ;
3536 git ( "add" , "-A" ) ;
3637 git ( "commit" , "-qm" , "release" , "--allow-empty" ) ;
@@ -134,6 +135,84 @@ test("--verify refuses mixed versions, a missing note, an unreviewed note and a
134135 assert . match ( run ( noEntry , "--verify" ) . stderr , / n o e n t r y f o r v 0 \. 8 \. 2 / ) ;
135136} ) ;
136137
138+ /** A release v0.8.1 commit, then one feature commit on main; returns the repo and the feature commit's sha. */
139+ function repoWithLateCommit ( notesFor ) {
140+ let sha = "" ;
141+ const root = repo (
142+ ( write ) => {
143+ bump ( "0.8.2" ) ( write ) ;
144+ write ( "releases/v0.8.2.md" , notesFor ( sha ) ) ;
145+ } ,
146+ ( write , git ) => {
147+ git ( "commit" , "-q" , "--allow-empty" , "-m" , "chore: release v0.8.1 (#1)" ) ;
148+ write ( "packages/core/src/late.ts" , "export const late = 1;\n" ) ;
149+ git ( "add" , "-A" ) ;
150+ git ( "commit" , "-qm" , "fix(core): a change merged after the notes were drafted (#2)" ) ;
151+ sha = git ( "rev-parse" , "HEAD" ) . trim ( ) ;
152+ } ,
153+ ) ;
154+ return { root, sha : ( ) => sha } ;
155+ }
156+
157+ test ( "--verify fails a release whose notes miss a commit merged since the last release" , ( ) => {
158+ const { root, sha } = repoWithLateCommit ( ( ) => NOTES ( "0.8.2" , "Nothing listed." ) ) ;
159+ const result = run ( root , "--verify" ) ;
160+ assert . equal ( result . code , 1 ) ;
161+ assert . match ( result . stderr , / m i s s e s 1 c o m m i t \( s \) / ) ;
162+ assert . ok ( result . stderr . includes ( sha ( ) . slice ( 0 , 9 ) ) ) ;
163+ } ) ;
164+
165+ test ( "--verify passes once the notes link that commit" , ( ) => {
166+ const { root } = repoWithLateCommit ( ( sha ) => NOTES ( "0.8.2" , `- late ([x](/commit/${ sha } )).` ) ) ;
167+ assert . equal ( run ( root , "--verify" ) . code , 0 ) ;
168+ } ) ;
169+
170+ test ( "commits that release notes leave out never count as missing" , ( ) => {
171+ const root = repo ( bump ( "0.8.2" ) , ( write , git ) => {
172+ git ( "commit" , "-q" , "--allow-empty" , "-m" , "chore: release v0.8.1 (#1)" ) ;
173+ git ( "commit" , "-q" , "--allow-empty" , "-m" , "chore: bump version to 0.8.1-x" ) ;
174+ git ( "commit" , "-q" , "--allow-empty" , "-m" , "docs: x [skip changelog]" ) ;
175+ } ) ;
176+ assert . equal ( run ( root , "--verify" ) . code , 0 ) ;
177+ } ) ;
178+
179+ test ( "the last release is found by its subject, not by a line in another commit's body" , ( ) => {
180+ const { root } = ( ( ) => {
181+ let sha = "" ;
182+ const r = repo (
183+ ( write ) => {
184+ bump ( "0.8.2" ) ( write ) ;
185+ write ( "releases/v0.8.2.md" , NOTES ( "0.8.2" , "Nothing listed." ) ) ;
186+ } ,
187+ ( write , git ) => {
188+ git ( "commit" , "-q" , "--allow-empty" , "-m" , "chore(release): cut v0.8.1 (#1)" ) ;
189+ write ( "packages/core/src/early.ts" , "export const early = 1;\n" ) ;
190+ git ( "add" , "-A" ) ;
191+ git ( "commit" , "-qm" , "fix(core): before the body line (#2)" ) ;
192+ git (
193+ "commit" ,
194+ "-q" ,
195+ "--allow-empty" ,
196+ "-m" ,
197+ "fix(core): squash body (#3)" ,
198+ "-m" ,
199+ "chore: release v9.9.9" ,
200+ ) ;
201+ sha = git ( "rev-parse" , "HEAD~1" ) . trim ( ) ;
202+ } ,
203+ ) ;
204+ return { root : r , sha } ;
205+ } ) ( ) ;
206+ const result = run ( root , "--verify" ) ;
207+ assert . equal ( result . code , 1 ) ;
208+ assert . match ( result . stderr , / m i s s e s 2 c o m m i t \( s \) / ) ;
209+ } ) ;
210+
211+ test ( "the merge queue runs the release checks on a release diff" , ( ) => {
212+ const ci = readFileSync ( new URL ( "../../.github/workflows/ci.yml" , import . meta. url ) , "utf8" ) ;
213+ assert . match ( ci , / r e l e a s e - c h e c k s : [ \s \S ] * m e r g e _ g r o u p [ \s \S ] * r e l e a s e _ d i f f / ) ;
214+ } ) ;
215+
137216test ( "classify works on plain data" , ( ) => {
138217 const files = { "a/package.json" : manifest ( "1" ) , "plugin.json" : manifest ( "1" ) } ;
139218 const after = { "a/package.json" : manifest ( "2" ) , "plugin.json" : manifest ( "2" ) } ;
0 commit comments