@ -8,6 +8,7 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
"strings"
"strings"
"time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/auth"
@ -326,7 +327,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
func EditPullRequest ( ctx * context . APIContext , form api . EditPullRequestOption ) {
func EditPullRequest ( ctx * context . APIContext , form api . EditPullRequestOption ) {
// swagger:operation PATCH /repos/{owner}/{repo}/pulls/{index} repository repoEditPullRequest
// swagger:operation PATCH /repos/{owner}/{repo}/pulls/{index} repository repoEditPullRequest
// ---
// ---
// summary: Update a pull request
// summary: Update a pull request. If using deadline only the date will be taken into account, and time of day ignored.
// consumes:
// consumes:
// - application/json
// - application/json
// produces:
// produces:
@ -385,9 +386,15 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
issue . Content = form . Body
issue . Content = form . Body
}
}
// Update Deadline
// Update or remove deadline if set
if form . Deadline != nil {
if form . Deadline != nil || form . RemoveDeadline != nil {
deadlineUnix := timeutil . TimeStamp ( form . Deadline . Unix ( ) )
var deadlineUnix timeutil . TimeStamp
if ( form . RemoveDeadline == nil || ! * form . RemoveDeadline ) && ! form . Deadline . IsZero ( ) {
deadline := time . Date ( form . Deadline . Year ( ) , form . Deadline . Month ( ) , form . Deadline . Day ( ) ,
23 , 59 , 59 , 0 , form . Deadline . Location ( ) )
deadlineUnix = timeutil . TimeStamp ( deadline . Unix ( ) )
}
if err := models . UpdateIssueDeadline ( issue , deadlineUnix , ctx . User ) ; err != nil {
if err := models . UpdateIssueDeadline ( issue , deadlineUnix , ctx . User ) ; err != nil {
ctx . Error ( 500 , "UpdateIssueDeadline" , err )
ctx . Error ( 500 , "UpdateIssueDeadline" , err )
return
return