mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:49:52 +01:00
feat(performance): remove BranchName
in /:owner/:repo/commit/:commit
`BranchName` provides the nearest branch of the requested `:commit`. It's plenty fast on smaller repositories. On larger repositories like nixpkgs, however, this can easily take 2-3 seconds on a modern machine on a NVMe. For context, at the time of writing, nixpkgs has over 650k commits and roughly 250 branches. `BranchName` is used once in the whole view: The cherry-pick target branch default selection. And I believe that's a logic error, which is why this patch is so small. The nearest branch of a given commit will always be a branch the commit is already part of. The branch you most likely *don't* want to cherry-pick to. Sure, one can technically cherry-pick a commit onto the same branch, but that simply results in an empty commit. I don't believe this is intended and even less so worth the compute. Instead, the cherry-pick branch selection suggestion now always uses the default branch, which used to be the fallback. If a user wants to know which branches contain the given commit, `load-branches-and-tags` exists and should be used instead. Also, to add insult to injury, `BranchName` was calculated for both logged-in and not logged-in users, despite its only consumer, the cherry-pick operation, only being rendered when a given user has write/commit permissions. But this isn't particularly surprising, given this happens a lot in Forgejo's codebase.
This commit is contained in:
parent
5ae2dbcb14
commit
c1f85ce27b
2 changed files with 2 additions and 8 deletions
|
@ -416,12 +416,6 @@ func Diff(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.Data["BranchName"], err = commit.GetBranchName()
|
||||
if err != nil {
|
||||
ctx.ServerError("commit.GetBranchName", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(http.StatusOK, tplCommitPage)
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@
|
|||
"branchForm" "branch-dropdown-form"
|
||||
"branchURLPrefix" (printf "%s/_cherrypick/%s/" $.RepoLink .CommitID) "branchURLSuffix" ""
|
||||
"setAction" true "submitForm" true}}
|
||||
<form method="get" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{if $.BranchName}}{{PathEscapeSegments $.BranchName}}{{else}}{{PathEscapeSegments $.Repository.DefaultBranch}}{{end}}" id="branch-dropdown-form">
|
||||
<input type="hidden" name="ref" value="{{if $.BranchName}}{{$.BranchName}}{{else}}{{$.Repository.DefaultBranch}}{{end}}">
|
||||
<form method="get" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{PathEscapeSegments $.Repository.DefaultBranch}}" id="branch-dropdown-form">
|
||||
<input type="hidden" name="ref" value="{{$.Repository.DefaultBranch}}">
|
||||
<input type="hidden" name="refType" value="branch">
|
||||
<input type="hidden" id="cherry-pick-type" name="cherry-pick-type"><br>
|
||||
<button type="submit" id="cherry-pick-submit" class="ui primary button"></button>
|
||||
|
|
Loading…
Reference in a new issue