diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-12-25 06:52:46 +0100 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-12-28 20:24:24 +0100 |
commit | 2ffa9a5e6e24715ab62a571ca1ca9a531944ca86 (patch) | |
tree | 7e9018b6a2239922e97d397cc4a798f2b646dd65 /services | |
parent | fix trailing comma not matched in the case of alphanumeric issue (#32945) (diff) | |
download | forgejo-2ffa9a5e6e24715ab62a571ca1ca9a531944ca86.tar.xz forgejo-2ffa9a5e6e24715ab62a571ca1ca9a531944ca86.zip |
demilestone should not include milestone (#32923)
Fix #32887
(cherry picked from commit f44712f22bc7bfce049c64c27f60453ff1e41a5c)
Conflicts:
services/issue/milestone_test.go
trivial conflicts (require vs assert)
Diffstat (limited to 'services')
-rw-r--r-- | services/issue/milestone.go | 4 | ||||
-rw-r--r-- | services/issue/milestone_test.go | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/services/issue/milestone.go b/services/issue/milestone.go index 31490c7b03..407ad0a59b 100644 --- a/services/issue/milestone.go +++ b/services/issue/milestone.go @@ -85,6 +85,10 @@ func changeMilestoneAssign(ctx context.Context, doer *user_model.User, issue *is } } + if issue.MilestoneID == 0 { + issue.Milestone = nil + } + return nil } diff --git a/services/issue/milestone_test.go b/services/issue/milestone_test.go index 1c06572f8e..e75f64550c 100644 --- a/services/issue/milestone_test.go +++ b/services/issue/milestone_test.go @@ -24,6 +24,7 @@ func TestChangeMilestoneAssign(t *testing.T) { oldMilestoneID := issue.MilestoneID issue.MilestoneID = 2 + require.NoError(t, issue.LoadMilestone(db.DefaultContext)) require.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID)) unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ IssueID: issue.ID, @@ -32,4 +33,11 @@ func TestChangeMilestoneAssign(t *testing.T) { OldMilestoneID: oldMilestoneID, }) unittest.CheckConsistencyFor(t, &issues_model.Milestone{}, &issues_model.Issue{}) + assert.NotNil(t, issue.Milestone) + + oldMilestoneID = issue.MilestoneID + issue.MilestoneID = 0 + require.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID)) + assert.EqualValues(t, 0, issue.MilestoneID) + assert.Nil(t, issue.Milestone) } |