fix(api): keep milestone due date when it is omitted in edit request (#39869) (#39921)

Backport https://github.com/go-gitea/gitea/pull/39869

`PATCH /repos/{owner}/{repo}/milestones/{id}` always overwrote the due
date with `due_on`, so a request that only changed other fields, such as
`{"state": "closed"}`, silently removed it.

The due date is now kept when `due_on` is omitted, and `"due_on": null`
or `"due_on": ""` remove it.

Only the milestone fix is backported. The issue and pull request
deadline changes of https://github.com/go-gitea/gitea/pull/39869 build
on https://github.com/go-gitea/gitea/pull/38677, which isn't on v28.
This commit is contained in:
Shudhanshu Singh
2026-10-21 17:59:21 +02:00
committed by GitHub
parent 193c676946
commit bc3e228e78
8 changed files with 97 additions and 7 deletions
+5 -2
View File
@@ -5,6 +5,8 @@ package structs
import (
"time"
"gitea.dev/modules/optional"
)
// Milestone milestone is a collection of issues on one repository
@@ -54,6 +56,7 @@ type EditMilestoneOption struct {
// State indicates the updated state of the milestone
// enum: ["open","closed"]
State *string `json:"state"`
// Deadline is the updated due date for the milestone
Deadline *time.Time `json:"due_on"`
// Deadline is the due date for the milestone, use null or empty string to remove the deadline
// swagger:strfmt date-time
Deadline optional.Option[*string] `json:"due_on,omitzero"`
}