aboutsummaryrefslogtreecommitdiffstats
path: root/services/issue/milestone.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/issue/milestone.go')
-rw-r--r--services/issue/milestone.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/services/issue/milestone.go b/services/issue/milestone.go
index af337c3f14..d7c5fa4551 100644
--- a/services/issue/milestone.go
+++ b/services/issue/milestone.go
@@ -15,6 +15,17 @@ import (
)
func changeMilestoneAssign(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldMilestoneID int64) error {
+ // Only check if milestone exists if we don't remove it.
+ if issue.MilestoneID > 0 {
+ has, err := issues_model.HasMilestoneByRepoID(ctx, issue.RepoID, issue.MilestoneID)
+ if err != nil {
+ return fmt.Errorf("HasMilestoneByRepoID: %v", err)
+ }
+ if !has {
+ return fmt.Errorf("HasMilestoneByRepoID: issue doesn't exist")
+ }
+ }
+
if err := issues_model.UpdateIssueCols(ctx, issue, "milestone_id"); err != nil {
return err
}