mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Merge pull request #2663 from Download-Fritz/MirrorForks
#2505 Allow to fork and disallow to create PRs for mirrors.
This commit is contained in:
commit
2408df3f35
@ -470,7 +470,7 @@ func runWeb(ctx *cli.Context) {
|
|||||||
m.Post("/delete", repo.DeleteRelease)
|
m.Post("/delete", repo.DeleteRelease)
|
||||||
}, reqRepoAdmin, middleware.RepoRef())
|
}, reqRepoAdmin, middleware.RepoRef())
|
||||||
|
|
||||||
m.Combo("/compare/*", repo.MustEnablePulls).Get(repo.CompareAndPullRequest).
|
m.Combo("/compare/*", repo.MustAllowPulls).Get(repo.CompareAndPullRequest).
|
||||||
Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
|
Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
|
||||||
}, reqSignIn, middleware.RepoAssignment(), repo.MustBeNotBare)
|
}, reqSignIn, middleware.RepoAssignment(), repo.MustBeNotBare)
|
||||||
|
|
||||||
@ -503,7 +503,7 @@ func runWeb(ctx *cli.Context) {
|
|||||||
m.Get("/commits", middleware.RepoRef(), repo.ViewPullCommits)
|
m.Get("/commits", middleware.RepoRef(), repo.ViewPullCommits)
|
||||||
m.Get("/files", middleware.RepoRef(), repo.ViewPullFiles)
|
m.Get("/files", middleware.RepoRef(), repo.ViewPullFiles)
|
||||||
m.Post("/merge", reqRepoAdmin, repo.MergePullRequest)
|
m.Post("/merge", reqRepoAdmin, repo.MergePullRequest)
|
||||||
}, repo.MustEnablePulls)
|
}, repo.MustAllowPulls)
|
||||||
|
|
||||||
m.Group("", func() {
|
m.Group("", func() {
|
||||||
m.Get("/src/*", repo.Home)
|
m.Get("/src/*", repo.Home)
|
||||||
|
@ -332,7 +332,17 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
|
|||||||
|
|
||||||
// CanBeForked returns true if repository meets the requirements of being forked.
|
// CanBeForked returns true if repository meets the requirements of being forked.
|
||||||
func (repo *Repository) CanBeForked() bool {
|
func (repo *Repository) CanBeForked() bool {
|
||||||
return !repo.IsBare && !repo.IsMirror
|
return !repo.IsBare
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanEnablePulls returns true if repository meets the requirements of accepting pulls.
|
||||||
|
func (repo *Repository) CanEnablePulls() bool {
|
||||||
|
return !repo.IsMirror
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllowPulls returns true if repository meets the requirements of accepting pulls and has them enabled.
|
||||||
|
func (repo *Repository) AllowsPulls() bool {
|
||||||
|
return repo.CanEnablePulls() && repo.EnablePulls;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) NextIssueIndex() int64 {
|
func (repo *Repository) NextIssueIndex() int64 {
|
||||||
|
@ -167,7 +167,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
|
|||||||
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner()
|
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner()
|
||||||
ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin()
|
ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin()
|
||||||
ctx.Data["IsRepositoryPusher"] = ctx.Repo.IsPusher()
|
ctx.Data["IsRepositoryPusher"] = ctx.Repo.IsPusher()
|
||||||
ctx.Data["CanPullRequest"] = ctx.Repo.IsAdmin() && repo.BaseRepo != nil && repo.BaseRepo.EnablePulls
|
ctx.Data["CanPullRequest"] = ctx.Repo.IsAdmin() && repo.BaseRepo != nil && repo.BaseRepo.AllowsPulls()
|
||||||
|
|
||||||
ctx.Data["DisableSSH"] = setting.DisableSSH
|
ctx.Data["DisableSSH"] = setting.DisableSSH
|
||||||
ctx.Data["CloneLink"] = repo.CloneLink()
|
ctx.Data["CloneLink"] = repo.CloneLink()
|
||||||
|
@ -47,9 +47,9 @@ func MustEnableIssues(ctx *middleware.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func MustEnablePulls(ctx *middleware.Context) {
|
func MustAllowPulls(ctx *middleware.Context) {
|
||||||
if !ctx.Repo.Repository.EnablePulls {
|
if !ctx.Repo.Repository.AllowsPulls() {
|
||||||
ctx.Handle(404, "MustEnablePulls", nil)
|
ctx.Handle(404, "MustAllowPulls", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["HasForkedRepo"] = ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)
|
ctx.Data["HasForkedRepo"] = ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)
|
||||||
@ -71,7 +71,7 @@ func RetrieveLabels(ctx *middleware.Context) {
|
|||||||
func Issues(ctx *middleware.Context) {
|
func Issues(ctx *middleware.Context) {
|
||||||
isPullList := ctx.Params(":type") == "pulls"
|
isPullList := ctx.Params(":type") == "pulls"
|
||||||
if isPullList {
|
if isPullList {
|
||||||
MustEnablePulls(ctx)
|
MustAllowPulls(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
<i class="icon octicon octicon-issue-opened"></i> {{.i18n.Tr "repo.issues"}} <span class="ui {{if not .Repository.NumOpenIssues}}gray{{else}}blue{{end}} small label">{{.Repository.NumOpenIssues}}</span>
|
<i class="icon octicon octicon-issue-opened"></i> {{.i18n.Tr "repo.issues"}} <span class="ui {{if not .Repository.NumOpenIssues}}gray{{else}}blue{{end}} small label">{{.Repository.NumOpenIssues}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Repository.EnablePulls}}
|
{{if .Repository.AllowsPulls}}
|
||||||
<a class="{{if .PageIsPullList}}active{{end}} item" href="{{.RepoLink}}/pulls">
|
<a class="{{if .PageIsPullList}}active{{end}} item" href="{{.RepoLink}}/pulls">
|
||||||
<i class="icon 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>
|
<i class="icon 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>
|
</a>
|
||||||
|
@ -117,6 +117,7 @@
|
|||||||
<p class="help">{{.i18n.Tr "repo.settings.tracker_url_format_desc" | Str2html}}</p>
|
<p class="help">{{.i18n.Tr "repo.settings.tracker_url_format_desc" | Str2html}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{if .Repository.CanEnablePulls}}
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
@ -126,6 +127,7 @@
|
|||||||
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
|
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
Loading…
Reference in New Issue
Block a user