diff --git a/.bra.toml b/.bra.toml index fe9472159c..cc1df16f0e 100644 --- a/.bra.toml +++ b/.bra.toml @@ -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}} - {{if not .IsBare}} + {{if .CanBeForked}}