fix(api): keep milestone due date when it is omitted in edit request (#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.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Shudhanshu Singhandwxiaoguang authored and GitHub committed 2026-10-21 18:52:33 +08:00
1 parent b5e53210c2
commit a8e1057f5e
15 files changed
+192 -74

No files matched your search

+5 -2
View File
@@ -5,6 +5,8 @@ package structs
import (
"time"
"gitea.dev/modules/optional"
)
// PullRequest represents a pull request
@@ -137,7 +139,7 @@ type CreatePullRequestOption struct {
// The list of label IDs to assign to the pull request
Labels []int64 `json:"labels"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
Deadline optional.Option[*string] `json:"due_date,omitzero"`
// The list of reviewer usernames
Reviewers []string `json:"reviewers"`
// The list of team reviewer names
@@ -164,8 +166,9 @@ type EditPullRequestOption struct {
Labels []int64 `json:"labels"`
// The new state for the pull request
State *string `json:"state"`
// Deadline is the updated due date for the pull request, use null or empty string to remove the deadline
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
Deadline optional.Option[*string] `json:"due_date,omitzero"`
// Whether to remove the current deadline
RemoveDeadline *bool `json:"unset_due_date"`
// Whether to allow maintainer edits