Browse Source

Adopt chain-loading properties as the default setup

tags/v1.7.0
James Moger 9 years ago
parent
commit
17ae31a20e

+ 8
- 8
build.xml View File

@@ -82,10 +82,9 @@
<fileset dir="${project.distrib.dir}/data" />
</copy>
<!-- copy gitblit.properties to the source directory.
this file is only used for parsing setting descriptions. -->
<copy tofile="${project.src.dir}/reference.properties" overwrite="true"
file="${project.distrib.dir}/data/gitblit.properties" />
<!-- copy defaults.properties to the source directory -->
<copy tofile="${project.src.dir}/defaults.properties" overwrite="true"
file="${project.distrib.dir}/data/defaults.properties" />
<!-- copy clientapps.json to the source directory.
this file is only used if a local file is not provided. -->
@@ -102,8 +101,8 @@
-->
<target name="compile" depends="setup" description="compiles Gitblit from source">
<!-- Generate the Keys class from the properties file -->
<mx:keys propertiesfile="${project.distrib.dir}/data/gitblit.properties"
<!-- Generate the Keys class from the defaults.properties file -->
<mx:keys propertiesfile="${project.distrib.dir}/data/defaults.properties"
outputclass="com.gitblit.Keys"
todir="${project.src.dir}" />
@@ -597,7 +596,7 @@
<replace token="%GCURL%" value="${gc.url}" />
<properties token="%PROPERTIES%" file="${project.distrib.dir}/data/gitblit.properties" />
<properties token="%PROPERTIES%" file="${project.distrib.dir}/data/defaults.properties" />
<regex searchPattern="\b(issue)(\s*[#]?|-){0,1}(\d+)\b" replacePattern="&lt;a href='http://code.google.com/p/gitblit/issues/detail?id=$3'&gt;issue $3&lt;/a&gt;" />
<regex searchPattern="\b(pr|pull request)(\s*[#]?|-){0,1}(\d+)\b" replacePattern="&lt;a href='https://github.com/gitblit/gitblit/pull/$3'&gt;pull request #$3&lt;/a&gt;" />
@@ -898,7 +897,7 @@
</menu>
</structure>
<properties token="%PROPERTIES%" file="${project.distrib.dir}/data/gitblit.properties" />
<properties token="%PROPERTIES%" file="${project.distrib.dir}/data/defaults.properties" />
<regex searchPattern="\b(issue)(\s*[#]?|-){0,1}(\d+)\b" replacePattern="&lt;a href='http://code.google.com/p/gitblit/issues/detail?id=$3'&gt;issue $3&lt;/a&gt;" />
<regex searchPattern="\b(pr|pull request)(\s*[#]?|-){0,1}(\d+)\b" replacePattern="&lt;a href='https://github.com/gitblit/gitblit/pull/$3'&gt;pull request #$3&lt;/a&gt;" />
@@ -938,6 +937,7 @@
<fileset dir="${project.distrib.dir}/data">
<include name="users.conf" />
<include name="projects.conf" />
<include name="defaults.properties" />
<include name="gitblit.properties" />
</fileset>
</copy>

+ 8
- 1
releases.moxie View File

@@ -7,15 +7,22 @@ r26: {
date: ${project.buildDate}
note: ~
html: ~
text: ~
text: ''
The new gitblit.properties file "includes" defaults.properties which is the original
gitblit.properties file. You may continue using your existing gitblit.properties file
as before, however, you might find future upgrades simpler by adopting the new "include"
design.
''
security: ~
fixes: ~
changes:
- Replaced Dagger with Guice (ticket-80)
- Use release name as root directory in Gitblit GO artifacts (ticket-109)
- Split gitblit.properties into gitblit.properties & defaults.properties (ticket-110)
- Show team type in teams page (pr-217, ticket-168)
additions:
- Add GitHub Octicons (ticket-106)
- Support for chain-loading properties files (ticket-110)
- Add Priority & Severity fields for tickets (pr-220, ticket-157)
- Add Maintenance ticket type (pr-223, ticket-206)
dependencyChanges:

+ 1893
- 0
src/main/distrib/data/defaults.properties
File diff suppressed because it is too large
View File


+ 11
- 1881
src/main/distrib/data/gitblit.properties
File diff suppressed because it is too large
View File


+ 1
- 0
src/main/java/.gitignore View File

@@ -1 +1,2 @@
/clientapps.json
/defaults.properties

+ 19
- 11
src/main/java/com/gitblit/FileSettings.java View File

@@ -80,6 +80,7 @@ public class FileSettings extends IStoredSettings {
if (propertiesFile != null && propertiesFile.exists() && (forceReload || (propertiesFile.lastModified() > lastModified))) {
FileInputStream is = null;
try {
logger.debug("loading {}", propertiesFile);
Properties props = new Properties();
is = new FileInputStream(propertiesFile);
props.load(is);
@@ -124,9 +125,13 @@ public class FileSettings extends IStoredSettings {
if (!StringUtils.isEmpty(include)) {
// allow for multiples
List<String> names = StringUtils.getStringsFromValue(include, " ");
List<String> names = StringUtils.getStringsFromValue(include, ",");
for (String name : names) {
if (StringUtils.isEmpty(name)) {
continue;
}
// try co-located
File file = new File(propertiesFile.getParentFile(), name.trim());
if (!file.exists()) {
@@ -134,17 +139,20 @@ public class FileSettings extends IStoredSettings {
file = new File(name.trim());
}
if (file.exists()) {
// load properties
try (FileInputStream iis = new FileInputStream(file)) {
baseProperties.load(iis);
}
// read nested includes
baseProperties = readIncludes(baseProperties);
if (!file.exists()) {
logger.warn("failed to locate {}", file);
continue;
}
// load properties
logger.debug("loading {}", file);
try (FileInputStream iis = new FileInputStream(file)) {
baseProperties.load(iis);
}
// read nested includes
baseProperties = readIncludes(baseProperties);
}
}
@@ -163,7 +171,7 @@ public class FileSettings extends IStoredSettings {
String content = FileUtils.readContent(propertiesFile, "\n");
for (String key : removals) {
String regex = "(?m)^(" + regExEscape(key) + "\\s*+=\\s*+)"
+ "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
+ "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
content = content.replaceAll(regex, "");
}
removals.clear();
@@ -183,7 +191,7 @@ public class FileSettings extends IStoredSettings {
String content = FileUtils.readContent(propertiesFile, "\n");
for (Map.Entry<String, String> setting:settings.entrySet()) {
String regex = "(?m)^(" + regExEscape(setting.getKey()) + "\\s*+=\\s*+)"
+ "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
+ "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
String oldContent = content;
content = content.replaceAll(regex, setting.getKey() + " = " + setting.getValue());
if (content.equals(oldContent)) {

+ 4
- 5
src/main/java/com/gitblit/manager/GitblitManager.java View File

@@ -77,7 +77,6 @@ import com.gitblit.tickets.ITicketService;
import com.gitblit.transport.ssh.IPublicKeyManager;
import com.gitblit.transport.ssh.SshKey;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.HttpUtils;
import com.gitblit.utils.JsonUtils;
import com.gitblit.utils.ObjectCache;
import com.gitblit.utils.StringUtils;
@@ -88,8 +87,8 @@ import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import com.google.inject.Provider;
import com.google.inject.Singleton;

/**
* GitblitManager is an aggregate interface delegate. It implements all the manager
@@ -441,7 +440,7 @@ public class GitblitManager implements IGitblit {
// Read bundled Gitblit properties to extract setting descriptions.
// This copy is pristine and only used for populating the setting
// models map.
InputStream is = GitblitManager.class.getResourceAsStream("/reference.properties");
InputStream is = GitblitManager.class.getResourceAsStream("/defaults.properties");
BufferedReader propertiesReader = new BufferedReader(new InputStreamReader(is));
StringBuilder description = new StringBuilder();
SettingModel setting = new SettingModel();
@@ -486,9 +485,9 @@ public class GitblitManager implements IGitblit {
}
propertiesReader.close();
} catch (NullPointerException e) {
logger.error("Failed to find resource copy of gitblit.properties");
logger.error("Failed to find classpath resource 'defaults.properties'");
} catch (IOException e) {
logger.error("Failed to load resource copy of gitblit.properties");
logger.error("Failed to load classpath resource 'defaults.properties'");
}
}


+ 7
- 2
src/site/setup_go.mkd View File

@@ -1,7 +1,7 @@
## Gitblit GO Installation & Setup
1. Download and unzip Gitblit GO [${project.releaseVersion} (Windows)](%GCURL%gitblit-${project.releaseVersion}.zip) or [${project.releaseVersion} (Linux/OSX)](%GCURL%gitblit-${project.releaseVersion}.tar.gz).
*Its best to eliminate spaces in the path name.*
*It is best to eliminate spaces in the path name.*
2. The server itself is configured through a simple text file.
Open `data/gitblit.properties` in your favorite text editor and make sure to review and set:
- *server.httpPort* and *server.httpsPort*
@@ -9,7 +9,7 @@ Open `data/gitblit.properties` in your favorite text editor and make sure to rev
**https** is strongly recommended because passwords are insecurely transmitted form your browser/git client using Basic authentication!
- *git.packedGitLimit* (set larger than the size of your largest repository)
3. Execute `authority.cmd` or `java -cp gitblit.jar com.gitblit.authority.Launcher --baseFolder data` from a command-line
**NOTE:** The Authority is a Swing GUI application. Use of this tool is not required as Gitblit GO will startup and create SSL certificates itself, BUT use of this tool allows you to control the identification metadata used in the generated certificates. Skipping this step will result in certificates with default metadata.
**NOTE:** The Authority is a Swing GUI application. Use of this tool is not required as Gitblit GO will startup and create SSL certificates itself, BUT use of this tool allows you to control the identification metadata used in the generated self-signed certificates. Skipping this step will result in certificates with default metadata.
1. fill out the fields in the *new certificate defaults* dialog
2. enter the store password used in *server.storePassword* when prompted. This generates an SSL certificate for **localhost**.
3. you may want to generate an SSL certificate for the hostname or ip address hostnames you are serving from
@@ -30,6 +30,11 @@ If you are deploying Gitblit to a *nix platform, you might consider moving the d
You can specify `GITBLIT_HOME` either as an environment variable or as a `-DGITBLIT_HOME` JVM system property.
### Including Other Properties
SINCE 1.7.0
Gitblit supports loading it's settings from multiple properties files. You can achieve this using the `include=filename` key. This setting supports loading multiple files using a *comma* as the delimiter. They are processed in the order defined and they may be nested (i.e. your included properties may include properties, etc, etc).
### Creating your own Self-Signed SSL Certificate
Gitblit GO (and Gitblit Certificate Authority) automatically generates a Certificate Authority (CA) certificate and an ssl certificate signed by this CA certificate that is bound to *localhost*.

+ 5
- 0
src/site/setup_war.mkd View File

@@ -31,3 +31,8 @@ This is a better way to configure your *baseFolder* because it survives WAR rede
1. Open TOMCAT_HOME/conf/context.xml
2. Insert an *Environment* node within the *Context* node.<pre>&lt;Environment name="baseFolder" type="java.lang.String" value="c:/projects/git/gitblit/data" override="false" /&gt;</pre>
### Including Other Properties
SINCE 1.7.0
Gitblit supports loading it's settings from multiple properties files. You can achieve this using the `include=filename` key. This setting supports loading multiple files using a *comma* as the delimiter. They are processed in the order defined and they may be nested (i.e. your included properties may include properties, etc, etc).

+ 14
- 0
src/site/upgrade_go.mkd View File

@@ -1,3 +1,17 @@
## Upgrading Gitblit GO (1.7.0+)
The default `gitblit.properties` file has been split into two files: `gitblit.properties`, which is the recommended file for setting your configuration, and `defaults.properties` which are Gitblit's default settings.
# Include Gitblit's 'defaults.properties' within your configuration.
#
# COMMA-DELIMITED
# SINCE 1.7.0
include = defaults.properties
Notice that the default settings are *included* by your `gitblit.properties` file. The disadvantage to this approach is you must flip between discovering/reading the settings in `defaults.properties` and setting them in `gitblit.properties`, but there are some clear advantages too. This setup is not required. You may continue to keep all your settings in `gitblit.properties` like before.
Additionally you may find it useful if you are maintaining several Gitblit instances to share common properties files.
## Upgrading Gitblit GO (1.2.1+)
1. Unzip Gitblit GO to a new folder

+ 18
- 5
src/site/upgrade_war.mkd View File

@@ -1,3 +1,21 @@
## Upgrading Gitblit WAR (1.7.0+)
The default `gitblit.properties` file has been split into two files: `gitblit.properties`, which is the recommended file for setting your configuration, and `defaults.properties` which are Gitblit's default settings.
# Include Gitblit's 'defaults.properties' within your configuration.
#
# COMMA-DELIMITED
# SINCE 1.7.0
include = defaults.properties
Notice that the default settings are *included* by your `gitblit.properties` file. The disadvantage to this approach is you must flip between discovering/reading the settings in `defaults.properties` and setting them in `gitblit.properties`, but there are some clear advantages too. This setup is not required. You may continue to keep all your settings in `gitblit.properties` like before.
Additionally you may find it useful if you are maintaining several Gitblit instances to share common properties files.
## Upgrading Gitblit WAR (1.4.0+)
The *baseFolder* context parameter has been replaced with a *baseFolder* JNDI env-entry. This means you can define the *baseFolder* from the administrative console of your servlet container and not have to manipulate anything in the web.xml file.
## Upgrading Gitblit WAR (1.2.1+)
1. Make sure your `WEB-INF/web.xml` *baseFolder* context parameter is not `${contextFolder}/WEB-INF/data`!
If it is, move your `WEB-INF/data` folder to a location writeable by your servlet container.
@@ -5,7 +23,6 @@ If it is, move your `WEB-INF/data` folder to a location writeable by your servle
3. Edit the new WAR's `WEB-INF/web.xml` file and set the *baseFolder* context parameter to your external baseFolder.
4. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `${baseFolder}/gitblit.properties`.
## Upgrading Gitblit WAR (pre-1.2.1)
1. Create a `data` as outlined in step 1 of *Upgrading Gitblit GO (pre-1.2.1)*
@@ -14,7 +31,3 @@ If it is, move your `WEB-INF/data` folder to a location writeable by your servle
4. Copy the new WAR's `WEB-INF/data/gitblit.properties` file to your data folder
5. Manually apply any changes you made to your original web.xml file to the gitblit.properties file you copied to your data folder
6. Edit the new WAR's `WEB-INF/web.xml` file and set the *baseFolder* context parameter to your external baseFolder.
## Upgrading Gitblit WAR (1.4.0+)
The *baseFolder* context parameter has been replaced with a *baseFolder* JNDI env-entry. This means you can define the *baseFolder* from the administrative console of your servlet container and not have to manipulate anything in the web.xml file.

Loading…
Cancel
Save