Skip to content

Commit c332d9a

Browse files
committed
Do not display fork button if target repo already exists (fixes #944)
1 parent 168f039 commit c332d9a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/gitblit/wicket/pages/RepositoryPage.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import com.gitblit.utils.BugtraqProcessor;
6565
import com.gitblit.utils.DeepCopier;
6666
import com.gitblit.utils.JGitUtils;
67+
import com.gitblit.utils.ModelUtils;
6768
import com.gitblit.utils.RefLogUtils;
6869
import com.gitblit.utils.StringUtils;
6970
import com.gitblit.wicket.CacheControl;
@@ -370,8 +371,10 @@ protected void setupPage(String repositoryName, String pageName) {
370371
add(new ExternalLink("myForkLink", "").setVisible(false));
371372
} else {
372373
String fork = app().repositories().getFork(user.username, model.name);
374+
String userRepo = ModelUtils.getPersonalPath(user.username) + "/" + StringUtils.stripDotGit(StringUtils.getLastPathElement(model.name));
375+
boolean hasUserRepo = app().repositories().hasRepository(userRepo);
373376
boolean hasFork = fork != null;
374-
boolean canFork = user.canFork(model) && model.hasCommits;
377+
boolean canFork = user.canFork(model) && model.hasCommits && !hasUserRepo;
375378

376379
if (hasFork || !canFork) {
377380
// user not allowed to fork or fork already exists or repo forbids forking

0 commit comments

Comments
 (0)