]> source.dussan.org Git - gitblit.git/commitdiff
Implemented RPC administration of indexed branches
authorJames Moger <james.moger@gitblit.com>
Sat, 17 Mar 2012 16:09:01 +0000 (12:09 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 17 Mar 2012 16:09:01 +0000 (12:09 -0400)
docs/02_rpc.mkd
src/com/gitblit/RpcServlet.java
src/com/gitblit/client/EditRepositoryDialog.java
src/com/gitblit/client/RepositoriesPanel.java
src/com/gitblit/models/RepositoryModel.java
src/com/gitblit/wicket/pages/EditRepositoryPage.java

index 84446f5b49a990cd61648862c9e2b00435fcb4f9..98a73e59d80f88397e5950fdb35996881965b79f 100644 (file)
@@ -63,6 +63,7 @@ The Gitblit API includes methods for retrieving and interpreting RSS feeds.  The
 <tr><th>Release</th><th>Protocol Version</th></tr>\r
 <tr><td>Gitblit v0.7.0</td><td>1 (inferred version)</td></tr>\r
 <tr><td>Gitblit v0.8.0</td><td>2</td></tr>\r
+<tr><td>Gitblit v0.9.0</td><td>3</td></tr>\r
 </tbody>\r
 </table>\r
 \r
index 2d51388760f2deaedfd3c8652dd3fb3e36b2f8c1..31ee5ad0454804eb632e3ed8ce6033d9b33c4265 100644 (file)
@@ -49,7 +49,7 @@ public class RpcServlet extends JsonServlet {
 \r
        private static final long serialVersionUID = 1L;\r
 \r
-       public static final int PROTOCOL_VERSION = 2;\r
+       public static final int PROTOCOL_VERSION = 3;\r
 \r
        public RpcServlet() {\r
                super();\r
index 4d3485dfa85e2e46461c09c4de68f3a008064859..5c746cc13aac948bbd364b13aebdd83db5a2c390 100644 (file)
@@ -105,6 +105,8 @@ public class EditRepositoryDialog extends JDialog {
        private JPalette<String> setsPalette;\r
 \r
        private JPalette<String> teamsPalette;\r
+       \r
+       private JPalette<String> indexedBranchesPalette;\r
 \r
        private JPalette<String> preReceivePalette;\r
 \r
@@ -258,6 +260,12 @@ public class EditRepositoryDialog extends JDialog {
                                .add(newFieldPanel(Translation.get("gb.federationSets"),\r
                                                setsPalette), BorderLayout.CENTER);\r
 \r
+               indexedBranchesPalette = new JPalette<String>();\r
+               JPanel indexedBranchesPanel = new JPanel(new BorderLayout(5, 5));\r
+               indexedBranchesPanel\r
+                               .add(newFieldPanel(Translation.get("gb.indexedBranches"),\r
+                                               indexedBranchesPalette), BorderLayout.CENTER);\r
+\r
                preReceivePalette = new JPalette<String>(true);\r
                preReceiveInherited = new JLabel();\r
                JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));\r
@@ -277,6 +285,9 @@ public class EditRepositoryDialog extends JDialog {
                        panel.addTab(Translation.get("gb.teams"), teamsPanel);\r
                }\r
                panel.addTab(Translation.get("gb.federation"), federationPanel);\r
+               if (protocolVersion >= 3) {\r
+                       panel.addTab(Translation.get("gb.indexedBranches"), indexedBranchesPanel);\r
+               }\r
                panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);\r
                panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);\r
 \r
@@ -433,7 +444,8 @@ public class EditRepositoryDialog extends JDialog {
                if (repository.federationStrategy.exceeds(FederationStrategy.EXCLUDE)) {\r
                        repository.federationSets = setsPalette.getSelections();\r
                }\r
-\r
+               \r
+               repository.indexedBranches = indexedBranchesPalette.getSelections();\r
                repository.preReceiveScripts = preReceivePalette.getSelections();\r
                repository.postReceiveScripts = postReceivePalette.getSelections();\r
                return true;\r
@@ -470,6 +482,10 @@ public class EditRepositoryDialog extends JDialog {
        public void setFederationSets(List<String> all, List<String> selected) {\r
                setsPalette.setObjects(all, selected);\r
        }\r
+       \r
+       public void setIndexedBranches(List<String> all, List<String> selected) {\r
+               indexedBranchesPalette.setObjects(all, selected);\r
+       }\r
 \r
        public void setPreReceiveScripts(List<String> all, List<String> inherited,\r
                        List<String> selected) {\r
index 104010d5b5e8e6ed242f7bcd12bdc9a890b02606..0643b60b9241ee5e4297964216b034384b73f446 100644 (file)
@@ -357,6 +357,7 @@ public abstract class RepositoriesPanel extends JPanel {
                dialog.setTeams(gitblit.getTeamnames(), null);\r
                dialog.setRepositories(gitblit.getRepositories());\r
                dialog.setFederationSets(gitblit.getFederationSets(), null);\r
+               dialog.setIndexedBranches(new ArrayList<String>(), null);\r
                dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null),\r
                                gitblit.getPreReceiveScriptsInherited(null), null);\r
                dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null),\r
@@ -419,6 +420,7 @@ public abstract class RepositoriesPanel extends JPanel {
                dialog.setTeams(gitblit.getTeamnames(), gitblit.getPermittedTeamnames(repository));\r
                dialog.setRepositories(gitblit.getRepositories());\r
                dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets);\r
+               dialog.setIndexedBranches(repository.getLocalBranches(), repository.indexedBranches);\r
                dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(repository),\r
                                gitblit.getPreReceiveScriptsInherited(repository), repository.preReceiveScripts);\r
                dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(repository),\r
index c087a358d8a62b68bdcdf0a4e69cf4b7efe3af5b..324f7d470b8508ccb6ff1d72b12728e2649e4daa 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.FederationStrategy;\r
+import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.StringUtils;\r
 \r
 /**\r
@@ -77,6 +78,19 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                this.federationSets = new ArrayList<String>();\r
                this.federationStrategy = FederationStrategy.FEDERATE_THIS;             \r
        }\r
+       \r
+       public List<String> getLocalBranches() {\r
+               if (ArrayUtils.isEmpty(availableRefs)) {\r
+                       return new ArrayList<String>();\r
+               }\r
+               List<String> localBranches = new ArrayList<String>();\r
+               for (String ref : availableRefs) {\r
+                       if (ref.startsWith("refs/heads")) {\r
+                               localBranches.add(ref);\r
+                       }\r
+               }\r
+               return localBranches;\r
+       }\r
 \r
        @Override\r
        public String toString() {\r
index 172859f1374f429792799686fc4f2e3b4616fb03..bd84ae3c586f99d2c0b9755d82dfba09c154a4b9 100644 (file)
@@ -39,7 +39,6 @@ import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;\r
 import org.apache.wicket.model.util.CollectionModel;\r
 import org.apache.wicket.model.util.ListModel;\r
-import org.eclipse.jgit.lib.Constants;\r
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.FederationStrategy;\r
@@ -117,14 +116,8 @@ public class EditRepositoryPage extends RootSubPage {
                                new StringChoiceRenderer(), 8, false);\r
 \r
                // indexed local branches palette\r
-               List<String> allLocalBranches = new ArrayList<String>();\r
-               if (!ArrayUtils.isEmpty(repositoryModel.availableRefs)) {\r
-                       for (String ref : repositoryModel.availableRefs) {\r
-                               if (ref.startsWith(Constants.R_HEADS)) {\r
-                                       allLocalBranches.add(ref);\r
-                               }\r
-                       }\r
-               }\r
+               List<String> allLocalBranches = repositoryModel.getLocalBranches();\r
+\r
                final Palette<String> indexedBranchesPalette = new Palette<String>("indexedBranches", new ListModel<String>(\r
                                indexedBranches), new CollectionModel<String>(allLocalBranches),\r
                                new StringChoiceRenderer(), 8, false);\r