mirror of https://github.com/go-gitea/gitea.git
Prevent panic when dividing through zero
This commit is contained in:
parent
ed73af6fa1
commit
0d06c7e5f2
|
@ -19,6 +19,7 @@ var (
|
||||||
ErrIssueNotExist = errors.New("Issue does not exist")
|
ErrIssueNotExist = errors.New("Issue does not exist")
|
||||||
ErrLabelNotExist = errors.New("Label does not exist")
|
ErrLabelNotExist = errors.New("Label does not exist")
|
||||||
ErrMilestoneNotExist = errors.New("Milestone 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.
|
// Issue represents an issue or pull request of repository.
|
||||||
|
@ -703,6 +704,11 @@ func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error) {
|
||||||
if issue.IsClosed {
|
if issue.IsClosed {
|
||||||
m.NumClosedIssues++
|
m.NumClosedIssues++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.NumIssues == 0 {
|
||||||
|
return ErrWrongIssueCounter
|
||||||
|
}
|
||||||
|
|
||||||
m.Completeness = m.NumClosedIssues * 100 / m.NumIssues
|
m.Completeness = m.NumClosedIssues * 100 / m.NumIssues
|
||||||
if _, err = sess.Id(m.Id).Update(m); err != nil {
|
if _, err = sess.Id(m.Id).Update(m); err != nil {
|
||||||
sess.Rollback()
|
sess.Rollback()
|
||||||
|
|
Loading…
Reference in New Issue