James Moger
2012-03-17 e9de3f7fd55dd4d4535cd7b2fc2bee8094152e39
Implemented RPC administration of indexed branches
6 files modified
48 ■■■■ changed files
docs/02_rpc.mkd 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/RpcServlet.java 2 ●●● patch | view | raw | blame | history
src/com/gitblit/client/EditRepositoryDialog.java 18 ●●●●● patch | view | raw | blame | history
src/com/gitblit/client/RepositoriesPanel.java 2 ●●●●● patch | view | raw | blame | history
src/com/gitblit/models/RepositoryModel.java 14 ●●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/EditRepositoryPage.java 11 ●●●● patch | view | raw | blame | history
docs/02_rpc.mkd
@@ -63,6 +63,7 @@
<tr><th>Release</th><th>Protocol Version</th></tr>
<tr><td>Gitblit v0.7.0</td><td>1 (inferred version)</td></tr>
<tr><td>Gitblit v0.8.0</td><td>2</td></tr>
<tr><td>Gitblit v0.9.0</td><td>3</td></tr>
</tbody>
</table>
src/com/gitblit/RpcServlet.java
@@ -49,7 +49,7 @@
    private static final long serialVersionUID = 1L;
    public static final int PROTOCOL_VERSION = 2;
    public static final int PROTOCOL_VERSION = 3;
    public RpcServlet() {
        super();
src/com/gitblit/client/EditRepositoryDialog.java
@@ -105,6 +105,8 @@
    private JPalette<String> setsPalette;
    private JPalette<String> teamsPalette;
    private JPalette<String> indexedBranchesPalette;
    private JPalette<String> preReceivePalette;
@@ -258,6 +260,12 @@
                .add(newFieldPanel(Translation.get("gb.federationSets"),
                        setsPalette), BorderLayout.CENTER);
        indexedBranchesPalette = new JPalette<String>();
        JPanel indexedBranchesPanel = new JPanel(new BorderLayout(5, 5));
        indexedBranchesPanel
                .add(newFieldPanel(Translation.get("gb.indexedBranches"),
                        indexedBranchesPalette), BorderLayout.CENTER);
        preReceivePalette = new JPalette<String>(true);
        preReceiveInherited = new JLabel();
        JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
@@ -277,6 +285,9 @@
            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 @@
        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 void setFederationSets(List<String> all, List<String> selected) {
        setsPalette.setObjects(all, selected);
    }
    public void setIndexedBranches(List<String> all, List<String> selected) {
        indexedBranchesPalette.setObjects(all, selected);
    }
    public void setPreReceiveScripts(List<String> all, List<String> inherited,
            List<String> selected) {
src/com/gitblit/client/RepositoriesPanel.java
@@ -357,6 +357,7 @@
        dialog.setTeams(gitblit.getTeamnames(), null);
        dialog.setRepositories(gitblit.getRepositories());
        dialog.setFederationSets(gitblit.getFederationSets(), null);
        dialog.setIndexedBranches(new ArrayList<String>(), null);
        dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null),
                gitblit.getPreReceiveScriptsInherited(null), null);
        dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null),
@@ -419,6 +420,7 @@
        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),
src/com/gitblit/models/RepositoryModel.java
@@ -22,6 +22,7 @@
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.FederationStrategy;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.StringUtils;
/**
@@ -77,6 +78,19 @@
        this.federationSets = new ArrayList<String>();
        this.federationStrategy = FederationStrategy.FEDERATE_THIS;        
    }
    public List<String> getLocalBranches() {
        if (ArrayUtils.isEmpty(availableRefs)) {
            return new ArrayList<String>();
        }
        List<String> localBranches = new ArrayList<String>();
        for (String ref : availableRefs) {
            if (ref.startsWith("refs/heads")) {
                localBranches.add(ref);
            }
        }
        return localBranches;
    }
    @Override
    public String toString() {
src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -39,7 +39,6 @@
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 @@
                new StringChoiceRenderer(), 8, false);
        // indexed local branches palette
        List<String> allLocalBranches = new ArrayList<String>();
        if (!ArrayUtils.isEmpty(repositoryModel.availableRefs)) {
            for (String ref : repositoryModel.availableRefs) {
                if (ref.startsWith(Constants.R_HEADS)) {
                    allLocalBranches.add(ref);
                }
            }
        }
        List<String> allLocalBranches = repositoryModel.getLocalBranches();
        final Palette<String> indexedBranchesPalette = new Palette<String>("indexedBranches", new ListModel<String>(
                indexedBranches), new CollectionModel<String>(allLocalBranches),
                new StringChoiceRenderer(), 8, false);