1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-26 09:09:36 -05:00

Mirror repository should not allow fork

This commit is contained in:
Unknwon 2015-09-05 14:31:52 -04:00
parent 46dce2d653
commit 119dec51f2
5 changed files with 9 additions and 6 deletions

View file

@ -13,7 +13,6 @@ watch_dirs = [
watch_exts = [".go"] watch_exts = [".go"]
build_delay = 1500 build_delay = 1500
cmds = [ cmds = [
#["go-bindata", "-o=modules/bindata/bindata.go", "-ignore=\\.DS_Store|README", "-pkg=bindata", "conf/..."],
["go", "install", "-tags", "sqlite"],# redis memcache cert pam ["go", "install", "-tags", "sqlite"],# redis memcache cert pam
["go", "build", "-tags", "sqlite"], ["go", "build", "-tags", "sqlite"],
["./gogs", "web"] ["./gogs", "web"]

View file

@ -272,6 +272,11 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
return repo.OwnerID == userID 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 { func (repo *Repository) NextIssueIndex() int64 {
return int64(repo.NumIssues+repo.NumPulls) + 1 return int64(repo.NumIssues+repo.NumPulls) + 1
} }

View file

@ -38,9 +38,8 @@ func getForkRepository(ctx *middleware.Context) *models.Repository {
return nil return nil
} }
// Cannot fork bare repo. if !forkRepo.CanBeForked() {
if forkRepo.IsBare { ctx.Handle(404, "getForkRepository", nil)
ctx.Handle(404, "", nil)
return nil return nil
} }

View file

@ -29,7 +29,7 @@
{{.NumStars}} {{.NumStars}}
</a> </a>
</div> </div>
{{if not .IsBare}} {{if .CanBeForked}}
<div class="ui labeled button" tabindex="0"> <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}}> <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"}} <i class="icon octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}

View file

@ -48,7 +48,7 @@
</button> </button>
</a> </a>
</li> </li>
{{if not .IsBare}} {{if .CanBeForked}}
<li id="repo-header-fork"> <li id="repo-header-fork">
<a id="repo-header-fork-btn" {{if or (not $.IsRepositoryAdmin) $.Owner.IsOrganization}}href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{end}}> <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"> <button class="btn btn-gray text-bold btn-radius">