Skip to content

Commit ba6baff

Browse files
Report the correct number of pushes on the feeds (#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 #16804 Signed-off-by: Andrew Thornton <[email protected]> * Update templates/user/dashboard/feeds.tmpl Co-authored-by: techknowlogick <[email protected]>
1 parent 28ac4a7 commit ba6baff

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
@@ -30,6 +30,7 @@ type PushCommits struct {
3030
Commits []*PushCommit
3131
HeadCommit *PushCommit
3232
CompareURL string
33+
Len int
3334

3435
avatars map[string]string
3536
emailUsers map[string]*models.User
@@ -180,5 +181,12 @@ func GitToPushCommits(gitCommits []*git.Commit) *PushCommits {
180181
for _, commit := range gitCommits {
181182
commits = append(commits, CommitToPushCommit(commit))
182183
}
183-
return &PushCommits{commits, nil, "", make(map[string]string), make(map[string]*models.User)}
184+
return &PushCommits{
185+
Commits: commits,
186+
HeadCommit: nil,
187+
CompareURL: "",
188+
Len: len(commits),
189+
avatars: make(map[string]string),
190+
emailUsers: make(map[string]*models.User),
191+
}
184192
}

modules/templates/helper.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,11 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
819819
if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil {
820820
log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err)
821821
}
822+
823+
if push.Len == 0 {
824+
push.Len = len(push.Commits)
825+
}
826+
822827
return push
823828
}
824829

templates/user/dashboard/feeds.tmpl

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

0 commit comments

Comments
 (0)