Skip to content

Commit

Permalink
Fix deleted milestone bug (go-gitea#1942)
Browse files Browse the repository at this point in the history
* Fix deleted milestone bug

* Use locale for ghost milestone name

* Fix pointer bug
  • Loading branch information
ethantkoenig authored and lunny committed Aug 13, 2017
1 parent 1709297 commit b3647ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
14 changes: 4 additions & 10 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,25 +231,19 @@ func (c *Comment) LoadMilestone() error {
has, err := x.ID(c.OldMilestoneID).Get(&oldMilestone)
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 @@ -558,6 +558,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 @@ -596,6 +596,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

0 comments on commit b3647ad

Please sign in to comment.