]> source.dussan.org Git - gitblit.git/commitdiff
Do not display fork button if target repo already exists (fixes #944)
authorJames Moger <james.moger@gitblit.com>
Tue, 10 Nov 2015 13:58:35 +0000 (08:58 -0500)
committerJames Moger <james.moger@gitblit.com>
Tue, 10 Nov 2015 13:58:35 +0000 (08:58 -0500)
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java

index 9639a0c11bbd2bb77033639f74775787a06403cf..7e164a8cd8a21c5e6a9bdf31e0f21127bebcbae7 100644 (file)
@@ -64,6 +64,7 @@ import com.gitblit.utils.ArrayUtils;
 import com.gitblit.utils.BugtraqProcessor;\r
 import com.gitblit.utils.DeepCopier;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.ModelUtils;\r
 import com.gitblit.utils.RefLogUtils;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.CacheControl;\r
@@ -370,8 +371,10 @@ public abstract class RepositoryPage extends RootPage {
                        add(new ExternalLink("myForkLink", "").setVisible(false));\r
                } else {\r
                        String fork = app().repositories().getFork(user.username, model.name);\r
+                       String userRepo = ModelUtils.getPersonalPath(user.username) + "/" + StringUtils.stripDotGit(StringUtils.getLastPathElement(model.name));\r
+                       boolean hasUserRepo = app().repositories().hasRepository(userRepo);\r
                        boolean hasFork = fork != null;\r
-                       boolean canFork = user.canFork(model) && model.hasCommits;\r
+                       boolean canFork = user.canFork(model) && model.hasCommits && !hasUserRepo;\r
 \r
                        if (hasFork || !canFork) {\r
                                // user not allowed to fork or fork already exists or repo forbids forking\r