]> source.dussan.org Git - gitblit.git/commitdiff
Support hot-reloading of project.mkd
authorJames Moger <james.moger@gitblit.com>
Wed, 3 Jul 2013 12:16:39 +0000 (08:16 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 3 Jul 2013 12:16:39 +0000 (08:16 -0400)
build.xml
src/main/distrib/data/git/project.mkd [new file with mode: 0644]
src/main/java/com/gitblit/GitBlit.java

index 6138c20d4c983c1a43296d536de9e0ff16965f0d..93fa00574b81a12b0285477b9fa30ddd9bbbddc5 100644 (file)
--- a/build.xml
+++ b/build.xml
                                        <include name="gitblit.properties" />                                   \r
                                </fileset>\r
                        </copy>\r
+                       <mkdir dir="@{toDir}/git" />\r
+                       <copy todir="@{toDir}/git" overwrite="false">\r
+                               <fileset dir="${project.distrib.dir}/data/git">\r
+                                       <include name="project.mkd" />\r
+                               </fileset>\r
+                       </copy>\r
                        <mkdir dir="@{toDir}/groovy" />\r
                        <copy todir="@{toDir}/groovy">\r
                                <fileset dir="${project.distrib.dir}/data/groovy">                                      \r
diff --git a/src/main/distrib/data/git/project.mkd b/src/main/distrib/data/git/project.mkd
new file mode 100644 (file)
index 0000000..851b57a
--- /dev/null
@@ -0,0 +1,12 @@
+This project contains all repositories created directly in the root of *git.repositoriesFolder*.\r
+\r
+This message is stored in *git.repositoriesFolder*/**project.mkd**\r
+\r
+#### Other Projects\r
+\r
+Each project, or repository group, may specify it's own message by defining a **project.mkd** file in the project folder.\r
+\r
+<pre>\r
+<i>git.repositoriesFolder</i>/projecta/<b>project.mkd</b>\r
+<i>git.repositoriesFolder</i>/projectb/<b>project.mkd</b>\r
+</pre>\r
index 1fd52f1a6e120e063c712fa707551eddd33d04e3..ca21717c07263aac4c3d3962ddb0bb85f9dd91d5 100644 (file)
@@ -1697,6 +1697,30 @@ public class GitBlit implements ServletContextListener {
                return count;
        }
        
+       private void reloadProjectMarkdown(ProjectModel project) {
+               // project markdown
+               File pmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : project.name) + "/project.mkd");
+               if (pmkd.exists()) {
+                       Date lm = new Date(pmkd.lastModified());
+                       if (!projectMarkdownCache.hasCurrent(project.name, lm)) {
+                               String mkd = com.gitblit.utils.FileUtils.readContent(pmkd,  "\n");
+                               projectMarkdownCache.updateObject(project.name, lm, mkd);
+                       }
+                       project.projectMarkdown = projectMarkdownCache.getObject(project.name);
+               }
+               
+               // project repositories markdown
+               File rmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : project.name) + "/repositories.mkd");
+               if (rmkd.exists()) {
+                       Date lm = new Date(rmkd.lastModified());
+                       if (!projectRepositoriesMarkdownCache.hasCurrent(project.name, lm)) {
+                               String mkd = com.gitblit.utils.FileUtils.readContent(rmkd,  "\n");
+                               projectRepositoriesMarkdownCache.updateObject(project.name, lm, mkd);
+                       }
+                       project.repositoriesMarkdown = projectRepositoriesMarkdownCache.getObject(project.name);
+               }
+       }
+       
        
        /**
         * Returns the map of project config.  This map is cached and reloaded if
@@ -1731,27 +1755,7 @@ public class GitBlit implements ServletContextListener {
                                project.title = projectConfigs.getString("project", name, "title");
                                project.description = projectConfigs.getString("project", name, "description");
                                
-                               // project markdown
-                               File pmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : name) + "/project.mkd");
-                               if (pmkd.exists()) {
-                                       Date lm = new Date(pmkd.lastModified());
-                                       if (!projectMarkdownCache.hasCurrent(name, lm)) {
-                                               String mkd = com.gitblit.utils.FileUtils.readContent(pmkd,  "\n");
-                                               projectMarkdownCache.updateObject(name, lm, mkd);
-                                       }
-                                       project.projectMarkdown = projectMarkdownCache.getObject(name);
-                               }
-                               
-                               // project repositories markdown
-                               File rmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : name) + "/repositories.mkd");
-                               if (rmkd.exists()) {
-                                       Date lm = new Date(rmkd.lastModified());
-                                       if (!projectRepositoriesMarkdownCache.hasCurrent(name, lm)) {
-                                               String mkd = com.gitblit.utils.FileUtils.readContent(rmkd,  "\n");
-                                               projectRepositoriesMarkdownCache.updateObject(name, lm, mkd);
-                                       }
-                                       project.repositoriesMarkdown = projectRepositoriesMarkdownCache.getObject(name);
-                               }
+                               reloadProjectMarkdown(project);
                                
                                configs.put(name.toLowerCase(), project);
                        }
@@ -1873,6 +1877,8 @@ public class GitBlit implements ServletContextListener {
                        // no repositories == no project
                        return null;
                }
+               
+               reloadProjectMarkdown(project);
                return project;
        }