From cca55e4722fa1ceba8a0933dda974162635f3955 Mon Sep 17 00:00:00 2001 From: John Crygier Date: Thu, 3 May 2012 11:48:16 -0500 Subject: [PATCH] Ability to get / set "custom" properties within a RepositoryModel. This makes getting specialized settings in hooks much easier. --- src/com/gitblit/models/RepositoryModel.java | 43 +++++++++ tests/com/gitblit/tests/GitBlitSuite.java | 2 +- .../gitblit/tests/RepositoryModelTest.java | 87 +++++++++++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 tests/com/gitblit/tests/RepositoryModelTest.java diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java index 324f7d47..fd35f36f 100644 --- a/src/com/gitblit/models/RepositoryModel.java +++ b/src/com/gitblit/models/RepositoryModel.java @@ -20,9 +20,16 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.StoredConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.FederationStrategy; +import com.gitblit.GitBlit; import com.gitblit.utils.ArrayUtils; +import com.gitblit.utils.JGitUtils; import com.gitblit.utils.StringUtils; /** @@ -35,6 +42,11 @@ import com.gitblit.utils.StringUtils; public class RepositoryModel implements Serializable, Comparable { private static final long serialVersionUID = 1L; + + public static String CUSTOM_DEFINED_PROP_SECTION = "gitblit"; + public static String CUSTOM_DEFINED_PROP_SUBSECTION = "customDefinedProperties"; + + private final Logger logger = LoggerFactory.getLogger(RepositoryModel.class); // field names are reflectively mapped in EditRepository page public String name; @@ -91,6 +103,37 @@ public class RepositoryModel implements Serializable, Comparable