Skip to content

Commit

Permalink
demilestone should not include milestone (#32923)
Browse files Browse the repository at this point in the history
Fix #32887
  • Loading branch information
lunny authored Dec 25, 2024
1 parent 1a7591d commit f44712f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions services/issue/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ func changeMilestoneAssign(ctx context.Context, doer *user_model.User, issue *is
}
}

if issue.MilestoneID == 0 {
issue.Milestone = nil
}

return nil
}

Expand Down
8 changes: 8 additions & 0 deletions services/issue/milestone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestChangeMilestoneAssign(t *testing.T) {

oldMilestoneID := issue.MilestoneID
issue.MilestoneID = 2
assert.NoError(t, issue.LoadMilestone(db.DefaultContext))
assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID))
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{
IssueID: issue.ID,
Expand All @@ -31,4 +32,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
assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID))
assert.EqualValues(t, 0, issue.MilestoneID)
assert.Nil(t, issue.Milestone)
}

0 comments on commit f44712f

Please sign in to comment.