mirror of
https://github.com/go-gitea/gitea.git
synced 2025-02-02 15:09:33 -05:00
Fix incorrect ref usages (#33301)
Fix #33297 By the way, improve some locales
This commit is contained in:
parent
ab347fd0f7
commit
cfc6e21f06
@ -1685,16 +1685,16 @@ issues.timetracker_timer_manually_add = Add Time
|
|||||||
|
|
||||||
issues.time_estimate_set = Set estimated time
|
issues.time_estimate_set = Set estimated time
|
||||||
issues.time_estimate_display = Estimate: %s
|
issues.time_estimate_display = Estimate: %s
|
||||||
issues.change_time_estimate_at = changed time estimate to <b>%s</b> %s
|
issues.change_time_estimate_at = changed time estimate to <b>%[1]s</b> %[2]s
|
||||||
issues.remove_time_estimate_at = removed time estimate %s
|
issues.remove_time_estimate_at = removed time estimate %s
|
||||||
issues.time_estimate_invalid = Time estimate format is invalid
|
issues.time_estimate_invalid = Time estimate format is invalid
|
||||||
issues.start_tracking_history = started working %s
|
issues.start_tracking_history = started working %s
|
||||||
issues.tracker_auto_close = Timer will be stopped automatically when this issue gets closed
|
issues.tracker_auto_close = Timer will be stopped automatically when this issue gets closed
|
||||||
issues.tracking_already_started = `You have already started time tracking on <a href="%s">another issue</a>!`
|
issues.tracking_already_started = `You have already started time tracking on <a href="%s">another issue</a>!`
|
||||||
issues.stop_tracking_history = worked for <b>%s</b> %s
|
issues.stop_tracking_history = worked for <b>%[1]s</b> %[2]s
|
||||||
issues.cancel_tracking_history = `canceled time tracking %s`
|
issues.cancel_tracking_history = `canceled time tracking %s`
|
||||||
issues.del_time = Delete this time log
|
issues.del_time = Delete this time log
|
||||||
issues.add_time_history = added spent time <b>%s</b> %s
|
issues.add_time_history = added spent time <b>%[1]s</b> %[2]s
|
||||||
issues.del_time_history= `deleted spent time %s`
|
issues.del_time_history= `deleted spent time %s`
|
||||||
issues.add_time_manually = Manually Add Time
|
issues.add_time_manually = Manually Add Time
|
||||||
issues.add_time_hours = Hours
|
issues.add_time_hours = Hours
|
||||||
|
@ -37,7 +37,6 @@ const (
|
|||||||
// Branches render repository branch page
|
// Branches render repository branch page
|
||||||
func Branches(ctx *context.Context) {
|
func Branches(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = "Branches"
|
ctx.Data["Title"] = "Branches"
|
||||||
ctx.Data["IsRepoToolbarBranches"] = true
|
|
||||||
ctx.Data["AllowsPulls"] = ctx.Repo.Repository.AllowsPulls(ctx)
|
ctx.Data["AllowsPulls"] = ctx.Repo.Repository.AllowsPulls(ctx)
|
||||||
ctx.Data["IsWriter"] = ctx.Repo.CanWrite(unit.TypeCode)
|
ctx.Data["IsWriter"] = ctx.Repo.CanWrite(unit.TypeCode)
|
||||||
ctx.Data["IsMirror"] = ctx.Repo.Repository.IsMirror
|
ctx.Data["IsMirror"] = ctx.Repo.Repository.IsMirror
|
||||||
|
@ -62,11 +62,7 @@ func Commits(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
ctx.Data["PageIsViewCode"] = true
|
ctx.Data["PageIsViewCode"] = true
|
||||||
|
|
||||||
commitsCount, err := ctx.Repo.GetCommitsCount()
|
commitsCount := ctx.Repo.CommitsCount
|
||||||
if err != nil {
|
|
||||||
ctx.ServerError("GetCommitsCount", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
page := ctx.FormInt("page")
|
page := ctx.FormInt("page")
|
||||||
if page <= 1 {
|
if page <= 1 {
|
||||||
@ -129,12 +125,6 @@ func Graph(ctx *context.Context) {
|
|||||||
ctx.Data["SelectedBranches"] = realBranches
|
ctx.Data["SelectedBranches"] = realBranches
|
||||||
files := ctx.FormStrings("file")
|
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)
|
graphCommitsCount, err := ctx.Repo.GetCommitGraphsCount(ctx, hidePRRefs, realBranches, files)
|
||||||
if err != nil {
|
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)
|
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["Username"] = ctx.Repo.Owner.Name
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
ctx.Data["CommitCount"] = commitsCount
|
|
||||||
|
|
||||||
paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5)
|
paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5)
|
||||||
paginator.AddParamFromRequest(ctx.Req)
|
paginator.AddParamFromRequest(ctx.Req)
|
||||||
|
@ -1332,7 +1332,7 @@ func registerRoutes(m *web.Router) {
|
|||||||
|
|
||||||
m.Group("/{username}/{reponame}", func() { // repo tags
|
m.Group("/{username}/{reponame}", func() { // repo tags
|
||||||
m.Group("/tags", func() {
|
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(".rss", feedEnabled, repo.TagsListFeedRSS)
|
||||||
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
|
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
|
||||||
m.Get("/list", repo.GetTagList)
|
m.Get("/list", repo.GetTagList)
|
||||||
@ -1522,8 +1522,8 @@ func registerRoutes(m *web.Router) {
|
|||||||
|
|
||||||
m.Group("/branches", func() {
|
m.Group("/branches", func() {
|
||||||
m.Get("/list", repo.GetBranchesList)
|
m.Get("/list", repo.GetBranchesList)
|
||||||
m.Get("", repo.Branches)
|
m.Get("", context.RepoRefByDefaultBranch() /* for the "commits" tab */, repo.Branches)
|
||||||
}, repo.MustBeNotEmpty, context.RepoRef())
|
}, repo.MustBeNotEmpty)
|
||||||
|
|
||||||
m.Group("/media", func() {
|
m.Group("/media", func() {
|
||||||
m.Get("/blob/{sha}", repo.DownloadByIDOrLFS)
|
m.Get("/blob/{sha}", repo.DownloadByIDOrLFS)
|
||||||
@ -1567,8 +1567,10 @@ func registerRoutes(m *web.Router) {
|
|||||||
m.Get("/graph", repo.Graph)
|
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})$}", 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("/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("/rss/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
|
||||||
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
|
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
|
||||||
|
@ -777,6 +777,18 @@ func repoRefFullName(typ git.RefType, shortName string) git.RefName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RepoRefByDefaultBranch() func(*Context) {
|
||||||
|
return func(ctx *Context) {
|
||||||
|
ctx.Repo.RefFullName = git.RefNameFromBranch(ctx.Repo.Repository.DefaultBranch)
|
||||||
|
ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch
|
||||||
|
ctx.Repo.Commit, _ = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.BranchName)
|
||||||
|
ctx.Repo.CommitsCount, _ = ctx.Repo.GetCommitsCount()
|
||||||
|
ctx.Data["RefFullName"] = ctx.Repo.RefFullName
|
||||||
|
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
||||||
|
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RepoRefByType handles repository reference name for a specific type
|
// RepoRefByType handles repository reference name for a specific type
|
||||||
// of repository reference
|
// of repository reference
|
||||||
func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="ui segments repository-summary tw-mt-1 tw-mb-0">
|
<div class="ui segments repository-summary tw-mt-1 tw-mb-0">
|
||||||
<div class="ui segment sub-menu repository-menu">
|
<div class="ui segment sub-menu repository-menu">
|
||||||
{{if and (.Permission.CanRead ctx.Consts.RepoUnitTypeCode) (not .IsEmptyRepo)}}
|
{{if and (.Permission.CanRead ctx.Consts.RepoUnitTypeCode) (not .IsEmptyRepo)}}
|
||||||
<a class="item muted {{if .PageIsCommits}}active{{end}}" href="{{.RepoLink}}/commits/{{.RefTypeNameSubURL}}">
|
<a class="item muted {{if .PageIsCommits}}active{{end}}" href="{{.RepoLink}}/commits/{{.RefFullName.RefWebLinkPath}}">
|
||||||
{{svg "octicon-history"}} <b>{{ctx.Locale.PrettyNumber .CommitsCount}}</b> {{ctx.Locale.TrN .CommitsCount "repo.commit" "repo.commits"}}
|
{{svg "octicon-history"}} <b>{{ctx.Locale.PrettyNumber .CommitsCount}}</b> {{ctx.Locale.TrN .CommitsCount "repo.commit" "repo.commits"}}
|
||||||
</a>
|
</a>
|
||||||
<a class="item muted {{if .PageIsBranches}}active{{end}}" href="{{.RepoLink}}/branches">
|
<a class="item muted {{if .PageIsBranches}}active{{end}}" href="{{.RepoLink}}/branches">
|
||||||
|
Loading…
Reference in New Issue
Block a user