Skip to content

Commit 9cc9c7c

Browse files
Report the correct number of pushes on the feeds (go-gitea#16811)
* Report the correct number of pushes on the feeds Since the number of commits in the Action table has been limited to 5 the number of commits reported on the feeds page is now incorrectly also limited to 5. The correct number is available as the Len and this PR changes this to report this. Fix go-gitea#16804 Signed-off-by: Andrew Thornton <[email protected]> * Update templates/user/dashboard/feeds.tmpl Co-authored-by: techknowlogick <[email protected]>
1 parent 695e8ae commit 9cc9c7c

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

modules/repository/commits.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type PushCommits struct {
3131
Commits []*PushCommit
3232
HeadCommit *PushCommit
3333
CompareURL string
34+
Len int
3435

3536
avatars map[string]string
3637
emailUsers map[string]*models.User
@@ -182,5 +183,12 @@ func ListToPushCommits(l *list.List) *PushCommits {
182183
commit := CommitToPushCommit(e.Value.(*git.Commit))
183184
commits = append(commits, commit)
184185
}
185-
return &PushCommits{commits, nil, "", make(map[string]string), make(map[string]*models.User)}
186+
return &PushCommits{
187+
Commits: commits,
188+
HeadCommit: nil,
189+
CompareURL: "",
190+
Len: len(commits),
191+
avatars: make(map[string]string),
192+
emailUsers: make(map[string]*models.User),
193+
}
186194
}

modules/templates/helper.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
848848
if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil {
849849
log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err)
850850
}
851+
852+
if push.Len == 0 {
853+
push.Len = len(push.Commits)
854+
}
855+
851856
return push
852857
}
853858

templates/user/dashboard/feeds.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</li>
102102
{{end}}
103103
{{end}}
104-
{{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}}
104+
{{if and (gt $push.Len 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" $push.Len}} »</a></li>{{end}}
105105
</ul>
106106
</div>
107107
{{else if eq .GetOpType 6}}

0 commit comments

Comments
 (0)