(c *context.Context, filename string)
| 37 | } |
| 38 | |
| 39 | func 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 | |
| 77 | func Commits(c *context.Context) { |
| 78 | renderCommits(c, "") |
no test coverage detected