diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2019-10-28 00:35:20 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-10-28 01:35:20 +0200 |
commit | 018b0e818038f3c38cc6bfc96fadeb25c92380e6 (patch) | |
tree | 865e142708862e9b64abef4a481619cac10b5a12 /routers/api | |
parent | 478f7db68ee42f2a873e554d8cfcf56f3ab82f99 (diff) | |
download | gitea-018b0e818038f3c38cc6bfc96fadeb25c92380e6.tar.gz gitea-018b0e818038f3c38cc6bfc96fadeb25c92380e6.zip |
Fix deadline on update issue or PR via API (#8696)
* Fix deadline on update issue or PR via API
* variable initialized directly (review comment)
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/issue.go | 15 | ||||
-rw-r--r-- | routers/api/v1/repo/pull.go | 15 |
2 files changed, 14 insertions, 16 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 9529e09b29..a41abba4cd 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -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 diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 6b20844c51..77fb452938 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -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 |