0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-01-09 15:29:25 +01:00

demilestone should not include milestone (#32923) (#32979)

Backport #32923 by @lunny

Fix #32887

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Giteabot 2024-12-25 16:03:18 +08:00 committed by GitHub
parent 6636b37a9c
commit ad1b76540e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -59,6 +59,10 @@ func changeMilestoneAssign(ctx context.Context, doer *user_model.User, issue *is
} }
} }
if issue.MilestoneID == 0 {
issue.Milestone = nil
}
return nil return nil
} }

View File

@ -23,6 +23,7 @@ func TestChangeMilestoneAssign(t *testing.T) {
oldMilestoneID := issue.MilestoneID oldMilestoneID := issue.MilestoneID
issue.MilestoneID = 2 issue.MilestoneID = 2
assert.NoError(t, issue.LoadMilestone(db.DefaultContext))
assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID)) assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID))
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{
IssueID: issue.ID, IssueID: issue.ID,
@ -31,4 +32,11 @@ func TestChangeMilestoneAssign(t *testing.T) {
OldMilestoneID: oldMilestoneID, OldMilestoneID: oldMilestoneID,
}) })
unittest.CheckConsistencyFor(t, &issues_model.Milestone{}, &issues_model.Issue{}) unittest.CheckConsistencyFor(t, &issues_model.Milestone{}, &issues_model.Issue{})
assert.NotNil(t, issue.Milestone)
oldMilestoneID = issue.MilestoneID
issue.MilestoneID = 0
assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID))
assert.EqualValues(t, 0, issue.MilestoneID)
assert.Nil(t, issue.Milestone)
} }