summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
author无闻 <joe2010xtmf@163.com>2014-07-22 16:24:16 -0400
committer无闻 <joe2010xtmf@163.com>2014-07-22 16:24:16 -0400
commit94b100ce4380c62bba2b5e18a74394da3ec482c2 (patch)
treeeacf7c6c53ce6472fb782aa14b494df1cd5945e5 /models/issue.go
parent40557a4f79dfa212434d7c3950b47f077708737d (diff)
parent0d06c7e5f2f8239383a3727c69ef938d12c037e2 (diff)
downloadgitea-94b100ce4380c62bba2b5e18a74394da3ec482c2.tar.gz
gitea-94b100ce4380c62bba2b5e18a74394da3ec482c2.zip
Merge pull request #299 from nuss-justin/issue/216
Fix #216. Change milestones, labels and assigne without reloading the page
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go
index c370af363e..6253837237 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -19,6 +19,7 @@ var (
ErrIssueNotExist = errors.New("Issue does not exist")
ErrLabelNotExist = errors.New("Label does not exist")
ErrMilestoneNotExist = errors.New("Milestone does not exist")
+ ErrWrongIssueCounter = errors.New("Invalid number of issues for this milestone")
)
// Issue represents an issue or pull request of repository.
@@ -713,6 +714,11 @@ func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error) {
if issue.IsClosed {
m.NumClosedIssues++
}
+
+ if m.NumIssues == 0 {
+ return ErrWrongIssueCounter
+ }
+
m.Completeness = m.NumClosedIssues * 100 / m.NumIssues
if _, err = sess.Id(m.Id).Update(m); err != nil {
sess.Rollback()