aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2025-01-16 21:52:21 +0800
committerGitHub <noreply@github.com>2025-01-16 13:52:21 +0000
commitcfc6e21f0680804747b4dee8af50bb12703a223d (patch)
tree9d035c84f75a3e78a800a7555cc04da8718dcf65 /routers/web
parentab347fd0f7f13b661b5728b4f47e76bc10c2204b (diff)
downloadgitea-cfc6e21f0680804747b4dee8af50bb12703a223d.tar.gz
gitea-cfc6e21f0680804747b4dee8af50bb12703a223d.zip
Fix incorrect ref usages (#33301)
Fix #33297 By the way, improve some locales
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/repo/branch.go1
-rw-r--r--routers/web/repo/commit.go13
-rw-r--r--routers/web/web.go12
3 files changed, 8 insertions, 18 deletions
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go
index 5011cbfc77..8747526f72 100644
--- a/routers/web/repo/branch.go
+++ b/routers/web/repo/branch.go
@@ -37,7 +37,6 @@ const (
// Branches render repository branch page
func Branches(ctx *context.Context) {
ctx.Data["Title"] = "Branches"
- ctx.Data["IsRepoToolbarBranches"] = true
ctx.Data["AllowsPulls"] = ctx.Repo.Repository.AllowsPulls(ctx)
ctx.Data["IsWriter"] = ctx.Repo.CanWrite(unit.TypeCode)
ctx.Data["IsMirror"] = ctx.Repo.Repository.IsMirror
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index bad8ca56d1..8ffda8ae0a 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -62,11 +62,7 @@ func Commits(ctx *context.Context) {
}
ctx.Data["PageIsViewCode"] = true
- commitsCount, err := ctx.Repo.GetCommitsCount()
- if err != nil {
- ctx.ServerError("GetCommitsCount", err)
- return
- }
+ commitsCount := ctx.Repo.CommitsCount
page := ctx.FormInt("page")
if page <= 1 {
@@ -129,12 +125,6 @@ func Graph(ctx *context.Context) {
ctx.Data["SelectedBranches"] = realBranches
files := ctx.FormStrings("file")
- commitsCount, err := ctx.Repo.GetCommitsCount()
- if err != nil {
- ctx.ServerError("GetCommitsCount", err)
- return
- }
-
graphCommitsCount, err := ctx.Repo.GetCommitGraphsCount(ctx, hidePRRefs, realBranches, files)
if err != nil {
log.Warn("GetCommitGraphsCount error for generate graph exclude prs: %t branches: %s in %-v, Will Ignore branches and try again. Underlying Error: %v", hidePRRefs, branches, ctx.Repo.Repository, err)
@@ -171,7 +161,6 @@ func Graph(ctx *context.Context) {
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
- ctx.Data["CommitCount"] = commitsCount
paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5)
paginator.AddParamFromRequest(ctx.Req)
diff --git a/routers/web/web.go b/routers/web/web.go
index 7343fbd008..609a7d77ac 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -1332,7 +1332,7 @@ func registerRoutes(m *web.Router) {
m.Group("/{username}/{reponame}", func() { // repo tags
m.Group("/tags", func() {
- m.Get("", repo.TagsList)
+ m.Get("", context.RepoRefByDefaultBranch() /* for the "commits" tab */, repo.TagsList)
m.Get(".rss", feedEnabled, repo.TagsListFeedRSS)
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
m.Get("/list", repo.GetTagList)
@@ -1522,8 +1522,8 @@ func registerRoutes(m *web.Router) {
m.Group("/branches", func() {
m.Get("/list", repo.GetBranchesList)
- m.Get("", repo.Branches)
- }, repo.MustBeNotEmpty, context.RepoRef())
+ m.Get("", context.RepoRefByDefaultBranch() /* for the "commits" tab */, repo.Branches)
+ }, repo.MustBeNotEmpty)
m.Group("/media", func() {
m.Get("/blob/{sha}", repo.DownloadByIDOrLFS)
@@ -1567,8 +1567,10 @@ func registerRoutes(m *web.Router) {
m.Get("/graph", repo.Graph)
m.Get("/commit/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff)
m.Get("/commit/{sha:([a-f0-9]{7,64})$}/load-branches-and-tags", repo.LoadBranchesAndTags)
- m.Get("/cherry-pick/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, repo.CherryPick)
- }, repo.MustBeNotEmpty, context.RepoRef())
+
+ // FIXME: this route `/cherry-pick/{sha}` doesn't seem useful or right, the new code always uses `/_cherrypick/` which could handle branch name correctly
+ m.Get("/cherry-pick/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, context.RepoRefByDefaultBranch(), repo.CherryPick)
+ }, repo.MustBeNotEmpty)
m.Get("/rss/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)