Skip to content

Commit

Permalink
Fix deadline on update issue or PR via API (#8696)
Browse files Browse the repository at this point in the history
* Fix deadline on update issue or PR via API

* variable initialized directly (review comment)
  • Loading branch information
davidsvantesson authored and lafriks committed Oct 27, 2019
1 parent 478f7db commit 018b0e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions routers/api/v1/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 018b0e8

Please sign in to comment.