Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deleted milestone bug #1942

Merged
merged 3 commits into from
Jun 17, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,28 +228,22 @@ func (c *Comment) LoadLabel() error {
func (c *Comment) LoadMilestone() error {
if c.OldMilestoneID > 0 {
var oldMilestone Milestone
has, err := x.ID(c.OldMilestoneID).Get(&oldMilestone)
has, err := x.ID(c.OldMilestoneID).Get(oldMilestone)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be &oldMilestone

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunny Fixed

if err != nil {
return err
} else if !has {
return ErrMilestoneNotExist{
ID: c.OldMilestoneID,
}
} else if has {
c.OldMilestone = &oldMilestone
}
c.OldMilestone = &oldMilestone
}

if c.MilestoneID > 0 {
var milestone Milestone
has, err := x.ID(c.MilestoneID).Get(&milestone)
if err != nil {
return err
} else if !has {
return ErrMilestoneNotExist{
ID: c.MilestoneID,
}
} else if has {
c.Milestone = &milestone
}
c.Milestone = &milestone
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ issues.remove_label_at = `removed the <div class="ui label" style="color: %s; ba
issues.add_milestone_at = `added this to the <b>%s</b> milestone %s`
issues.change_milestone_at = `modified the milestone from <b>%s</b> to <b>%s</b> %s`
issues.remove_milestone_at = `removed this from the <b>%s</b> milestone %s`
issues.deleted_milestone = `(deleted)`
issues.self_assign_at = `self-assigned this %s`
issues.add_assignee_at = `was assigned by <b>%s</b> %s`
issues.remove_assignee_at = `removed their assignment %s`
Expand Down
10 changes: 10 additions & 0 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,16 @@ func ViewIssue(ctx *context.Context) {
ctx.Handle(500, "LoadMilestone", err)
return
}
ghostMilestone := &models.Milestone{
ID: -1,
Name: ctx.Tr("repo.issues.deleted_milestone"),
}
if comment.OldMilestoneID > 0 && comment.OldMilestone == nil {
comment.OldMilestone = ghostMilestone
}
if comment.MilestoneID > 0 && comment.Milestone == nil {
comment.Milestone = ghostMilestone
}
} else if comment.Type == models.CommentTypeAssignees {
if err = comment.LoadAssignees(); err != nil {
ctx.Handle(500, "LoadAssignees", err)
Expand Down