diff --git a/modules/repository/commits.go b/modules/repository/commits.go index eaaf3b8b1..8eaa640d5 100644 --- a/modules/repository/commits.go +++ b/modules/repository/commits.go @@ -31,6 +31,7 @@ type PushCommits struct { Commits []*PushCommit HeadCommit *PushCommit CompareURL string + Len int avatars map[string]string emailUsers map[string]*models.User @@ -182,5 +183,12 @@ func ListToPushCommits(l *list.List) *PushCommits { commit := CommitToPushCommit(e.Value.(*git.Commit)) commits = append(commits, commit) } - return &PushCommits{commits, nil, "", make(map[string]string), make(map[string]*models.User)} + return &PushCommits{ + Commits: commits, + HeadCommit: nil, + CompareURL: "", + Len: len(commits), + avatars: make(map[string]string), + emailUsers: make(map[string]*models.User), + } } diff --git a/modules/templates/helper.go b/modules/templates/helper.go index f9b2dafd2..fcddb59d6 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -848,6 +848,11 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits { if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil { log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err) } + + if push.Len == 0 { + push.Len = len(push.Commits) + } + return push } diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 6ed75ee14..057a4a762 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -101,7 +101,7 @@ {{end}} {{end}} - {{if and (gt (len $push.Commits) 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" (len $push.Commits)}} »
  • {{end}} + {{if and (gt $push.Len 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" $push.Len}} »
  • {{end}} {{else if eq .GetOpType 6}}