MCPcopy Create free account
hub / github.com/gogs/gogs / renderCommits

Function renderCommits

internal/route/repo/commit.go:39–75  ·  view source on GitHub ↗
(c *context.Context, filename string)

Source from the content-addressed store, hash-verified

37}
38
39func renderCommits(c *context.Context, filename string) {
40 c.Data["Title"] = c.Tr("repo.commits.commit_history") + " · " + c.Repo.Repository.FullName()
41 c.Data["PageIsCommits"] = true
42 c.Data["FileName"] = filename
43
44 page := c.QueryInt("page")
45 if page < 1 {
46 page = 1
47 }
48 pageSize := c.QueryInt("pageSize")
49 if pageSize < 1 {
50 pageSize = conf.UI.User.CommitsPagingNum
51 }
52
53 commits, err := c.Repo.Commit.CommitsByPage(page, pageSize, git.CommitsByPageOptions{Path: filename})
54 if err != nil {
55 c.Error(err, "paging commits")
56 return
57 }
58
59 commits = RenderIssueLinks(commits, c.Repo.RepoLink)
60 c.Data["Commits"] = matchUsersWithCommitEmails(c.Req.Context(), commits)
61
62 if page > 1 {
63 c.Data["HasPrevious"] = true
64 c.Data["PreviousPage"] = page - 1
65 }
66 if len(commits) == pageSize {
67 c.Data["HasNext"] = true
68 c.Data["NextPage"] = page + 1
69 }
70 c.Data["PageSize"] = pageSize
71
72 c.Data["Username"] = c.Repo.Owner.Name
73 c.Data["Reponame"] = c.Repo.Repository.Name
74 c.Success(COMMITS)
75}
76
77func Commits(c *context.Context) {
78 renderCommits(c, "")

Callers 2

CommitsFunction · 0.85
FileHistoryFunction · 0.85

Calls 6

RenderIssueLinksFunction · 0.85
TrMethod · 0.80
SuccessMethod · 0.80
FullNameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected