]> source.dussan.org Git - gitea.git/commitdiff
Fix deleted milestone bug (#1942)
authorEthan Koenig <etk39@cornell.edu>
Sat, 17 Jun 2017 04:51:28 +0000 (00:51 -0400)
committerLunny Xiao <xiaolunwen@gmail.com>
Sat, 17 Jun 2017 04:51:28 +0000 (12:51 +0800)
* Fix deleted milestone bug

* Use locale for ghost milestone name

* Fix pointer bug

models/issue_comment.go
options/locale/locale_en-US.ini
routers/repo/issue.go

index 69edf28f54326d2eab466221e5474e664eae6550..91d8551518d33a1efe9518c641638a4b0aca0434 100644 (file)
@@ -231,12 +231,9 @@ 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 {
@@ -244,12 +241,9 @@ func (c *Comment) LoadMilestone() error {
                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
 }
index c2df7f27dce32a25bd2b789befcbe1a5c69c375d..c1aa44e8d7a4eeb2d4b9ba6418bb8c4b9e0379fd 100644 (file)
@@ -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`
index b94eddc4efb5776b4fd2d3e01509c8330abb1cd1..b5b620dbb3db0dd0db4ecd7ec2381512225cfe90 100644 (file)
@@ -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)