@@ -263,12 +263,46 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches
263
263
}
264
264
265
265
cherryPickDeadlinePlusOneMonth := cherryPickDeadline .AddDate (0 , 1 , 0 )
266
- cherryPickDay := firstFriday (cherryPickDeadlinePlusOneMonth )
267
- newCherryPickDeadline := time .Date (cherryPickDeadlinePlusOneMonth .Year (), cherryPickDeadlinePlusOneMonth .Month (), cherryPickDay , 0 , 0 , 0 , 0 , time .UTC )
268
266
269
- targetDatePlusOneMonth := targetDate .AddDate (0 , 1 , 0 )
270
- targetDateDay := secondTuesday (targetDatePlusOneMonth )
271
- newTargetDate := time .Date (targetDatePlusOneMonth .Year (), targetDatePlusOneMonth .Month (), targetDateDay , 0 , 0 , 0 , 0 , time .UTC )
267
+ var (
268
+ newCherryPickDeadline time.Time
269
+ newTargetDate time.Time
270
+ found bool
271
+ )
272
+
273
+ for _ , u := range schedule .UpcomingReleases {
274
+ if u == nil {
275
+ continue
276
+ }
277
+
278
+ upcomingCherryPickDeadline , err := time .Parse (refDate , u .CherryPickDeadline )
279
+ if err != nil {
280
+ return fmt .Errorf ("parse upcoming cherry pick deadline: %w" , err )
281
+ }
282
+
283
+ if cherryPickDeadlinePlusOneMonth .Month () == upcomingCherryPickDeadline .Month () &&
284
+ cherryPickDeadlinePlusOneMonth .Year () == upcomingCherryPickDeadline .Year () {
285
+ newCherryPickDeadline = upcomingCherryPickDeadline
286
+
287
+ newTargetDate , err = time .Parse (refDate , u .TargetDate )
288
+ if err != nil {
289
+ return fmt .Errorf ("parse upcoming release date: %w" , err )
290
+ }
291
+
292
+ found = true
293
+
294
+ break
295
+ }
296
+ }
297
+
298
+ if ! found {
299
+ cherryPickDay := firstFriday (cherryPickDeadlinePlusOneMonth )
300
+ newCherryPickDeadline = time .Date (cherryPickDeadlinePlusOneMonth .Year (), cherryPickDeadlinePlusOneMonth .Month (), cherryPickDay , 0 , 0 , 0 , 0 , time .UTC )
301
+
302
+ targetDatePlusOneMonth := targetDate .AddDate (0 , 1 , 0 )
303
+ targetDateDay := secondTuesday (targetDatePlusOneMonth )
304
+ newTargetDate = time .Date (targetDatePlusOneMonth .Year (), targetDatePlusOneMonth .Month (), targetDateDay , 0 , 0 , 0 , 0 , time .UTC )
305
+ }
272
306
273
307
sched .Next = & PatchRelease {
274
308
Release : nextReleaseVersion .String (),
0 commit comments