@@ -74,6 +74,7 @@ const ADD_CHANGESET_URL_PLACEHOLDER_REGEXP = /\{\{\s*addChangesetUrl\s*\}\}/
74
74
const getAbsentMessage = (
75
75
commitSha : string ,
76
76
addChangesetUrl : string ,
77
+ newChangesetTemplateFallback : string ,
77
78
releasePlan : ReleasePlan | null ,
78
79
) => `### ⚠️ No Changeset found
79
80
91
92
[Click here if you're a maintainer who wants to add a changeset to this MR](${ addChangesetUrl } )`
92
93
}
93
94
95
+ ${ newChangesetTemplateFallback }
96
+
94
97
__${ generatedByBotNote } __
95
98
`
96
99
97
100
const getApproveMessage = (
98
101
commitSha : string ,
99
102
addChangesetUrl : string ,
103
+ newChangesetTemplateFallback : string ,
100
104
releasePlan : ReleasePlan | null ,
101
105
) => `### 🦋 Changeset detected
102
106
114
118
[Click here if you're a maintainer who wants to add another changeset to this MR](${ addChangesetUrl } )`
115
119
}
116
120
121
+ ${ newChangesetTemplateFallback }
122
+
117
123
__${ generatedByBotNote } __
118
124
`
119
125
120
- const getNewChangesetTemplate = ( changedPackages : string [ ] , title : string ) =>
121
- encodeURIComponent ( `---
126
+ const getNewChangesetTemplate = (
127
+ changedPackages : string [ ] ,
128
+ title : string ,
129
+ ) => `---
122
130
${ changedPackages . map ( x => `"${ x } ": patch` ) . join ( '\n' ) }
123
131
---
124
132
125
133
${ title }
126
- ` )
134
+ `
127
135
128
136
const isMrNote = (
129
137
discussionOrNote : DiscussionSchema | MergeRequestNoteSchema ,
@@ -201,7 +209,8 @@ async function getNoteInfo(
201
209
}
202
210
203
211
/**
204
- * The `username` used for commenting could be random, if we haven't tested the random `username`, then test it
212
+ * The `username` used for commenting could be random, if we haven't tested
213
+ * the random `username`, then test it
205
214
*
206
215
* @see https://docs.gitlab.com/ee/development/internal_users.html
207
216
* @see https://github.com/un-ts/changesets-gitlab/issues/145#issuecomment-1860610958
@@ -286,25 +295,44 @@ export const comment = async () => {
286
295
} ) ,
287
296
] as const )
288
297
289
- const addChangesetUrl = `${ env . CI_MERGE_REQUEST_PROJECT_URL } /-/new/ ${ mrBranch } ?file_name=. changeset/${ humanId (
290
- {
291
- separator : '-' ,
292
- capitalize : false ,
293
- } ,
294
- ) } .md&file= ${ getNewChangesetTemplate (
298
+ const newChangesetFileName = `. changeset/${ humanId ( {
299
+ separator : '-' ,
300
+ capitalize : false ,
301
+ } ) } .md`
302
+
303
+ const newChangesetTemplate = getNewChangesetTemplate (
295
304
changedPackages ,
296
305
env . CI_MERGE_REQUEST_TITLE ,
297
- ) } ${
306
+ )
307
+
308
+ const addChangesetUrl = `${ env . CI_MERGE_REQUEST_PROJECT_URL } /-/new/${ mrBranch } ?file_name=${ newChangesetFileName } &file=${ encodeURIComponent ( newChangesetTemplate ) } ${
298
309
commitMessage
299
310
? '&commit_message=' + encodeURIComponent ( commitMessage )
300
311
: ''
301
312
} `
302
313
314
+ const newChangesetTemplateFallback = `
315
+ If the above link doesn't fill the changeset template file name and content which is [a known regression on GitLab > 16.11](https://gitlab.com/gitlab-org/gitlab/-/issues/532221), you can copy and paste the following template into ${ newChangesetFileName } instead:
316
+
317
+ \`\`\`yaml
318
+ ${ newChangesetTemplate }
319
+ \`\`\`
320
+ ` . trim ( )
321
+
303
322
const prComment =
304
323
( hasChangeset
305
- ? getApproveMessage ( latestCommitSha , addChangesetUrl , releasePlan )
306
- : getAbsentMessage ( latestCommitSha , addChangesetUrl , releasePlan ) ) +
307
- errFromFetchingChangedFiles
324
+ ? getApproveMessage (
325
+ latestCommitSha ,
326
+ addChangesetUrl ,
327
+ newChangesetTemplateFallback ,
328
+ releasePlan ,
329
+ )
330
+ : getAbsentMessage (
331
+ latestCommitSha ,
332
+ addChangesetUrl ,
333
+ newChangesetTemplateFallback ,
334
+ releasePlan ,
335
+ ) ) + errFromFetchingChangedFiles
308
336
309
337
switch ( commentType ) {
310
338
case 'discussion' : {
0 commit comments