summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-13 11:26:25 -0400
committerUnknwon <u@gogs.io>2015-09-13 11:26:25 -0400
commitb0bf4cc1cb6e68968fa4a6076f57045a268026e9 (patch)
tree8af89b3d3a72e7769b369603884eaa988e46e548 /routers/repo/issue.go
parent98108e379d8931dc7eeafa25acf4e523039b6502 (diff)
downloadgitea-b0bf4cc1cb6e68968fa4a6076f57045a268026e9.tar.gz
gitea-b0bf4cc1cb6e68968fa4a6076f57045a268026e9.zip
fix #1632 and #1606
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index e242dd0e5f..f9a560827a 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -759,6 +759,20 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) {
return
}
+ defer func() {
+ // Check if issue owner/poster changes the status of issue.
+ if (ctx.Repo.IsOwner() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) &&
+ (form.Status == "reopen" || form.Status == "close") &&
+ !(issue.IsPull && issue.HasMerged) {
+ issue.Repo = ctx.Repo.Repository
+ if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil {
+ log.Error(4, "ChangeStatus: %v", err)
+ } else {
+ log.Trace("Issue[%d] status changed: %v", issue.ID, !issue.IsClosed)
+ }
+ }
+ }()
+
// Fix #321: Allow empty comments, as long as we have attachments.
if len(form.Content) == 0 && len(attachments) == 0 {
ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
@@ -810,18 +824,6 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) {
}
log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
- // Check if issue owner/poster changes the status of issue.
- if (ctx.Repo.IsOwner() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) &&
- (form.Status == "reopen" || form.Status == "close") &&
- !(issue.IsPull && issue.HasMerged) {
- issue.Repo = ctx.Repo.Repository
- if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil {
- ctx.Handle(500, "ChangeStatus", err)
- return
- }
- log.Trace("Issue[%d] status changed: %v", issue.ID, !issue.IsClosed)
- }
-
ctx.Redirect(fmt.Sprintf("%s/issues/%d#%s", ctx.Repo.RepoLink, issue.Index, comment.HashTag()))
}