diff options
-rw-r--r-- | .bra.toml | 1 | ||||
-rw-r--r-- | models/repo.go | 5 | ||||
-rw-r--r-- | routers/repo/pull.go | 5 | ||||
-rw-r--r-- | templates/repo/header.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/header_old.tmpl | 2 |
5 files changed, 9 insertions, 6 deletions
@@ -13,7 +13,6 @@ watch_dirs = [ watch_exts = [".go"] build_delay = 1500 cmds = [ - #["go-bindata", "-o=modules/bindata/bindata.go", "-ignore=\\.DS_Store|README", "-pkg=bindata", "conf/..."], ["go", "install", "-tags", "sqlite"],# redis memcache cert pam ["go", "build", "-tags", "sqlite"], ["./gogs", "web"] diff --git a/models/repo.go b/models/repo.go index 9fb5607db7..d0fa7c8fc6 100644 --- a/models/repo.go +++ b/models/repo.go @@ -272,6 +272,11 @@ func (repo *Repository) IsOwnedBy(userID int64) bool { return repo.OwnerID == userID } +// CanBeForked returns true if repository meets the requirements of being forked. +func (repo *Repository) CanBeForked() bool { + return !repo.IsBare && !repo.IsMirror +} + func (repo *Repository) NextIssueIndex() int64 { return int64(repo.NumIssues+repo.NumPulls) + 1 } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 19f9f5b8e2..c1eec7cc2f 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -38,9 +38,8 @@ func getForkRepository(ctx *middleware.Context) *models.Repository { return nil } - // Cannot fork bare repo. - if forkRepo.IsBare { - ctx.Handle(404, "", nil) + if !forkRepo.CanBeForked() { + ctx.Handle(404, "getForkRepository", nil) return nil } diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index d95d9526e7..2f883cd704 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -29,7 +29,7 @@ {{.NumStars}} </a> </div> - {{if not .IsBare}} + {{if .CanBeForked}} <div class="ui labeled button" tabindex="0"> <a class="ui grey button {{if eq .OwnerID $.SignedUserID}}poping up{{end}}" {{if not (eq .OwnerID $.SignedUserID)}}href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{else}} data-content="{{$.i18n.Tr "repo.fork_from_self"}}" data-position="top center" data-variation="tiny"{{end}}> <i class="icon octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}} diff --git a/templates/repo/header_old.tmpl b/templates/repo/header_old.tmpl index 0537cc0244..23a3e0888d 100644 --- a/templates/repo/header_old.tmpl +++ b/templates/repo/header_old.tmpl @@ -48,7 +48,7 @@ </button> </a> </li> - {{if not .IsBare}} + {{if .CanBeForked}} <li id="repo-header-fork"> <a id="repo-header-fork-btn" {{if or (not $.IsRepositoryAdmin) $.Owner.IsOrganization}}href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{end}}> <button class="btn btn-gray text-bold btn-radius"> |