From: James Moger Date: Sat, 17 Mar 2012 16:09:01 +0000 (-0400) Subject: Implemented RPC administration of indexed branches X-Git-Tag: v0.9.0~49 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e9de3f7fd55dd4d4535cd7b2fc2bee8094152e39;p=gitblit.git Implemented RPC administration of indexed branches --- diff --git a/docs/02_rpc.mkd b/docs/02_rpc.mkd index 84446f5b..98a73e59 100644 --- a/docs/02_rpc.mkd +++ b/docs/02_rpc.mkd @@ -63,6 +63,7 @@ The Gitblit API includes methods for retrieving and interpreting RSS feeds. The ReleaseProtocol Version Gitblit v0.7.01 (inferred version) Gitblit v0.8.02 +Gitblit v0.9.03 diff --git a/src/com/gitblit/RpcServlet.java b/src/com/gitblit/RpcServlet.java index 2d513887..31ee5ad0 100644 --- a/src/com/gitblit/RpcServlet.java +++ b/src/com/gitblit/RpcServlet.java @@ -49,7 +49,7 @@ public class RpcServlet extends JsonServlet { private static final long serialVersionUID = 1L; - public static final int PROTOCOL_VERSION = 2; + public static final int PROTOCOL_VERSION = 3; public RpcServlet() { super(); diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java index 4d3485df..5c746cc1 100644 --- a/src/com/gitblit/client/EditRepositoryDialog.java +++ b/src/com/gitblit/client/EditRepositoryDialog.java @@ -105,6 +105,8 @@ public class EditRepositoryDialog extends JDialog { private JPalette setsPalette; private JPalette teamsPalette; + + private JPalette indexedBranchesPalette; private JPalette preReceivePalette; @@ -258,6 +260,12 @@ public class EditRepositoryDialog extends JDialog { .add(newFieldPanel(Translation.get("gb.federationSets"), setsPalette), BorderLayout.CENTER); + indexedBranchesPalette = new JPalette(); + JPanel indexedBranchesPanel = new JPanel(new BorderLayout(5, 5)); + indexedBranchesPanel + .add(newFieldPanel(Translation.get("gb.indexedBranches"), + indexedBranchesPalette), BorderLayout.CENTER); + preReceivePalette = new JPalette(true); preReceiveInherited = new JLabel(); JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5)); @@ -277,6 +285,9 @@ public class EditRepositoryDialog extends JDialog { panel.addTab(Translation.get("gb.teams"), teamsPanel); } panel.addTab(Translation.get("gb.federation"), federationPanel); + if (protocolVersion >= 3) { + panel.addTab(Translation.get("gb.indexedBranches"), indexedBranchesPanel); + } panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel); panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel); @@ -433,7 +444,8 @@ public class EditRepositoryDialog extends JDialog { if (repository.federationStrategy.exceeds(FederationStrategy.EXCLUDE)) { repository.federationSets = setsPalette.getSelections(); } - + + repository.indexedBranches = indexedBranchesPalette.getSelections(); repository.preReceiveScripts = preReceivePalette.getSelections(); repository.postReceiveScripts = postReceivePalette.getSelections(); return true; @@ -470,6 +482,10 @@ public class EditRepositoryDialog extends JDialog { public void setFederationSets(List all, List selected) { setsPalette.setObjects(all, selected); } + + public void setIndexedBranches(List all, List selected) { + indexedBranchesPalette.setObjects(all, selected); + } public void setPreReceiveScripts(List all, List inherited, List selected) { diff --git a/src/com/gitblit/client/RepositoriesPanel.java b/src/com/gitblit/client/RepositoriesPanel.java index 104010d5..0643b60b 100644 --- a/src/com/gitblit/client/RepositoriesPanel.java +++ b/src/com/gitblit/client/RepositoriesPanel.java @@ -357,6 +357,7 @@ public abstract class RepositoriesPanel extends JPanel { dialog.setTeams(gitblit.getTeamnames(), null); dialog.setRepositories(gitblit.getRepositories()); dialog.setFederationSets(gitblit.getFederationSets(), null); + dialog.setIndexedBranches(new ArrayList(), null); dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null), gitblit.getPreReceiveScriptsInherited(null), null); dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null), @@ -419,6 +420,7 @@ public abstract class RepositoriesPanel extends JPanel { dialog.setTeams(gitblit.getTeamnames(), gitblit.getPermittedTeamnames(repository)); dialog.setRepositories(gitblit.getRepositories()); dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets); + dialog.setIndexedBranches(repository.getLocalBranches(), repository.indexedBranches); dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(repository), gitblit.getPreReceiveScriptsInherited(repository), repository.preReceiveScripts); dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(repository), diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java index c087a358..324f7d47 100644 --- a/src/com/gitblit/models/RepositoryModel.java +++ b/src/com/gitblit/models/RepositoryModel.java @@ -22,6 +22,7 @@ import java.util.List; import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.FederationStrategy; +import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.StringUtils; /** @@ -77,6 +78,19 @@ public class RepositoryModel implements Serializable, Comparable(); this.federationStrategy = FederationStrategy.FEDERATE_THIS; } + + public List getLocalBranches() { + if (ArrayUtils.isEmpty(availableRefs)) { + return new ArrayList(); + } + List localBranches = new ArrayList(); + for (String ref : availableRefs) { + if (ref.startsWith("refs/heads")) { + localBranches.add(ref); + } + } + return localBranches; + } @Override public String toString() { diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index 172859f1..bd84ae3c 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -39,7 +39,6 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.util.CollectionModel; import org.apache.wicket.model.util.ListModel; -import org.eclipse.jgit.lib.Constants; import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.FederationStrategy; @@ -117,14 +116,8 @@ public class EditRepositoryPage extends RootSubPage { new StringChoiceRenderer(), 8, false); // indexed local branches palette - List allLocalBranches = new ArrayList(); - if (!ArrayUtils.isEmpty(repositoryModel.availableRefs)) { - for (String ref : repositoryModel.availableRefs) { - if (ref.startsWith(Constants.R_HEADS)) { - allLocalBranches.add(ref); - } - } - } + List allLocalBranches = repositoryModel.getLocalBranches(); + final Palette indexedBranchesPalette = new Palette("indexedBranches", new ListModel( indexedBranches), new CollectionModel(allLocalBranches), new StringChoiceRenderer(), 8, false);