diff options
author | 无闻 <joe2010xtmf@163.com> | 2014-07-22 16:46:20 -0400 |
---|---|---|
committer | 无闻 <joe2010xtmf@163.com> | 2014-07-22 16:46:20 -0400 |
commit | 6e9f1c52b18f112eecd5c72e295cfea1809f07fa (patch) | |
tree | 7282a5567458560c71896fbe0382d11d5982d443 /routers/repo/issue.go | |
parent | 94b100ce4380c62bba2b5e18a74394da3ec482c2 (diff) | |
parent | 812f71e21b5cbd998c12647fa879fa8ea2cace86 (diff) | |
download | gitea-6e9f1c52b18f112eecd5c72e295cfea1809f07fa.tar.gz gitea-6e9f1c52b18f112eecd5c72e295cfea1809f07fa.zip |
Merge pull request #301 from nuss-justin/bugfix/milestone-counter
Update milestone issue stats when reopening/closing issue
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 5fe9ebc390..e71c835fd8 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -642,6 +642,29 @@ func Comment(ctx *middleware.Context, params martini.Params) { return } + // Change open/closed issue counter for the associated milestone + if issue.MilestoneId > 0 { + l, err := models.GetMilestoneById(issue.MilestoneId) + + if err != nil { + ctx.Handle(500, "issue.Comment(GetLabelById)", err) + return + } + + if issue.IsClosed { + l.NumOpenIssues = l.NumOpenIssues - 1 + l.NumClosedIssues = l.NumClosedIssues + 1 + } else { + l.NumOpenIssues = l.NumOpenIssues + 1 + l.NumClosedIssues = l.NumClosedIssues - 1 + } + + if err = models.UpdateMilestone(l); err != nil { + ctx.Handle(500, "issue.Comment(UpdateLabel)", err) + return + } + } + cmtType := models.IT_CLOSE if !issue.IsClosed { cmtType = models.IT_REOPEN |