summaryrefslogtreecommitdiffstats
path: root/models/issue_milestone.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-29 14:36:32 +0800
committerGitHub <noreply@github.com>2020-01-29 08:36:32 +0200
commitc09e020558318feebbdce477f91c94411e8959b6 (patch)
tree49a83b33103c114c7068a33bb246e066ae1062e0 /models/issue_milestone.go
parentf29c301040a9de42130b1b1d15f94b5869137f08 (diff)
downloadgitea-c09e020558318feebbdce477f91c94411e8959b6.tar.gz
gitea-c09e020558318feebbdce477f91c94411e8959b6.zip
Fix milestone API state parameter unhandled (#10049)
* Fix milestone API state parameter unhandled * Fix test
Diffstat (limited to 'models/issue_milestone.go')
-rw-r--r--models/issue_milestone.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/models/issue_milestone.go b/models/issue_milestone.go
index 198fa7d78c..ba39e6ebc6 100644
--- a/models/issue_milestone.go
+++ b/models/issue_milestone.go
@@ -291,12 +291,33 @@ func updateMilestone(e Engine, m *Milestone) error {
}
// UpdateMilestone updates information of given milestone.
-func UpdateMilestone(m *Milestone) error {
- if err := updateMilestone(x, m); err != nil {
+func UpdateMilestone(m *Milestone, oldIsClosed bool) error {
+ sess := x.NewSession()
+ defer sess.Close()
+ if err := sess.Begin(); err != nil {
+ return err
+ }
+
+ if m.IsClosed && !oldIsClosed {
+ m.ClosedDateUnix = timeutil.TimeStampNow()
+ }
+
+ if err := updateMilestone(sess, m); err != nil {
return err
}
- return updateMilestoneCompleteness(x, m.ID)
+ if err := updateMilestoneCompleteness(sess, m.ID); err != nil {
+ return err
+ }
+
+ // if IsClosed changed, update milestone numbers of repository
+ if oldIsClosed != m.IsClosed {
+ if err := updateRepoMilestoneNum(sess, m.RepoID); err != nil {
+ return err
+ }
+ }
+
+ return sess.Commit()
}
func updateMilestoneCompleteness(e Engine, milestoneID int64) error {