Skip to content

Commit e6aef3c

Browse files
authored
Merge pull request #3982 from xmudrii/schdbuilder-dates
Use upcoming_releases dates for building the schedule
2 parents 92a3190 + 2b3def4 commit e6aef3c

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

cmd/schedule-builder/cmd/markdown.go

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,46 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches
263263
}
264264

265265
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)
268266

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+
}
272306

273307
sched.Next = &PatchRelease{
274308
Release: nextReleaseVersion.String(),

cmd/schedule-builder/cmd/markdown_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func TestUpdatePatchSchedule(t *testing.T) {
381381
UpcomingReleases: []*PatchRelease{
382382
{
383383
CherryPickDeadline: "2024-03-08",
384-
TargetDate: "2024-03-13",
384+
TargetDate: "2024-03-12",
385385
},
386386
{
387387
CherryPickDeadline: "2024-04-12",
@@ -399,8 +399,8 @@ func TestUpdatePatchSchedule(t *testing.T) {
399399
Release: "1.30",
400400
Next: &PatchRelease{
401401
Release: "1.30.4",
402-
CherryPickDeadline: "2024-04-05",
403-
TargetDate: "2024-04-09",
402+
CherryPickDeadline: "2024-04-12",
403+
TargetDate: "2024-04-17",
404404
},
405405
EndOfLifeDate: "2025-01-01",
406406
MaintenanceModeStartDate: "2024-12-01",

0 commit comments

Comments
 (0)