Skip to content

Commit 5bbae9f

Browse files
committed
Fix monthly patch output for schedule-builder
The output was empty which is now fixed. Signed-off-by: Sascha Grunert <[email protected]>
1 parent d6ed17f commit 5bbae9f

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

cmd/schedule-builder/cmd/markdown.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ func parsePatchSchedule(patchSchedule PatchSchedule) string {
4545
table.SetAutoWrapText(false)
4646
table.SetHeader([]string{"Monthly Patch Release", "Cherry Pick Deadline", "Target Date"})
4747
for _, upcoming := range patchSchedule.UpcomingReleases {
48-
table.Append([]string{strings.TrimSpace(upcoming.Release), strings.TrimSpace(upcoming.CherryPickDeadline), strings.TrimSpace(upcoming.TargetDate)})
48+
targetDate, err := time.Parse(refDate, upcoming.TargetDate)
49+
if err != nil {
50+
logrus.Errorf("Unable to parse upcoming target date %q: %v", upcoming.TargetDate, err)
51+
continue
52+
}
53+
table.Append([]string{
54+
targetDate.Format(refDateMonthly),
55+
strings.TrimSpace(upcoming.CherryPickDeadline),
56+
strings.TrimSpace(upcoming.TargetDate)},
57+
)
4958
}
5059
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
5160
table.SetCenterSeparator("|")
@@ -167,8 +176,12 @@ func processFile(fileName string, vars interface{}) string {
167176
return process(tmpl, vars)
168177
}
169178

179+
const (
180+
refDate = "2006-01-02"
181+
refDateMonthly = "January 2006"
182+
)
183+
170184
func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches EolBranches, filePath, eolFilePath string) error {
171-
const refDate = "2006-01-02"
172185

173186
removeSchedules := []int{}
174187
for i, sched := range schedule.Schedules {
@@ -270,7 +283,7 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches
270283
continue
271284
}
272285

273-
logrus.Infof("Using existing upcoming release for %s (%s)", upcomingRelease.Release, upcomingRelease.TargetDate)
286+
logrus.Infof("Using existing upcoming release for %s", upcomingRelease.TargetDate)
274287
newUpcomingReleases = append(newUpcomingReleases, upcomingRelease)
275288
latestDate = upcomingTargetDate
276289
}
@@ -286,7 +299,7 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches
286299
nextCherryPickDeadline := time.Date(latestDate.Year(), latestDate.Month(), cherryPickDay, 0, 0, 0, 0, time.UTC)
287300
nextTargetDate := time.Date(latestDate.Year(), latestDate.Month(), targetDateDay, 0, 0, 0, 0, time.UTC)
288301

289-
logrus.Infof("Adding new upcoming release for %s", nextTargetDate.Format("January 2006"))
302+
logrus.Infof("Adding new upcoming release for %s", nextTargetDate.Format(refDateMonthly))
290303

291304
newUpcomingReleases = append(newUpcomingReleases, &PatchRelease{
292305
CherryPickDeadline: nextCherryPickDeadline.Format(refDate),

cmd/schedule-builder/cmd/markdown_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const expectedPatchSchedule = `### Upcoming Monthly Releases
3131
3232
| MONTHLY PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE |
3333
|-----------------------|----------------------|-------------|
34-
| | 2020-06-12 | 2020-06-17 |
34+
| June 2020 | 2020-06-12 | 2020-06-17 |
3535
3636
### Timeline
3737

0 commit comments

Comments
 (0)