]> source.dussan.org Git - gitea.git/commitdiff
Fix deadline on update issue or PR via API (#8696)
authorDavid Svantesson <davidsvantesson@gmail.com>
Sun, 27 Oct 2019 23:35:20 +0000 (00:35 +0100)
committerLauris BH <lauris@nix.lv>
Sun, 27 Oct 2019 23:35:20 +0000 (01:35 +0200)
* Fix deadline on update issue or PR via API

* variable initialized directly (review comment)

routers/api/v1/repo/issue.go
routers/api/v1/repo/pull.go

index 9529e09b290023a10c6ae031e282f468e33c174d..a41abba4cd4aa1c0121f6307b6dcfdd4a32934bc 100644 (file)
@@ -336,14 +336,13 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
        }
 
        // Update the deadline
-       var deadlineUnix timeutil.TimeStamp
-       if form.Deadline != nil && !form.Deadline.IsZero() && ctx.Repo.CanWrite(models.UnitTypeIssues) {
-               deadlineUnix = timeutil.TimeStamp(form.Deadline.Unix())
-       }
-
-       if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
-               ctx.Error(500, "UpdateIssueDeadline", err)
-               return
+       if form.Deadline != nil && ctx.Repo.CanWrite(models.UnitTypeIssues) {
+               deadlineUnix := timeutil.TimeStamp(form.Deadline.Unix())
+               if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
+                       ctx.Error(500, "UpdateIssueDeadline", err)
+                       return
+               }
+               issue.DeadlineUnix = deadlineUnix
        }
 
        // Add/delete assignees
index 6b20844c51f624ab1e58c81ff11ec5ccb67933bb..77fb452938284b395fd0d27509597d5463ec7859 100644 (file)
@@ -392,14 +392,13 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
        }
 
        // Update Deadline
-       var deadlineUnix timeutil.TimeStamp
-       if form.Deadline != nil && !form.Deadline.IsZero() {
-               deadlineUnix = timeutil.TimeStamp(form.Deadline.Unix())
-       }
-
-       if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
-               ctx.Error(500, "UpdateIssueDeadline", err)
-               return
+       if form.Deadline != nil {
+               deadlineUnix := timeutil.TimeStamp(form.Deadline.Unix())
+               if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
+                       ctx.Error(500, "UpdateIssueDeadline", err)
+                       return
+               }
+               issue.DeadlineUnix = deadlineUnix
        }
 
        // Add/delete assignees