diff --git a/.bra.toml b/.bra.toml index fe9472159..cc1df16f0 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 9fb5607db..d0fa7c8fc 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 19f9f5b8e..c1eec7cc2 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 d95d9526e..2f883cd70 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -29,7 +29,7 @@ {{.NumStars}} - {{if not .IsBare}} + {{if .CanBeForked}}