John Crygier
2012-05-07 08d86d5b8852cab1837a53cc2c56bb661da59499
Make the variables / messages more consistant
7 files modified
82 ■■■■ changed files
src/com/gitblit/Constants.java 4 ●●●● patch | view | raw | blame | history
src/com/gitblit/GitBlit.java 10 ●●●● patch | view | raw | blame | history
src/com/gitblit/models/RepositoryModel.java 2 ●●● patch | view | raw | blame | history
src/com/gitblit/wicket/GitBlitWebApp.properties 4 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/EditRepositoryPage.html 6 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/EditRepositoryPage.java 22 ●●●● patch | view | raw | blame | history
tests/com/gitblit/tests/RepositoryModelTest.java 34 ●●●● patch | view | raw | blame | history
src/com/gitblit/Constants.java
@@ -72,9 +72,9 @@
    
    public static final String DEFAULT_BRANCH = "default";
    
    public static String CUSTOM_DEFINED_PROP_SECTION = "gitblit";
    public static String CUSTOM_FIELDS_PROP_SECTION = "gitblit";
    
    public static String CUSTOM_DEFINED_PROP_SUBSECTION = "customDefinedProperties";
    public static String CUSTOM_FIELDS_PROP_SUBSECTION = "customFields";
    
    public static String getGitBlitVersion() {
        return NAME + " v" + VERSION;
src/com/gitblit/GitBlit.java
@@ -859,9 +859,9 @@
                    "gitblit", null, "indexBranch")));
            
            // Custom defined properties
            model.customDefinedProperties = new HashMap<String, String>();
            for (String aProperty : config.getNames(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION)) {
                model.customDefinedProperties.put(aProperty, config.getString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, aProperty));
            model.customFields = new HashMap<String, String>();
            for (String aProperty : config.getNames(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION)) {
                model.customFields.put(aProperty, config.getString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, aProperty));
            }
        }
        model.HEAD = JGitUtils.getHEADRef(r);
@@ -1111,8 +1111,8 @@
        updateList(config, "indexBranch", repository.indexedBranches);
        
        // User Defined Properties
        for (Entry<String, String> singleProperty : repository.customDefinedProperties.entrySet()) {
            config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue());
        for (Entry<String, String> singleProperty : repository.customFields.entrySet()) {
            config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue());
        }
        try {
src/com/gitblit/models/RepositoryModel.java
@@ -64,7 +64,7 @@
    public List<String> preReceiveScripts;
    public List<String> postReceiveScripts;
    public List<String> mailingLists;
    public Map<String, String> customDefinedProperties;
    public Map<String, String> customFields;
    private String displayName;
    
    public RepositoryModel() {
src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -202,8 +202,8 @@
gb.preReceiveScripts = pre-receive scripts
gb.postReceiveScripts = post-receive scripts
gb.hookScripts = hook scripts
gb.customDefinedProperties = custom defined properties
gb.customDefinedPropertiesDescription = custom properties available to groovy hooks
gb.customFields = custom fields
gb.customFieldsDescription = custom fields available to groovy hooks
gb.accessPermissions = access permissions
gb.filters = filters
gb.generalDescription = common settings
src/com/gitblit/wicket/pages/EditRepositoryPage.html
@@ -36,9 +36,9 @@
                <tr><td colspan="2"><h3><wicket:message key="gb.hookScripts"></wicket:message> &nbsp;<small><wicket:message key="gb.hookScriptsDescription"></wicket:message></small></h3></td></tr>    
                <tr><th style="vertical-align: top;"><wicket:message key="gb.preReceiveScripts"></wicket:message><p></p><span wicket:id="inheritedPreReceive"></span></th><td style="padding:2px;"><span wicket:id="preReceiveScripts"></span></td></tr>
                <tr><th style="vertical-align: top;"><wicket:message key="gb.postReceiveScripts"></wicket:message><p></p><span wicket:id="inheritedPostReceive"></span></th><td style="padding:2px;"><span wicket:id="postReceiveScripts"></span></td></tr>
                <div wicket:id="customDefinedPropertiesSection">
                    <tr><td colspan="2"><h3><wicket:message key="gb.customDefinedProperties"></wicket:message> &nbsp;<small><wicket:message key="gb.customDefinedPropertiesDescription"></wicket:message></small></h3></td></tr>
                    <tr wicket:id="customDefinedProperties"><th style="vertical-align: top;"><span wicket:id="customLabel"></span></th><td class="edit"><input class="span8" type="text" wicket:id="customValue" size="30" tabindex="16" /></td></tr>
                <div wicket:id="customFiledsSection">
                    <tr><td colspan="2"><h3><wicket:message key="gb.customFields"></wicket:message> &nbsp;<small><wicket:message key="gb.customFieldsDescription"></wicket:message></small></h3></td></tr>
                    <tr wicket:id="customFieldsListView"><th style="vertical-align: top;"><span wicket:id="customFieldLabel"></span></th><td class="edit"><input class="span8" type="text" wicket:id="customFieldValue" size="30" tabindex="16" /></td></tr>
                </div>
                <tr><td colspan='2'><div class="form-actions"><input class="btn btn-primary" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" tabindex="17" /> &nbsp; <input class="btn" type="submit" value="Cancel" wicket:message="value:gb.cancel" wicket:id="cancel" tabindex="18" /></div></td></tr>
            </tbody>
src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -165,17 +165,17 @@
            definedProperties.add(new AbstractMap.SimpleEntry<String, String>(customFieldProperty[0], customFieldProperty[1]));
        }
        
        final ListView<Entry<String, String>> customDefinedProperties = new ListView<Entry<String, String>>("customDefinedProperties", definedProperties) {
        final ListView<Entry<String, String>> customFieldsListView = new ListView<Entry<String, String>>("customFieldsListView", definedProperties) {
            @Override
            protected void populateItem(ListItem<Entry<String, String>> item) {
                String value = repositoryModel.customDefinedProperties.get(item.getModelObject().getKey());
                String value = repositoryModel.customFields.get(item.getModelObject().getKey());
                
                item.add(new Label(item.getModelObject().getKey(), item.getModelObject().getValue()));        // Used to get the key later
                item.add(new Label("customLabel", item.getModelObject().getValue()));
                item.add(new TextField<String>("customValue", new Model<String>(value)));
                item.add(new Label("customFieldLabel", item.getModelObject().getValue()));
                item.add(new TextField<String>("customFieldValue", new Model<String>(value)));
            }
        };
        customDefinedProperties.setReuseItems(true);
        customFieldsListView.setReuseItems(true);
        CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(
                repositoryModel);
@@ -278,12 +278,12 @@
                    repositoryModel.postReceiveScripts = postReceiveScripts;
                    
                    // Loop over each of the user defined properties
                    for (int i = 0; i < customDefinedProperties.size(); i++) {
                        ListItem<ListItemModel<String>> item = (ListItem<ListItemModel<String>>) customDefinedProperties.get(i);
                    for (int i = 0; i < customFieldsListView.size(); i++) {
                        ListItem<ListItemModel<String>> item = (ListItem<ListItemModel<String>>) customFieldsListView.get(i);
                        String key = item.get(0).getId();        // Item 0 is our 'fake' label
                        String value = ((TextField<String>)item.get(2)).getValue();        // Item 2 is out text box
                        
                        repositoryModel.customDefinedProperties.put(key, value);
                        repositoryModel.customFields.put(key, value);
                    }
                    
                    // save the repository
@@ -371,13 +371,13 @@
        form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()
                .getPostReceiveScriptsInherited(repositoryModel)));
        
        WebMarkupContainer customDefinedPropertiesSection = new WebMarkupContainer("customDefinedPropertiesSection") {
        WebMarkupContainer customFiledsSection = new WebMarkupContainer("customFiledsSection") {
            public boolean isVisible() {
                return GitBlit.getString(Keys.repository.customFields, "").isEmpty() == false;
            };
        };
        customDefinedPropertiesSection.add(customDefinedProperties);
        form.add(customDefinedPropertiesSection);
        customFiledsSection.add(customFieldsListView);
        form.add(customFiledsSection);
        form.add(new Button("save"));
        Button cancel = new Button("cancel") {
tests/com/gitblit/tests/RepositoryModelTest.java
@@ -25,11 +25,11 @@
    public static void startGitBlit() throws Exception {
        wasStarted = GitBlitSuite.startGitblit() == false;
        
        oldSection = Constants.CUSTOM_DEFINED_PROP_SECTION;
        oldSubSection = Constants.CUSTOM_DEFINED_PROP_SUBSECTION;
        oldSection = Constants.CUSTOM_FIELDS_PROP_SECTION;
        oldSubSection = Constants.CUSTOM_FIELDS_PROP_SUBSECTION;
        
        Constants.CUSTOM_DEFINED_PROP_SECTION = "RepositoryModelTest";
        Constants.CUSTOM_DEFINED_PROP_SUBSECTION = "RepositoryModelTestSubSection";
        Constants.CUSTOM_FIELDS_PROP_SECTION = "RepositoryModelTest";
        Constants.CUSTOM_FIELDS_PROP_SUBSECTION = "RepositoryModelTestSubSection";
    }
    
    @AfterClass
@@ -37,8 +37,8 @@
        if (wasStarted == false)
            GitBlitSuite.stopGitblit();
        
        Constants.CUSTOM_DEFINED_PROP_SECTION = oldSection;
        Constants.CUSTOM_DEFINED_PROP_SUBSECTION = oldSubSection;
        Constants.CUSTOM_FIELDS_PROP_SECTION = oldSection;
        Constants.CUSTOM_FIELDS_PROP_SUBSECTION = oldSubSection;
    }
    
    @Before
@@ -46,9 +46,9 @@
        Repository r = GitBlitSuite.getHelloworldRepository();
        StoredConfig config = JGitUtils.readConfig(r);
        
        config.unsetSection(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION);
        config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, "commitMessageRegEx", "\\d");
        config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, "anotherProperty", "Hello");
        config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION);
        config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, "commitMessageRegEx", "\\d");
        config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, "anotherProperty", "Hello");
        
        config.save();
    }
@@ -58,7 +58,7 @@
        Repository r = GitBlitSuite.getHelloworldRepository();
        StoredConfig config = JGitUtils.readConfig(r);
        
        config.unsetSection(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION);
        config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION);
        config.save();
    }
@@ -67,8 +67,8 @@
        RepositoryModel model = GitBlit.self().getRepositoryModel(
                GitBlitSuite.getHelloworldRepository().getDirectory().getName());
        
        assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx"));
        assertEquals("Hello", model.customDefinedProperties.get("anotherProperty"));
        assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
        assertEquals("Hello", model.customFields.get("anotherProperty"));
    }
    
    @Test
@@ -76,17 +76,17 @@
        RepositoryModel model = GitBlit.self().getRepositoryModel(
                GitBlitSuite.getHelloworldRepository().getDirectory().getName());
        
        assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx"));
        assertEquals("Hello", model.customDefinedProperties.get("anotherProperty"));
        assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
        assertEquals("Hello", model.customFields.get("anotherProperty"));
        
        assertEquals("Hello", model.customDefinedProperties.put("anotherProperty", "GoodBye"));
        assertEquals("Hello", model.customFields.put("anotherProperty", "GoodBye"));
        GitBlit.self().updateRepositoryModel(model.name, model, false);
        
        model = GitBlit.self().getRepositoryModel(
                GitBlitSuite.getHelloworldRepository().getDirectory().getName());
        
        assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx"));
        assertEquals("GoodBye", model.customDefinedProperties.get("anotherProperty"));
        assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
        assertEquals("GoodBye", model.customFields.get("anotherProperty"));
    }
}