]> source.dussan.org Git - gitblit.git/commitdiff
Changed constants and fixed nullpointer in update repository
authorJames Moger <james.moger@gitblit.com>
Thu, 10 May 2012 13:16:14 +0000 (09:16 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 10 May 2012 13:16:14 +0000 (09:16 -0400)
distrib/gitblit.properties
docs/04_releases.mkd
src/com/gitblit/Constants.java
src/com/gitblit/GitBlit.java
tests/com/gitblit/tests/RepositoryModelTest.java

index e04f2c8faafadc0a1b483d6fc9a6f0d853e5d35f..6353696e0a0ff199b69ba922d5e8da6c98e3fbca 100644 (file)
@@ -91,6 +91,21 @@ groovy.preReceiveScripts =
 # SINCE 0.8.0\r
 groovy.postReceiveScripts =\r
 \r
+# Repository custom fields for Groovy Hook mechanism\r
+#\r
+# List of key=label pairs of custom fields to prompt for in the Edit Repository\r
+# page.  These keys are stored in the repository's git config file in the \r
+# section [gitblit "customFields"].  Key names are alphanumeric only.  These\r
+# fields are intended to be used for the Groovy hook mechanism where a script\r
+# can adjust it's execution based on the custom fields stored in the repository\r
+# config.\r
+#\r
+# e.g. "commitMsgRegex=Commit Message Regular Expression" anotherProperty=Another\r
+#\r
+# SPACE-DELIMITED\r
+# SINCE 1.0.0\r
+groovy.customFields = \r
+\r
 #\r
 # Authentication Settings\r
 #\r
@@ -815,14 +830,4 @@ server.storePassword = gitblit
 #\r
 # SINCE 0.5.0\r
 # RESTART REQUIRED\r
-server.shutdownPort = 8081\r
-\r
-# Custom Defined Properties for Repositories\r
-# Space delimited (use quotes if labels have spaces) list of custom properties\r
-# to show up on the "Edit Repository" page, with labels.  Thes custom properties will\r
-# then be available for hooks.\r
-#\r
-# E.g. "commit-msg-regex=Commit Message Regualar Expression" another-property=Another\r
-#\r
-# SINCE 1.0.0\r
-repository.customFields = 
\ No newline at end of file
+server.shutdownPort = 8081
\ No newline at end of file
index cf65ea04712dcdcd2bb6161207734e0f6bd17228..5bad8516f8dc72d421921d53d9fa33e516125c3d 100644 (file)
@@ -4,6 +4,10 @@
 \r
 **%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%) | [war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) | [express](http://code.google.com/p/gitblit/downloads/detail?name=%EXPRESS%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] &nbsp; *released %BUILDDATE%*\r
 \r
+#### fixes\r
+\r
+- Fixed bug in Basic authentication if passwords had a colon (Github/peterloron)\r
+\r
 #### changes\r
 \r
 - IUserService interface has changed to better accomodate custom authentication and/or custom authorization\r
@@ -11,6 +15,8 @@
 #### additions\r
 \r
 - Added LDAP User Service with many new *realm.ldap* keys (Github/jcrygier)\r
+- Added support for custom repository properties for Groovy hooks (Github/jcrygier)\r
+- Added script to facilicate proxy environment setup on Linux (Github/mragab)\r
 \r
 **0.9.3** *released 2012-04-11*\r
 \r
index 80e77993af914fe49f77fc28774d7fa66f41adfa..b11505c0389bdeafcf36dcee8f029aa0a2e092dc 100644 (file)
@@ -72,9 +72,9 @@ public class Constants {
        \r
        public static final String DEFAULT_BRANCH = "default";\r
        \r
-       public static String CUSTOM_FIELDS_PROP_SECTION = "gitblit";\r
+       public static final String CONFIG_GITBLIT = "gitblit";\r
        \r
-       public static String CUSTOM_FIELDS_PROP_SUBSECTION = "customFields";\r
+       public static final String CONFIG_CUSTOM_FIELDS = "customFields";\r
        \r
        public static String getGitBlitVersion() {\r
                return NAME + " v" + VERSION;\r
index 273ad366855dedb38ce661d688f06cc0bba92e0c..57421a3142874dc82ab4590b5156185b5011f61f 100644 (file)
@@ -846,22 +846,22 @@ public class GitBlit implements ServletContextListener {
                        model.federationStrategy = FederationStrategy.fromName(getConfig(config,\r
                                        "federationStrategy", null));\r
                        model.federationSets = new ArrayList<String>(Arrays.asList(config.getStringList(\r
-                                       "gitblit", null, "federationSets")));\r
+                                       Constants.CONFIG_GITBLIT, null, "federationSets")));\r
                        model.isFederated = getConfig(config, "isFederated", false);\r
                        model.origin = config.getString("remote", "origin", "url");\r
                        model.preReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(\r
-                                       "gitblit", null, "preReceiveScript")));\r
+                                       Constants.CONFIG_GITBLIT, null, "preReceiveScript")));\r
                        model.postReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(\r
-                                       "gitblit", null, "postReceiveScript")));\r
+                                       Constants.CONFIG_GITBLIT, null, "postReceiveScript")));\r
                        model.mailingLists = new ArrayList<String>(Arrays.asList(config.getStringList(\r
-                                       "gitblit", null, "mailingList")));\r
+                                       Constants.CONFIG_GITBLIT, null, "mailingList")));\r
                        model.indexedBranches = new ArrayList<String>(Arrays.asList(config.getStringList(\r
-                                       "gitblit", null, "indexBranch")));\r
+                                       Constants.CONFIG_GITBLIT, null, "indexBranch")));\r
                        \r
                        // Custom defined properties\r
                        model.customFields = new HashMap<String, String>();\r
-                       for (String aProperty : config.getNames(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION)) {\r
-                               model.customFields.put(aProperty, config.getString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, aProperty));\r
+                       for (String aProperty : config.getNames(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS)) {\r
+                               model.customFields.put(aProperty, config.getString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, aProperty));\r
                        }\r
                }\r
                model.HEAD = JGitUtils.getHEADRef(r);\r
@@ -956,7 +956,7 @@ public class GitBlit implements ServletContextListener {
         * @return field value or defaultValue\r
         */\r
        private String getConfig(StoredConfig config, String field, String defaultValue) {\r
-               String value = config.getString("gitblit", null, field);\r
+               String value = config.getString(Constants.CONFIG_GITBLIT, null, field);\r
                if (StringUtils.isEmpty(value)) {\r
                        return defaultValue;\r
                }\r
@@ -964,7 +964,7 @@ public class GitBlit implements ServletContextListener {
        }\r
 \r
        /**\r
-        * Returns the gitblit boolean vlaue for the specified key. If key is not\r
+        * Returns the gitblit boolean value for the specified key. If key is not\r
         * set, returns defaultValue.\r
         * \r
         * @param config\r
@@ -973,7 +973,7 @@ public class GitBlit implements ServletContextListener {
         * @return field value or defaultValue\r
         */\r
        private boolean getConfig(StoredConfig config, String field, boolean defaultValue) {\r
-               return config.getBoolean("gitblit", field, defaultValue);\r
+               return config.getBoolean(Constants.CONFIG_GITBLIT, field, defaultValue);\r
        }\r
 \r
        /**\r
@@ -1090,19 +1090,19 @@ public class GitBlit implements ServletContextListener {
         */\r
        public void updateConfiguration(Repository r, RepositoryModel repository) {\r
                StoredConfig config = JGitUtils.readConfig(r);\r
-               config.setString("gitblit", null, "description", repository.description);\r
-               config.setString("gitblit", null, "owner", repository.owner);\r
-               config.setBoolean("gitblit", null, "useTickets", repository.useTickets);\r
-               config.setBoolean("gitblit", null, "useDocs", repository.useDocs);\r
-               config.setString("gitblit", null, "accessRestriction", repository.accessRestriction.name());\r
-               config.setBoolean("gitblit", null, "showRemoteBranches", repository.showRemoteBranches);\r
-               config.setBoolean("gitblit", null, "isFrozen", repository.isFrozen);\r
-               config.setBoolean("gitblit", null, "showReadme", repository.showReadme);\r
-               config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation);\r
-               config.setBoolean("gitblit", null, "skipSummaryMetrics", repository.skipSummaryMetrics);\r
-               config.setString("gitblit", null, "federationStrategy",\r
+               config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);\r
+               config.setString(Constants.CONFIG_GITBLIT, null, "owner", repository.owner);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs);\r
+               config.setString(Constants.CONFIG_GITBLIT, null, "accessRestriction", repository.accessRestriction.name());\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "showRemoteBranches", repository.showRemoteBranches);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFrozen", repository.isFrozen);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "showReadme", repository.showReadme);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSizeCalculation", repository.skipSizeCalculation);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSummaryMetrics", repository.skipSummaryMetrics);\r
+               config.setString(Constants.CONFIG_GITBLIT, null, "federationStrategy",\r
                                repository.federationStrategy.name());\r
-               config.setBoolean("gitblit", null, "isFederated", repository.isFederated);\r
+               config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFederated", repository.isFederated);\r
 \r
                updateList(config, "federationSets", repository.federationSets);\r
                updateList(config, "preReceiveScript", repository.preReceiveScripts);\r
@@ -1111,8 +1111,18 @@ public class GitBlit implements ServletContextListener {
                updateList(config, "indexBranch", repository.indexedBranches);\r
                \r
                // User Defined Properties\r
-               for (Entry<String, String> singleProperty : repository.customFields.entrySet()) {\r
-                       config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, singleProperty.getKey(), singleProperty.getValue());\r
+               if (repository.customFields != null) {\r
+                       if (repository.customFields.size() == 0) {\r
+                               // clear section\r
+                               config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);\r
+                       } else {\r
+                               for (Entry<String, String> property : repository.customFields.entrySet()) {\r
+                                       // set field\r
+                                       String key = property.getKey();\r
+                                       String value = property.getValue();\r
+                                       config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, key, value);\r
+                               }\r
+                       }\r
                }\r
 \r
                try {\r
@@ -1129,9 +1139,9 @@ public class GitBlit implements ServletContextListener {
                        return;\r
                }\r
                if (ArrayUtils.isEmpty(list)) {\r
-                       config.unset("gitblit", null, field);\r
+                       config.unset(Constants.CONFIG_GITBLIT, null, field);\r
                } else {\r
-                       config.setStringList("gitblit", null, field, list);\r
+                       config.setStringList(Constants.CONFIG_GITBLIT, null, field, list);\r
                }\r
        }\r
 \r
index 3596c333a66d55bf23bb590803df0dc74333b51a..d49cb434ab3aca8226f9a957ce4cf5ea6172c931 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2012 John Crygier
+ * Copyright 2012 gitblit.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.gitblit.tests;
 
 import static org.junit.Assert.assertEquals;
@@ -17,28 +33,17 @@ import com.gitblit.utils.JGitUtils;
 
 public class RepositoryModelTest {
        
-       private static String oldSection;
-       private static String oldSubSection;
        private static boolean wasStarted = false;
        
        @BeforeClass
        public static void startGitBlit() throws Exception {
                wasStarted = GitBlitSuite.startGitblit() == false;
-               
-               oldSection = Constants.CUSTOM_FIELDS_PROP_SECTION;
-               oldSubSection = Constants.CUSTOM_FIELDS_PROP_SUBSECTION;
-               
-               Constants.CUSTOM_FIELDS_PROP_SECTION = "RepositoryModelTest";
-               Constants.CUSTOM_FIELDS_PROP_SUBSECTION = "RepositoryModelTestSubSection";
        }
        
        @AfterClass
        public static void stopGitBlit() throws Exception {
                if (wasStarted == false)
                        GitBlitSuite.stopGitblit();
-               
-               Constants.CUSTOM_FIELDS_PROP_SECTION = oldSection;
-               Constants.CUSTOM_FIELDS_PROP_SUBSECTION = oldSubSection;
        }
        
        @Before
@@ -46,9 +51,9 @@ public class RepositoryModelTest {
                Repository r = GitBlitSuite.getHelloworldRepository();
                StoredConfig config = JGitUtils.readConfig(r);
                
-               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.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
+               config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "commitMessageRegEx", "\\d");
+               config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "anotherProperty", "Hello");
                
                config.save();
        }
@@ -58,7 +63,7 @@ public class RepositoryModelTest {
                Repository r = GitBlitSuite.getHelloworldRepository();
                StoredConfig config = JGitUtils.readConfig(r);
                
-               config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION);
+               config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
                config.save();
        }