loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fixed commit count. (#17698)

Added "Tag" label.
Unified branch, tag and commit name.

authored by

KN4CK3R and committed by
GitHub
ea42d3c0 3c4724d7

+35 -32
+11 -7
modules/context/repo.go
··· 59 59 Commit *git.Commit 60 60 Tag *git.Tag 61 61 GitRepo *git.Repository 62 + RefName string 62 63 BranchName string 63 64 TagName string 64 65 TreePath string ··· 191 192 case r.IsViewBranch: 192 193 return "branch/" + util.PathEscapeSegments(r.BranchName) 193 194 case r.IsViewTag: 194 - return "tag/" + util.PathEscapeSegments(r.BranchName) 195 + return "tag/" + util.PathEscapeSegments(r.TagName) 195 196 case r.IsViewCommit: 196 - return "commit/" + util.PathEscapeSegments(r.BranchName) 197 + return "commit/" + util.PathEscapeSegments(r.CommitID) 197 198 } 198 199 log.Error("Unknown view type for repo: %v", r) 199 200 return "" ··· 563 564 ctx.Data["Branches"] = brs 564 565 ctx.Data["BranchesCount"] = len(brs) 565 566 566 - ctx.Data["TagName"] = ctx.Repo.TagName 567 - 568 567 // If not branch selected, try default one. 569 568 // If default branch doesn't exists, fall back to some other branch. 570 569 if len(ctx.Repo.BranchName) == 0 { ··· 573 572 } else if len(brs) > 0 { 574 573 ctx.Repo.BranchName = brs[0] 575 574 } 575 + ctx.Repo.RefName = ctx.Repo.BranchName 576 576 } 577 577 ctx.Data["BranchName"] = ctx.Repo.BranchName 578 - ctx.Data["CommitID"] = ctx.Repo.CommitID 579 578 580 579 // People who have push access or have forked repository can propose a new pull request. 581 580 canPush := ctx.Repo.CanWrite(unit_model.TypeCode) || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) ··· 781 780 // Get default branch. 782 781 if len(ctx.Params("*")) == 0 { 783 782 refName = ctx.Repo.Repository.DefaultBranch 784 - ctx.Repo.BranchName = refName 785 783 if !ctx.Repo.GitRepo.IsBranchExist(refName) { 786 784 brs, _, err := ctx.Repo.GitRepo.GetBranches(0, 0) 787 785 if err != nil { ··· 795 793 } 796 794 refName = brs[0] 797 795 } 796 + ctx.Repo.RefName = refName 797 + ctx.Repo.BranchName = refName 798 798 ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName) 799 799 if err != nil { 800 800 ctx.ServerError("GetBranchCommit", err) ··· 805 805 806 806 } else { 807 807 refName = getRefName(ctx, refType) 808 - ctx.Repo.BranchName = refName 808 + ctx.Repo.RefName = refName 809 809 isRenamedBranch, has := ctx.Data["IsRenamedBranch"].(bool) 810 810 if isRenamedBranch && has { 811 811 renamedBranchName := ctx.Data["RenamedBranchName"].(string) ··· 817 817 818 818 if refType.RefTypeIncludesBranches() && ctx.Repo.GitRepo.IsBranchExist(refName) { 819 819 ctx.Repo.IsViewBranch = true 820 + ctx.Repo.BranchName = refName 820 821 821 822 ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName) 822 823 if err != nil { ··· 827 828 828 829 } else if refType.RefTypeIncludesTags() && ctx.Repo.GitRepo.IsTagExist(refName) { 829 830 ctx.Repo.IsViewTag = true 831 + ctx.Repo.TagName = refName 832 + 830 833 ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetTagCommit(refName) 831 834 if err != nil { 832 835 ctx.ServerError("GetTagCommit", err) ··· 870 873 871 874 ctx.Data["BranchName"] = ctx.Repo.BranchName 872 875 ctx.Data["BranchNameSubURL"] = ctx.Repo.BranchNameSubURL() 876 + ctx.Data["TagName"] = ctx.Repo.TagName 873 877 ctx.Data["CommitID"] = ctx.Repo.CommitID 874 878 ctx.Data["TreePath"] = ctx.Repo.TreePath 875 879 ctx.Data["IsViewBranch"] = ctx.Repo.IsViewBranch
+1
options/locale/locale_en-US.ini
··· 971 971 releases = Releases 972 972 tag = Tag 973 973 released_this = released this 974 + file.title = %s at %s 974 975 file_raw = Raw 975 976 file_history = History 976 977 file_view_source = View Source
+5 -7
routers/web/repo/branch.go
··· 344 344 var err error 345 345 346 346 if form.CreateTag { 347 - if ctx.Repo.IsViewTag { 348 - err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName, "") 349 - } else { 350 - err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName, "") 347 + target := ctx.Repo.CommitID 348 + if ctx.Repo.IsViewBranch { 349 + target = ctx.Repo.BranchName 351 350 } 351 + err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, target, form.NewBranchName, "") 352 352 } else if ctx.Repo.IsViewBranch { 353 353 err = repo_service.CreateNewBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName) 354 - } else if ctx.Repo.IsViewTag { 355 - err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName) 356 354 } else { 357 - err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName) 355 + err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName) 358 356 } 359 357 if err != nil { 360 358 if models.IsErrTagAlreadyExists(err) {
+6 -7
routers/web/repo/commit.go
··· 77 77 ctx.Data["Username"] = ctx.Repo.Owner.Name 78 78 ctx.Data["Reponame"] = ctx.Repo.Repository.Name 79 79 ctx.Data["CommitCount"] = commitsCount 80 - ctx.Data["Branch"] = ctx.Repo.BranchName 80 + ctx.Data["RefName"] = ctx.Repo.RefName 81 81 82 82 pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) 83 83 pager.SetDefaultParams(ctx) ··· 153 153 ctx.Data["Username"] = ctx.Repo.Owner.Name 154 154 ctx.Data["Reponame"] = ctx.Repo.Repository.Name 155 155 ctx.Data["CommitCount"] = commitsCount 156 - ctx.Data["Branch"] = ctx.Repo.BranchName 156 + ctx.Data["RefName"] = ctx.Repo.RefName 157 157 paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5) 158 158 paginator.AddParam(ctx, "mode", "Mode") 159 159 paginator.AddParam(ctx, "hide-pr-refs", "HidePRRefs") ··· 199 199 } 200 200 ctx.Data["Username"] = ctx.Repo.Owner.Name 201 201 ctx.Data["Reponame"] = ctx.Repo.Repository.Name 202 - ctx.Data["Branch"] = ctx.Repo.BranchName 202 + ctx.Data["RefName"] = ctx.Repo.RefName 203 203 ctx.HTML(http.StatusOK, tplCommits) 204 204 } 205 205 ··· 213 213 return 214 214 } 215 215 216 - branchName := ctx.Repo.BranchName 217 - commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(branchName, fileName) 216 + commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(ctx.Repo.RefName, fileName) 218 217 if err != nil { 219 218 ctx.ServerError("FileCommitsCount", err) 220 219 return ··· 228 227 page = 1 229 228 } 230 229 231 - commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page) 230 + commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(ctx.Repo.RefName, fileName, page) 232 231 if err != nil { 233 232 ctx.ServerError("CommitsByFileAndRange", err) 234 233 return ··· 239 238 ctx.Data["Reponame"] = ctx.Repo.Repository.Name 240 239 ctx.Data["FileName"] = fileName 241 240 ctx.Data["CommitCount"] = commitsCount 242 - ctx.Data["Branch"] = branchName 241 + ctx.Data["RefName"] = ctx.Repo.RefName 243 242 244 243 pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) 245 244 pager.SetDefaultParams(ctx)
+1 -1
routers/web/repo/view.go
··· 371 371 } 372 372 defer dataRc.Close() 373 373 374 - ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Repo.TreePath + " at " + ctx.Repo.BranchName 374 + ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Tr("repo.file.title", ctx.Repo.TreePath, ctx.Repo.RefName) 375 375 376 376 fileSize := blob.Size() 377 377 ctx.Data["FileIsSymlink"] = entry.IsLink()
+6 -4
templates/repo/branch_dropdown.tmpl
··· 7 7 {{if $release}} 8 8 {{.root.i18n.Tr "repo.release.compare"}} 9 9 {{else}} 10 - {{svg "octicon-git-branch"}} 11 - {{if .root.IsViewBranch}}{{.root.i18n.Tr "repo.branch"}}{{else}}{{.root.i18n.Tr "repo.tree"}}{{end}}: 12 - <strong>{{if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.BranchName}}{{end}}</strong> 10 + {{if .root.IsViewTag}}{{svg "octicon-tag"}}{{else}}{{svg "octicon-git-branch"}}{{end}} 11 + {{if .root.IsViewBranch}}{{.root.i18n.Tr "repo.branch"}}{{else if .root.IsViewTag}}{{.root.i18n.Tr "repo.tag"}}{{else}}{{.root.i18n.Tr "repo.tree"}}{{end}}: 12 + <strong>{{if .root.IsViewBranch}}{{.root.BranchName}}{{else if .root.IsViewTag}}{{.root.TagName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong> 13 13 {{end}} 14 14 </span> 15 15 {{svg "octicon-triangle-down" 14 "dropdown icon"}} ··· 66 66 <div class="text small"> 67 67 {{if or .root.IsViewBranch $release}} 68 68 {{.root.i18n.Tr "repo.branch.create_from" .root.BranchName}} 69 + {{else if .root.IsViewTag}} 70 + {{.root.i18n.Tr "repo.branch.create_from" .root.TagName}} 69 71 {{else}} 70 - {{.root.i18n.Tr "repo.branch.create_from" (ShortSha .root.BranchName)}} 72 + {{.root.i18n.Tr "repo.branch.create_from" (ShortSha .root.CommitID)}} 71 73 {{end}} 72 74 </div> 73 75 </a>
+4 -5
templates/repo/commits_table.tmpl
··· 1 1 <h4 class="ui top attached header commits-table df ac sb"> 2 2 <div class="commits-table-left df ac"> 3 3 {{if or .PageIsCommits (gt .CommitCount 0)}} 4 - {{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}} {{if .Branch}}({{.Branch}}){{end}} 5 - {{else if .IsNothingToCompare }} 6 - {{.i18n.Tr "repo.commits.nothing_to_compare" }} {{if .Branch}}({{.Branch}}){{end}} 7 - 4 + {{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}} {{if .RefName}}({{.RefName}}){{end}} 5 + {{else if .IsNothingToCompare}} 6 + {{.i18n.Tr "repo.commits.nothing_to_compare" }} {{if .RefName}}({{.RefName}}){{end}} 8 7 {{else}} 9 - {{.i18n.Tr "repo.commits.no_commits" $.BaseBranch $.HeadBranch }} {{if .Branch}}({{.Branch}}){{end}} 8 + {{.i18n.Tr "repo.commits.no_commits" $.BaseBranch $.HeadBranch}} {{if .RefName}}({{.RefName}}){{end}} 10 9 {{end}} 11 10 </div> 12 11 <div class="commits-table-right df ac">
+1 -1
templates/repo/sub_menu.tmpl
··· 3 3 <div class="ui two horizontal center link list"> 4 4 {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsEmptyRepo)}} 5 5 <div class="item{{if .PageIsCommits}} active{{end}}"> 6 - <a class="ui" href="{{.RepoLink}}/commits{{if .IsViewBranch}}/branch{{else if .IsViewTag}}/tag{{else if .IsViewCommit}}/commit{{end}}/{{PathEscapeSegments .BranchName}}">{{svg "octicon-history"}} <b>{{.CommitsCount}}</b> {{.i18n.Tr (TrN .i18n.Lang .CommitsCount "repo.commit" "repo.commits") }}</a> 6 + <a class="ui" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}">{{svg "octicon-history"}} <b>{{.CommitsCount}}</b> {{.i18n.Tr (TrN .i18n.Lang .CommitsCount "repo.commit" "repo.commits") }}</a> 7 7 </div> 8 8 <div class="item{{if .PageIsBranches}} active{{end}}"> 9 9 <a class="ui" href="{{.RepoLink}}/branches">{{svg "octicon-git-branch"}} <b>{{.BranchesCount}}</b> {{.i18n.Tr (TrN .i18n.Lang .BranchesCount "repo.branch" "repo.branches") }}</a>