mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 12:44:49 -05:00
feat: Only use issue and wiki on repo. (#1297)
This commit is contained in:
parent
5ecb369dac
commit
1c3bd436cc
7 changed files with 32 additions and 40 deletions
24
cmd/web.go
24
cmd/web.go
|
@ -448,7 +448,7 @@ func runWeb(ctx *cli.Context) error {
|
|||
m.Combo("").Get(repo.ProtectedBranch).Post(repo.ProtectedBranchPost)
|
||||
m.Post("/can_push", repo.ChangeProtectedBranch)
|
||||
m.Post("/delete", repo.DeleteProtectedBranch)
|
||||
})
|
||||
}, repo.MustBeNotBare)
|
||||
|
||||
m.Group("/hooks", func() {
|
||||
m.Get("", repo.Webhooks)
|
||||
|
@ -520,11 +520,11 @@ func runWeb(ctx *cli.Context) error {
|
|||
m.Get("/new", repo.NewRelease)
|
||||
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
|
||||
m.Post("/delete", repo.DeleteRelease)
|
||||
}, reqRepoWriter, context.RepoRef())
|
||||
}, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
|
||||
m.Group("/releases", func() {
|
||||
m.Get("/edit/*", repo.EditRelease)
|
||||
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
|
||||
}, reqRepoWriter, func(ctx *context.Context) {
|
||||
}, repo.MustBeNotBare, reqRepoWriter, func(ctx *context.Context) {
|
||||
var err error
|
||||
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
|
||||
if err != nil {
|
||||
|
@ -563,17 +563,17 @@ func runWeb(ctx *cli.Context) error {
|
|||
return
|
||||
}
|
||||
})
|
||||
}, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) {
|
||||
}, repo.MustBeNotBare, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) {
|
||||
if !ctx.Repo.Repository.CanEnableEditor() || ctx.Repo.IsViewCommit {
|
||||
ctx.Handle(404, "", nil)
|
||||
return
|
||||
}
|
||||
})
|
||||
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare, context.UnitTypes())
|
||||
}, reqSignIn, context.RepoAssignment(), context.UnitTypes())
|
||||
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Group("", func() {
|
||||
m.Get("/releases", repo.Releases)
|
||||
m.Get("/releases", repo.MustBeNotBare, repo.Releases)
|
||||
m.Get("/^:type(issues|pulls)$", repo.RetrieveLabels, repo.Issues)
|
||||
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
|
||||
m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
|
||||
|
@ -581,7 +581,7 @@ func runWeb(ctx *cli.Context) error {
|
|||
}, context.RepoRef())
|
||||
|
||||
// m.Get("/branches", repo.Branches)
|
||||
m.Post("/branches/:name/delete", reqSignIn, reqRepoWriter, repo.DeleteBranchPost)
|
||||
m.Post("/branches/:name/delete", reqSignIn, reqRepoWriter, repo.MustBeNotBare, repo.DeleteBranchPost)
|
||||
|
||||
m.Group("/wiki", func() {
|
||||
m.Get("/?:page", repo.Wiki)
|
||||
|
@ -601,7 +601,7 @@ func runWeb(ctx *cli.Context) error {
|
|||
m.Get("/*", repo.WikiRaw)
|
||||
}, repo.MustEnableWiki)
|
||||
|
||||
m.Get("/archive/*", repo.Download)
|
||||
m.Get("/archive/*", repo.MustBeNotBare, repo.Download)
|
||||
|
||||
m.Group("/pulls/:index", func() {
|
||||
m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
|
||||
|
@ -617,10 +617,10 @@ func runWeb(ctx *cli.Context) error {
|
|||
m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.Diff)
|
||||
m.Get("/forks", repo.Forks)
|
||||
}, context.RepoRef())
|
||||
m.Get("/commit/:sha([a-f0-9]{7,40})\\.:ext(patch|diff)", repo.RawDiff)
|
||||
m.Get("/commit/:sha([a-f0-9]{7,40})\\.:ext(patch|diff)", repo.MustBeNotBare, repo.RawDiff)
|
||||
|
||||
m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.CompareDiff)
|
||||
}, ignSignIn, context.RepoAssignment(), repo.MustBeNotBare, context.UnitTypes())
|
||||
m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.MustBeNotBare, repo.CompareDiff)
|
||||
}, ignSignIn, context.RepoAssignment(), context.UnitTypes())
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Get("/stars", repo.Stars)
|
||||
m.Get("/watchers", repo.Watchers)
|
||||
|
@ -630,7 +630,7 @@ func runWeb(ctx *cli.Context) error {
|
|||
m.Group("/:reponame", func() {
|
||||
m.Get("", repo.SetEditorconfigIfExists, repo.Home)
|
||||
m.Get("\\.git$", repo.SetEditorconfigIfExists, repo.Home)
|
||||
}, ignSignIn, context.RepoAssignment(true), context.RepoRef(), context.UnitTypes())
|
||||
}, ignSignIn, context.RepoAssignment(), context.RepoRef(), context.UnitTypes())
|
||||
|
||||
m.Group("/:reponame", func() {
|
||||
m.Group("/info/lfs", func() {
|
||||
|
|
|
@ -553,7 +553,7 @@ func (repo *Repository) CanBeForked() bool {
|
|||
|
||||
// CanEnablePulls returns true if repository meets the requirements of accepting pulls.
|
||||
func (repo *Repository) CanEnablePulls() bool {
|
||||
return !repo.IsMirror
|
||||
return !repo.IsMirror && !repo.IsBare
|
||||
}
|
||||
|
||||
// AllowsPulls returns true if repository meets the requirements of accepting pulls and has them enabled.
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
"code.gitea.io/git"
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"github.com/Unknwon/com"
|
||||
editorconfig "gopkg.in/editorconfig/editorconfig-core-go.v1"
|
||||
|
@ -154,15 +153,8 @@ func RedirectToRepo(ctx *Context, redirectRepoID int64) {
|
|||
}
|
||||
|
||||
// RepoAssignment returns a macaron to handle repository assignment
|
||||
func RepoAssignment(args ...bool) macaron.Handler {
|
||||
func RepoAssignment() macaron.Handler {
|
||||
return func(ctx *Context) {
|
||||
var (
|
||||
displayBare bool // To display bare page if it is a bare repo.
|
||||
)
|
||||
if len(args) >= 1 {
|
||||
displayBare = args[0]
|
||||
}
|
||||
|
||||
var (
|
||||
owner *models.User
|
||||
err error
|
||||
|
@ -294,15 +286,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
|
|||
|
||||
// repo is bare and display enable
|
||||
if ctx.Repo.Repository.IsBare {
|
||||
log.Debug("Bare repository: %s", ctx.Repo.RepoLink)
|
||||
// NOTE: to prevent templating error
|
||||
ctx.Data["BranchName"] = ""
|
||||
if displayBare {
|
||||
if !ctx.Repo.IsAdmin() {
|
||||
ctx.Flash.Info(ctx.Tr("repo.repo_is_empty"), true)
|
||||
}
|
||||
ctx.HTML(200, "repo/bare")
|
||||
}
|
||||
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ quick_guide = Quick Guide
|
|||
clone_this_repo = Clone this repository
|
||||
create_new_repo_command = Create a new repository on the command line
|
||||
push_exist_repo = Push an existing repository from the command line
|
||||
repo_is_empty = This repository is empty, please come back later!
|
||||
bare_message = This repository does not have any content yet.
|
||||
|
||||
code = Code
|
||||
branch = Branch
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
tplRepoBARE base.TplName = "repo/bare"
|
||||
tplRepoHome base.TplName = "repo/home"
|
||||
tplWatchers base.TplName = "repo/watchers"
|
||||
tplForks base.TplName = "repo/forks"
|
||||
|
@ -243,12 +244,18 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
|||
|
||||
// Home render repository home page
|
||||
func Home(ctx *context.Context) {
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
|
||||
if ctx.Repo.Repository.IsBare {
|
||||
ctx.HTML(200, tplRepoBARE)
|
||||
return
|
||||
}
|
||||
|
||||
title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name
|
||||
if len(ctx.Repo.Repository.Description) > 0 {
|
||||
title += ": " + ctx.Repo.Repository.Description
|
||||
}
|
||||
ctx.Data["Title"] = title
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
|
||||
branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchName
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
{{if .IsRepositoryAdmin}}
|
||||
<h4 class="ui top attached header">
|
||||
{{.i18n.Tr "repo.quick_guide"}}
|
||||
<div class="ui right">
|
||||
<a class="ui black tiny button" href="{{.RepoLink}}/settings">{{.i18n.Tr "repo.settings"}}</a>
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui attached guide table segment">
|
||||
<div class="item">
|
||||
|
@ -58,6 +55,10 @@ git push -u origin master</code></pre>
|
|||
git push -u origin master</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="ui segment center">
|
||||
{{.i18n.Tr "repo.bare_message"}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</div><!-- end grid -->
|
||||
</div><!-- end container -->
|
||||
{{end}}
|
||||
{{if not (or .IsBareRepo .IsDiffCompare)}}
|
||||
{{if not .IsDiffCompare}}
|
||||
<div class="ui tabs container">
|
||||
<div class="ui tabular stackable menu navbar">
|
||||
{{if .Repository.EnableUnit $.UnitTypeCode}}
|
||||
|
@ -66,20 +66,20 @@
|
|||
<i class="octicon octicon-issue-opened"></i> {{.i18n.Tr "repo.issues"}} </span>
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
|
||||
{{if .Repository.AllowsPulls}}
|
||||
<a class="{{if .PageIsPullList}}active{{end}} item" href="{{.RepoLink}}/pulls">
|
||||
<i class="octicon octicon-git-pull-request"></i> {{.i18n.Tr "repo.pulls"}} <span class="ui {{if not .Repository.NumOpenPulls}}gray{{else}}blue{{end}} small label">{{.Repository.NumOpenPulls}}</span>
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
{{if .Repository.EnableUnit $.UnitTypeCommits}}
|
||||
{{if and (.Repository.EnableUnit $.UnitTypeCommits) (not .IsBareRepo)}}
|
||||
<a class="{{if (or (.PageIsCommits) (.PageIsDiff))}}active{{end}} item" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}">
|
||||
<i class="octicon octicon-history"></i> {{.i18n.Tr "repo.commits"}} <span class="ui {{if not .CommitsCount}}gray{{else}}blue{{end}} small label">{{.CommitsCount}}</span>
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
{{if .Repository.EnableUnit $.UnitTypeReleases}}
|
||||
{{if and (.Repository.EnableUnit $.UnitTypeReleases) (not .IsBareRepo) }}
|
||||
<a class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
|
||||
<i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumTags}}gray{{else}}blue{{end}} small label">{{.Repository.NumTags}}</span>
|
||||
</a>
|
||||
|
|
Loading…
Reference in a new issue