summaryrefslogtreecommitdiffstats
path: root/services/issue/milestone.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-30 23:55:08 +0800
committerGitHub <noreply@github.com>2022-06-30 23:55:08 +0800
commit184a7d4195baffb169f24f4e9a4524f8d4045e91 (patch)
treeb7d620626be91e789115d41d9829518e4119c4a1 /services/issue/milestone.go
parentdb3355cb1aa206fc9f1cf786543607204f628218 (diff)
downloadgitea-184a7d4195baffb169f24f4e9a4524f8d4045e91.tar.gz
gitea-184a7d4195baffb169f24f4e9a4524f8d4045e91.zip
Check if project has the same repository id with issue when assign project to issue (#20133)
* Check if project has the same repository id with issue when assign project to issue * Check if issue's repository id match project's repository id * Add more permission checking * Remove invalid argument * Fix errors * Add generic check * Remove duplicated check * Return error + add check for new issues * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: 6543 <6543@obermui.de>
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
}