|
|
|
@ -8,7 +8,6 @@ import (
|
|
|
|
|
"container/list" |
|
|
|
|
"path" |
|
|
|
|
|
|
|
|
|
"github.com/Unknwon/com" |
|
|
|
|
"github.com/Unknwon/paginater" |
|
|
|
|
|
|
|
|
|
"github.com/gogits/gogs/models" |
|
|
|
@ -46,18 +45,6 @@ func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
|
|
|
|
|
func Commits(ctx *middleware.Context) { |
|
|
|
|
ctx.Data["PageIsCommits"] = true |
|
|
|
|
|
|
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
|
|
|
|
|
|
brs, err := ctx.Repo.GitRepo.GetBranches() |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "GetBranches", err) |
|
|
|
|
return |
|
|
|
|
} else if len(brs) == 0 { |
|
|
|
|
ctx.Handle(404, "GetBranches", nil) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
commitsCount, err := ctx.Repo.Commit.CommitsCount() |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "GetCommitsCount", err) |
|
|
|
@ -78,11 +65,12 @@ func Commits(ctx *middleware.Context) {
|
|
|
|
|
} |
|
|
|
|
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink) |
|
|
|
|
commits = models.ValidateCommitsWithEmails(commits) |
|
|
|
|
|
|
|
|
|
ctx.Data["Commits"] = commits |
|
|
|
|
ctx.Data["Username"] = userName |
|
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
|
|
|
|
|
|
ctx.Data["Username"] = ctx.Repo.Owner.Name |
|
|
|
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name |
|
|
|
|
ctx.Data["CommitCount"] = commitsCount |
|
|
|
|
ctx.Data["Branch"] = ctx.Repo.BranchName |
|
|
|
|
ctx.HTML(200, COMMITS) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -95,18 +83,6 @@ func SearchCommits(ctx *middleware.Context) {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
userName := ctx.Params(":username") |
|
|
|
|
repoName := ctx.Params(":reponame") |
|
|
|
|
|
|
|
|
|
brs, err := ctx.Repo.GitRepo.GetBranches() |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "GetBranches", err) |
|
|
|
|
return |
|
|
|
|
} else if len(brs) == 0 { |
|
|
|
|
ctx.Handle(404, "GetBranches", nil) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
commits, err := ctx.Repo.Commit.SearchCommits(keyword) |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "SearchCommits", err) |
|
|
|
@ -114,12 +90,13 @@ func SearchCommits(ctx *middleware.Context) {
|
|
|
|
|
} |
|
|
|
|
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink) |
|
|
|
|
commits = models.ValidateCommitsWithEmails(commits) |
|
|
|
|
ctx.Data["Commits"] = commits |
|
|
|
|
|
|
|
|
|
ctx.Data["Keyword"] = keyword |
|
|
|
|
ctx.Data["Username"] = userName |
|
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
|
ctx.Data["Username"] = ctx.Repo.Owner.Name |
|
|
|
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name |
|
|
|
|
ctx.Data["CommitCount"] = commits.Len() |
|
|
|
|
ctx.Data["Commits"] = commits |
|
|
|
|
ctx.Data["Branch"] = ctx.Repo.BranchName |
|
|
|
|
ctx.HTML(200, COMMITS) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -132,58 +109,36 @@ func FileHistory(ctx *middleware.Context) {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
|
branchName := ctx.Repo.BranchName |
|
|
|
|
|
|
|
|
|
brs, err := ctx.Repo.GitRepo.GetBranches() |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "GetBranches", err) |
|
|
|
|
return |
|
|
|
|
} else if len(brs) == 0 { |
|
|
|
|
ctx.Handle(404, "GetBranches", nil) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(branchName, fileName) |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "repo.FileHistory(GetCommitsCount)", err) |
|
|
|
|
ctx.Handle(500, "FileCommitsCount", err) |
|
|
|
|
return |
|
|
|
|
} else if commitsCount == 0 { |
|
|
|
|
ctx.Handle(404, "repo.FileHistory", nil) |
|
|
|
|
ctx.Handle(404, "FileCommitsCount", nil) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Calculate and validate page number.
|
|
|
|
|
page := com.StrTo(ctx.Query("p")).MustInt() |
|
|
|
|
if page < 1 { |
|
|
|
|
page := ctx.QueryInt("page") |
|
|
|
|
if page <= 1 { |
|
|
|
|
page = 1 |
|
|
|
|
} |
|
|
|
|
lastPage := page - 1 |
|
|
|
|
if lastPage < 0 { |
|
|
|
|
lastPage = 0 |
|
|
|
|
} |
|
|
|
|
nextPage := page + 1 |
|
|
|
|
if nextPage*50 > commitsCount { |
|
|
|
|
nextPage = 0 |
|
|
|
|
} |
|
|
|
|
ctx.Data["Page"] = paginater.New(commitsCount, git.CommitsRangeSize, page, 5) |
|
|
|
|
|
|
|
|
|
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange( |
|
|
|
|
branchName, fileName, page) |
|
|
|
|
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page) |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err) |
|
|
|
|
ctx.Handle(500, "CommitsByFileAndRange", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink) |
|
|
|
|
commits = models.ValidateCommitsWithEmails(commits) |
|
|
|
|
|
|
|
|
|
ctx.Data["Commits"] = commits |
|
|
|
|
ctx.Data["Username"] = userName |
|
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
|
|
|
|
|
|
ctx.Data["Username"] = ctx.Repo.Owner.Name |
|
|
|
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name |
|
|
|
|
ctx.Data["FileName"] = fileName |
|
|
|
|
ctx.Data["CommitCount"] = commitsCount |
|
|
|
|
ctx.Data["LastPageNum"] = lastPage |
|
|
|
|
ctx.Data["NextPageNum"] = nextPage |
|
|
|
|
ctx.Data["Branch"] = branchName |
|
|
|
|
ctx.HTML(200, COMMITS) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|