Browse Source

#2505 Allow to fork and disallow to create PRs for mirrors.

pull/2663/head
Download-Fritz 9 years ago
parent
commit
a467184e13
  1. 12
      models/repo.go
  2. 2
      modules/middleware/repo.go
  3. 4
      routers/repo/issue.go
  4. 2
      templates/repo/header.tmpl
  5. 2
      templates/repo/settings/options.tmpl

12
models/repo.go

@ -332,7 +332,17 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
// CanBeForked returns true if repository meets the requirements of being forked.
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 {

2
modules/middleware/repo.go

@ -167,7 +167,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner()
ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin()
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["CloneLink"] = repo.CloneLink()

4
routers/repo/issue.go

@ -48,7 +48,9 @@ func MustEnableIssues(ctx *middleware.Context) {
}
func MustEnablePulls(ctx *middleware.Context) {
if !ctx.Repo.Repository.EnablePulls {
if !ctx.Repo.Repository.CanEnablePulls() {
ctx.Handle(404, "Unsupported", nil)
} else if !ctx.Repo.Repository.EnablePulls {
ctx.Handle(404, "MustEnablePulls", nil)
}

2
templates/repo/header.tmpl

@ -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>
</a>
{{end}}
{{if .Repository.EnablePulls}}
{{if .Repository.AllowsPulls}}
<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>
</a>

2
templates/repo/settings/options.tmpl

@ -117,6 +117,7 @@
<p class="help">{{.i18n.Tr "repo.settings.tracker_url_format_desc" | Str2html}}</p>
</div>
{{if .Repository.CanEnablePulls}}
<div class="ui divider"></div>
<div class="inline field">
@ -126,6 +127,7 @@
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
</div>
</div>
{{end}}
<div class="ui divider"></div>
<div class="field">

Loading…
Cancel
Save