aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-06-02 17:30:15 -0400
committerUnknwon <u@gogs.io>2017-06-02 17:30:15 -0400
commit6bb9c442b2d95bf683702c089085bb50b987818f (patch)
tree480af511bf91127f139e3f1222335b1fd4f72334
parentc4079216440af73c03343f53a6a4734688c87b60 (diff)
issue: fix updated_unix is not updated for new comments (#4462)
-rw-r--r--gogs.go2
-rw-r--r--models/comment.go3
-rw-r--r--routers/repo/issue.go34
-rw-r--r--templates/.VERSION2
4 files changed, 22 insertions, 19 deletions
diff --git a/gogs.go b/gogs.go
index 2252f6e1..c25e395f 100644
--- a/gogs.go
+++ b/gogs.go
@@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting"
)
-const APP_VER = "0.11.12.0529"
+const APP_VER = "0.11.13.0602"
func init() {
setting.AppVer = APP_VER
diff --git a/models/comment.go b/models/comment.go
index 673ca780..be29e2ba 100644
--- a/models/comment.go
+++ b/models/comment.go
@@ -275,7 +275,10 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
if err != nil {
return nil, err
}
+ }
+ if _, err = e.Exec("UPDATE `issue` SET updated_unix = ? WHERE id = ?", time.Now().Unix(), opts.Issue.ID); err != nil {
+ return nil, fmt.Errorf("update issue 'updated_unix': %v", err)
}
// Notify watchers for whatever action comes in, ignore if no action type.
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 72b1a388..03d29d24 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -822,9 +822,9 @@ func UpdateIssueAssignee(ctx *context.Context) {
})
}
-func NewComment(ctx *context.Context, f form.CreateComment) {
- issue := getActionIssue(ctx)
- if ctx.Written() {
+func NewComment(c *context.Context, f form.CreateComment) {
+ issue := getActionIssue(c)
+ if c.Written() {
return
}
@@ -833,9 +833,9 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
attachments = f.Files
}
- if ctx.HasError() {
- ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
- ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
+ if c.HasError() {
+ c.Flash.Error(c.Data["ErrorMsg"].(string))
+ c.Redirect(fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issue.Index))
return
}
@@ -843,7 +843,7 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
var comment *models.Comment
defer func() {
// Check if issue admin/poster changes the status of issue.
- if (ctx.Repo.IsWriter() || (ctx.IsLogged && issue.IsPoster(ctx.User.ID))) &&
+ if (c.Repo.IsWriter() || (c.IsLogged && issue.IsPoster(c.User.ID))) &&
(f.Status == "reopen" || f.Status == "close") &&
!(issue.IsPull && issue.PullRequest.HasMerged) {
@@ -855,7 +855,7 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
pr, err = models.GetUnmergedPullRequest(pull.HeadRepoID, pull.BaseRepoID, pull.HeadBranch, pull.BaseBranch)
if err != nil {
if !models.IsErrPullRequestNotExist(err) {
- ctx.Handle(500, "GetUnmergedPullRequest", err)
+ c.ServerError("GetUnmergedPullRequest", err)
return
}
}
@@ -863,7 +863,7 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
// Regenerate patch and test conflict.
if pr == nil {
if err = issue.PullRequest.UpdatePatch(); err != nil {
- ctx.Handle(500, "UpdatePatch", err)
+ c.ServerError("UpdatePatch", err)
return
}
@@ -872,10 +872,10 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
}
if pr != nil {
- ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
+ c.Flash.Info(c.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
} else {
- if err = issue.ChangeStatus(ctx.User, ctx.Repo.Repository, f.Status == "close"); err != nil {
- log.Error(4, "ChangeStatus: %v", err)
+ if err = issue.ChangeStatus(c.User, c.Repo.Repository, f.Status == "close"); err != nil {
+ log.Error(2, "ChangeStatus: %v", err)
} else {
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
}
@@ -888,9 +888,9 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
typeName = "pulls"
}
if comment != nil {
- ctx.Redirect(fmt.Sprintf("%s/%s/%d#%s", ctx.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
+ c.Redirect(fmt.Sprintf("%s/%s/%d#%s", c.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
} else {
- ctx.Redirect(fmt.Sprintf("%s/%s/%d", ctx.Repo.RepoLink, typeName, issue.Index))
+ c.Redirect(fmt.Sprintf("%s/%s/%d", c.Repo.RepoLink, typeName, issue.Index))
}
}()
@@ -899,13 +899,13 @@ func NewComment(ctx *context.Context, f form.CreateComment) {
return
}
- comment, err = models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, f.Content, attachments)
+ comment, err = models.CreateIssueComment(c.User, c.Repo.Repository, issue, f.Content, attachments)
if err != nil {
- ctx.Handle(500, "CreateIssueComment", err)
+ c.ServerError("CreateIssueComment", err)
return
}
- log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
+ log.Trace("Comment created: %d/%d/%d", c.Repo.Repository.ID, issue.ID, comment.ID)
}
func UpdateCommentContent(ctx *context.Context) {
diff --git a/templates/.VERSION b/templates/.VERSION
index 0d9bfcbc..8a829c0c 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.11.12.0529 \ No newline at end of file
+0.11.13.0602 \ No newline at end of file