From 08d86d5b8852cab1837a53cc2c56bb661da59499 Mon Sep 17 00:00:00 2001 From: John Crygier Date: Mon, 7 May 2012 07:43:19 -0500 Subject: [PATCH] Make the variables / messages more consistant --- src/com/gitblit/Constants.java | 4 +-- src/com/gitblit/GitBlit.java | 10 +++--- src/com/gitblit/models/RepositoryModel.java | 2 +- .../gitblit/wicket/GitBlitWebApp.properties | 4 +-- .../wicket/pages/EditRepositoryPage.html | 6 ++-- .../wicket/pages/EditRepositoryPage.java | 22 ++++++------ .../gitblit/tests/RepositoryModelTest.java | 34 +++++++++---------- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java index c84b95f1..80e77993 100644 --- a/src/com/gitblit/Constants.java +++ b/src/com/gitblit/Constants.java @@ -72,9 +72,9 @@ public class Constants { 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; diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 8ba080af..f4a5ccc0 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -859,9 +859,9 @@ public class GitBlit implements ServletContextListener { "gitblit", null, "indexBranch"))); // Custom defined properties - model.customDefinedProperties = new HashMap(); - 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(); + 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 @@ public class GitBlit implements ServletContextListener { updateList(config, "indexBranch", repository.indexedBranches); // User Defined Properties - for (Entry singleProperty : repository.customDefinedProperties.entrySet()) { - config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue()); + for (Entry singleProperty : repository.customFields.entrySet()) { + config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue()); } try { diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java index 92fc2373..0e0c2df1 100644 --- a/src/com/gitblit/models/RepositoryModel.java +++ b/src/com/gitblit/models/RepositoryModel.java @@ -64,7 +64,7 @@ public class RepositoryModel implements Serializable, Comparable preReceiveScripts; public List postReceiveScripts; public List mailingLists; - public Map customDefinedProperties; + public Map customFields; private String displayName; public RepositoryModel() { diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index b96a32ed..dfbdd4bf 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -202,8 +202,8 @@ gb.mailingLists = mailing lists 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 diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html index e144f382..07c55226 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -36,9 +36,9 @@

 

-
-

 

- +
+

 

+
 
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index 13b9e5a6..f3e2c386 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -165,17 +165,17 @@ public class EditRepositoryPage extends RootSubPage { definedProperties.add(new AbstractMap.SimpleEntry(customFieldProperty[0], customFieldProperty[1])); } - final ListView> customDefinedProperties = new ListView>("customDefinedProperties", definedProperties) { + final ListView> customFieldsListView = new ListView>("customFieldsListView", definedProperties) { @Override protected void populateItem(ListItem> 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("customValue", new Model(value))); + item.add(new Label("customFieldLabel", item.getModelObject().getValue())); + item.add(new TextField("customFieldValue", new Model(value))); } }; - customDefinedProperties.setReuseItems(true); + customFieldsListView.setReuseItems(true); CompoundPropertyModel model = new CompoundPropertyModel( repositoryModel); @@ -278,12 +278,12 @@ public class EditRepositoryPage extends RootSubPage { repositoryModel.postReceiveScripts = postReceiveScripts; // Loop over each of the user defined properties - for (int i = 0; i < customDefinedProperties.size(); i++) { - ListItem> item = (ListItem>) customDefinedProperties.get(i); + for (int i = 0; i < customFieldsListView.size(); i++) { + ListItem> item = (ListItem>) customFieldsListView.get(i); String key = item.get(0).getId(); // Item 0 is our 'fake' label String value = ((TextField)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 @@ public class EditRepositoryPage extends RootSubPage { 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") { diff --git a/tests/com/gitblit/tests/RepositoryModelTest.java b/tests/com/gitblit/tests/RepositoryModelTest.java index 611ed295..3596c333 100644 --- a/tests/com/gitblit/tests/RepositoryModelTest.java +++ b/tests/com/gitblit/tests/RepositoryModelTest.java @@ -25,11 +25,11 @@ public class RepositoryModelTest { 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 @@ public class RepositoryModelTest { 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 @@ public class RepositoryModelTest { 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 @@ public class RepositoryModelTest { 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 @@ public class RepositoryModelTest { 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 @@ public class RepositoryModelTest { 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")); } } -- 2.39.5