From 428b2244aadeb4724e705044d73ac74be724f6e9 Mon Sep 17 00:00:00 2001 From: mschaefers Date: Tue, 4 Dec 2012 16:07:37 -0500 Subject: [PATCH] Merged and enhanced pull request #55 (disallow forks setting) --- distrib/gitblit.properties | 8 +++++++- src/com/gitblit/wicket/pages/EditRepositoryPage.java | 2 +- src/com/gitblit/wicket/pages/EditTeamPage.java | 3 ++- src/com/gitblit/wicket/pages/EditUserPage.java | 2 +- src/com/gitblit/wicket/pages/RepositoryPage.java | 8 +++++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties index 233fdfad..d57f9ba1 100644 --- a/distrib/gitblit.properties +++ b/distrib/gitblit.properties @@ -504,6 +504,12 @@ web.compressedDownloads = zip gz # SINCE 0.9.0 web.allowLuceneIndexing = true +# Allows an authenticated user to create forks of a repository +# +# set this to false if you want to disable all fork controls on the web site +# +web.allowForking = true + # Controls the length of shortened commit hash ids # # SINCE 1.2.0 @@ -1179,4 +1185,4 @@ server.requireClientCertificates = false # # SINCE 0.5.0 # RESTART REQUIRED -server.shutdownPort = 8081 \ No newline at end of file +server.shutdownPort = 8081 diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index dead34a9..9de8244a 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -379,7 +379,7 @@ public class EditRepositoryPage extends RootSubPage { form.add(new TextField("description")); form.add(new DropDownChoice("owner", GitBlit.self().getAllUsernames()) .setEnabled(GitBlitWebSession.get().canAdmin() && !repositoryModel.isPersonalRepository())); - form.add(new CheckBox("allowForks")); + form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true))); DropDownChoice accessRestriction = new DropDownChoice("accessRestriction", Arrays .asList(AccessRestrictionType.values()), new AccessRestrictionRenderer()); form.add(accessRestriction); diff --git a/src/com/gitblit/wicket/pages/EditTeamPage.java b/src/com/gitblit/wicket/pages/EditTeamPage.java index a22361f1..1991c02a 100644 --- a/src/com/gitblit/wicket/pages/EditTeamPage.java +++ b/src/com/gitblit/wicket/pages/EditTeamPage.java @@ -38,6 +38,7 @@ import org.apache.wicket.model.util.ListModel; import com.gitblit.GitBlit; import com.gitblit.GitBlitException; +import com.gitblit.Keys; import com.gitblit.Constants.RegistrantType; import com.gitblit.models.RegistrantAccessPermission; import com.gitblit.models.TeamModel; @@ -216,7 +217,7 @@ public class EditTeamPage extends RootSubPage { // field names reflective match TeamModel fields form.add(new TextField("name")); form.add(new CheckBox("canAdmin")); - form.add(new CheckBox("canFork")); + form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true))); form.add(new CheckBox("canCreate")); form.add(users.setEnabled(editMemberships)); mailingLists = new Model(teamModel.mailingLists == null ? "" diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java index 80f09dba..d22800ef 100644 --- a/src/com/gitblit/wicket/pages/EditUserPage.java +++ b/src/com/gitblit/wicket/pages/EditUserPage.java @@ -233,7 +233,7 @@ public class EditUserPage extends RootSubPage { form.add(new TextField("displayName").setEnabled(editDisplayName)); form.add(new TextField("emailAddress").setEnabled(editEmailAddress)); form.add(new CheckBox("canAdmin")); - form.add(new CheckBox("canFork")); + form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true))); form.add(new CheckBox("canCreate")); form.add(new CheckBox("excludeFromFederation")); form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions())); diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index 346edc3e..3acf73af 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -154,7 +154,9 @@ public abstract class RepositoryPage extends BasePage { pages.put("branches", new PageRegistration("gb.branches", BranchesPage.class, params)); pages.put("tags", new PageRegistration("gb.tags", TagsPage.class, params)); pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params)); - pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params)); + if (GitBlit.getBoolean(Keys.web.allowForking, true)) { + pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params)); + } // conditional links Repository r = getRepository(); @@ -191,7 +193,7 @@ public abstract class RepositoryPage extends BasePage { } protected boolean allowForkControls() { - return true; + return GitBlit.getBoolean(Keys.web.allowForking, true); } @Override @@ -597,4 +599,4 @@ public abstract class RepositoryPage extends BasePage { getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl)); } } -} +} -- 2.39.5