summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit
diff options
context:
space:
mode:
authorFlorian Zschocke <florian.zschocke@cycos.com>2013-08-21 14:30:01 +0200
committerFlorian Zschocke <florian.zschocke@cycos.com>2013-08-21 14:30:01 +0200
commitacb5bdf953e4242c175b22b4ddd2197079ee6ace (patch)
tree73e76da906db3333e643bb5ee84b66a82d147178 /src/main/java/com/gitblit
parente05f2266e8f11d22efe13e0588efc5c7f8268cd1 (diff)
downloadgitblit-acb5bdf953e4242c175b22b4ddd2197079ee6ace.tar.gz
gitblit-acb5bdf953e4242c175b22b4ddd2197079ee6ace.zip
Maintain repository 'description' file.
Make use of the 'description' file in Git repositories which is used by tools like gitweb or cgit and often by standard hooks. Update the file when changing the description and initialize the Gitblit description from the file when Gitblit reads a new, existing repository.
Diffstat (limited to 'src/main/java/com/gitblit')
-rw-r--r--src/main/java/com/gitblit/GitBlit.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index e47c4c69..5512296f 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -2021,6 +2021,14 @@ public class GitBlit implements ServletContextListener {
boolean hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
if (config != null) {
+ // Initialize description from description file
+ if (getConfig(config,"description", null) == null) {
+ File descFile = new File(r.getDirectory(), "description");
+ if (descFile.exists()) {
+ config.setString(Constants.CONFIG_GITBLIT, null, "description",
+ com.gitblit.utils.FileUtils.readContent(descFile, System.getProperty("line.separator")));
+ }
+ }
model.description = getConfig(config, "description", "");
model.originRepository = getConfig(config, "originRepository", null);
model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
@@ -2521,6 +2529,15 @@ public class GitBlit implements ServletContextListener {
// update settings
if (r != null) {
updateConfiguration(r, repository);
+ // Update the description file
+ File descFile = new File(r.getDirectory(), "description");
+ if (repository.description != null)
+ {
+ com.gitblit.utils.FileUtils.writeContent(descFile, repository.description);
+ }
+ else if (descFile.exists() && !descFile.isDirectory()) {
+ descFile.delete();
+ }
// only update symbolic head if it changes
String currentRef = JGitUtils.getHEADRef(r);
if (!StringUtils.isEmpty(repository.HEAD) && !repository.HEAD.equals(currentRef)) {