Browse Source

Do not display fork button if target repo already exists (fixes #944)

tags/v1.7.0
James Moger 8 years ago
parent
commit
c332d9a3d4
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      src/main/java/com/gitblit/wicket/pages/RepositoryPage.java

+ 4
- 1
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java View File

import com.gitblit.utils.BugtraqProcessor; import com.gitblit.utils.BugtraqProcessor;
import com.gitblit.utils.DeepCopier; import com.gitblit.utils.DeepCopier;
import com.gitblit.utils.JGitUtils; import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.ModelUtils;
import com.gitblit.utils.RefLogUtils; import com.gitblit.utils.RefLogUtils;
import com.gitblit.utils.StringUtils; import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl; import com.gitblit.wicket.CacheControl;
add(new ExternalLink("myForkLink", "").setVisible(false)); add(new ExternalLink("myForkLink", "").setVisible(false));
} else { } else {
String fork = app().repositories().getFork(user.username, model.name); String fork = app().repositories().getFork(user.username, model.name);
String userRepo = ModelUtils.getPersonalPath(user.username) + "/" + StringUtils.stripDotGit(StringUtils.getLastPathElement(model.name));
boolean hasUserRepo = app().repositories().hasRepository(userRepo);
boolean hasFork = fork != null; boolean hasFork = fork != null;
boolean canFork = user.canFork(model) && model.hasCommits;
boolean canFork = user.canFork(model) && model.hasCommits && !hasUserRepo;
if (hasFork || !canFork) { if (hasFork || !canFork) {
// user not allowed to fork or fork already exists or repo forbids forking // user not allowed to fork or fork already exists or repo forbids forking

Loading…
Cancel
Save