fix: handle empty dates in pagure milestone migration (#10169)

Don't panic during pagure migration if a milestone has no date.

Fixes https://forge.fedoraproject.org/forge/forge/issues/281

### Manual testing

Here's how to confirm that the change is working.

Simply migrate a repository having milestones with deadlines from Pagure over to Forgejo to test.

At the source namespace, https://pagure.io/protop2g-test-srce/roadmap

This change assumes that the milestone's deadline is stored in Pagure in Unix time format (the default).

At the destination namespace, check that the due date is correct.

Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10169
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
Co-committed-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
This commit is contained in:
Akashdeep Dhar 2025-12-02 07:34:50 +01:00 committed by Gusted
parent ba778097ee
commit c4c2b8c1fb

View file

@ -334,11 +334,15 @@ func (d *PagureDownloader) GetMilestones() ([]*base.Milestone, error) {
state = "open"
}
deadline := processDate(details.Date)
var deadline *time.Time
if details.Date != nil && *details.Date != "" {
parsedDeadline := processDate(details.Date)
deadline = &parsedDeadline
}
milestones = append(milestones, &base.Milestone{
Title: name,
Description: "",
Deadline: &deadline,
Deadline: deadline,
State: state,
})
}