]> source.dussan.org Git - gitea.git/commitdiff
Mirror repository should not allow fork
authorUnknwon <u@gogs.io>
Sat, 5 Sep 2015 18:31:52 +0000 (14:31 -0400)
committerUnknwon <u@gogs.io>
Sat, 5 Sep 2015 18:31:52 +0000 (14:31 -0400)
.bra.toml
models/repo.go
routers/repo/pull.go
templates/repo/header.tmpl
templates/repo/header_old.tmpl

index fe9472159cb18d27a3d419ae0ca05177fd184ecf..cc1df16f0e38b12e11a80e59f7d7156eab748830 100644 (file)
--- 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"]
index 9fb5607db71cee3b5baabfd94759ce2cc987f07d..d0fa7c8fc660ae7204d6636b5176e4f2ddfe9614 100644 (file)
@@ -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
 }
index 19f9f5b8e2a856df6a3df2fb30f88288ca5c4f3f..c1eec7cc2f53905a323c44d2a2a97dddb75ab485 100644 (file)
@@ -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
        }
 
index d95d9526e7e4317e5a5d35abbf320c8ed203ef7a..2f883cd7041056e9650fe14db9ed9d6a612d3db0 100644 (file)
@@ -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"}}
index 0537cc02449e6d641777749a23445c921aac994d..23a3e0888d88975b393a2437a368a1af6267007a 100644 (file)
@@ -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">