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

Report the correct number of pushes on the feeds (#16811) #16822

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion modules/repository/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type PushCommits struct {
Commits []*PushCommit
HeadCommit *PushCommit
CompareURL string
Len int

avatars map[string]string
emailUsers map[string]*models.User
Expand Down Expand Up @@ -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),
}
}
5 changes: 5 additions & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion templates/user/dashboard/feeds.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</li>
{{end}}
{{end}}
{{if and (gt (len $push.Commits) 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" (len $push.Commits)}} »</a></li>{{end}}
{{if and (gt $push.Len 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" $push.Len}} »</a></li>{{end}}
</ul>
</div>
{{else if eq .GetOpType 6}}
Expand Down