Kaynağa Gözat

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

tags/v0.9.99
Download-Fritz 8 yıl önce
ebeveyn
işleme
a467184e13

+ 11
- 1
models/repo.go Dosyayı Görüntüle



// 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 {

+ 1
- 1
modules/middleware/repo.go Dosyayı Görüntüle

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()

+ 3
- 1
routers/repo/issue.go Dosyayı Görüntüle

} }


func MustEnablePulls(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) ctx.Handle(404, "MustEnablePulls", nil)
} }



+ 1
- 1
templates/repo/header.tmpl Dosyayı Görüntüle

<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>

+ 9
- 7
templates/repo/settings/options.tmpl Dosyayı Görüntüle

<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>


<div class="ui divider"></div>
{{if .Repository.CanEnablePulls}}
<div class="ui divider"></div>


<div class="inline field">
<label>{{.i18n.Tr "repo.pulls"}}</label>
<div class="ui checkbox">
<input name="enable_pulls" type="checkbox" {{if .Repository.EnablePulls}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
<div class="inline field">
<label>{{.i18n.Tr "repo.pulls"}}</label>
<div class="ui checkbox">
<input name="enable_pulls" type="checkbox" {{if .Repository.EnablePulls}}checked{{end}}>
<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…
İptal
Kaydet