]> source.dussan.org Git - gitblit.git/commitdiff
Support --baseFolder parameter and small data reorganization
authorJames Moger <james.moger@gitblit.com>
Wed, 16 Jan 2013 03:17:08 +0000 (22:17 -0500)
committerJames Moger <james.moger@gitblit.com>
Wed, 16 Jan 2013 03:41:20 +0000 (22:41 -0500)
49 files changed:
.gitignore
build.xml
distrib/authority.cmd
distrib/gitblit
distrib/gitblit-centos
distrib/gitblit-stop.cmd
distrib/gitblit-ubuntu
distrib/gitblit.cmd
distrib/gitblit.properties
distrib/groovy/.gitignore [new file with mode: 0644]
distrib/groovy/blockpush.groovy [new file with mode: 0644]
distrib/groovy/jenkins.groovy [new file with mode: 0644]
distrib/groovy/localclone.groovy [new file with mode: 0644]
distrib/groovy/protect-refs.groovy [new file with mode: 0644]
distrib/groovy/sendmail-html.groovy [new file with mode: 0644]
distrib/groovy/sendmail.groovy [new file with mode: 0644]
distrib/groovy/thebuggenie.groovy [new file with mode: 0644]
distrib/installService.cmd
distrib/projects.conf [new file with mode: 0644]
docs/01_setup.mkd
docs/04_releases.mkd
groovy/.gitignore [deleted file]
groovy/blockpush.groovy [deleted file]
groovy/jenkins.groovy [deleted file]
groovy/localclone.groovy [deleted file]
groovy/protect-refs.groovy [deleted file]
groovy/sendmail-html.groovy [deleted file]
groovy/sendmail.groovy [deleted file]
groovy/thebuggenie.groovy [deleted file]
src/WEB-INF/web.xml
src/com/gitblit/Constants.java
src/com/gitblit/FederationClient.java
src/com/gitblit/GitBlit.java
src/com/gitblit/GitBlitServer.java
src/com/gitblit/GitServlet.java
src/com/gitblit/GitblitUserService.java
src/com/gitblit/LdapUserService.java
src/com/gitblit/RedmineUserService.java
src/com/gitblit/RobotsTxtServlet.java
src/com/gitblit/authority/GitblitAuthority.java
src/com/gitblit/build/Build.java
src/com/gitblit/build/BuildWebXml.java
src/com/gitblit/utils/FileUtils.java
src/com/gitblit/wicket/pages/ChangePasswordPage.java
src/com/gitblit/wicket/pages/EditUserPage.java
src/com/gitblit/wicket/pages/RepositoriesPage.java
test-gitblit.properties
tests/com/gitblit/tests/GitBlitSuite.java
tests/com/gitblit/tests/GitBlitTest.java

index e335123e7e569867a572592e14e52df85a442792..65b74abc08568c5ac2e656b4b114c41bd718ddb6 100644 (file)
@@ -31,4 +31,5 @@
 /deploy\r
 /*.jks\r
 /x509test\r
-/certs
\ No newline at end of file
+/certs
+/data
index 200fc91c107451db5da3c7c18d76a94b2e5fce3d..4a4633c32476664a591790cefbaf23e8e8032a5e 100644 (file)
--- a/build.xml
+++ b/build.xml
        <property name="project.jar" value="gitblit.jar" />\r
        <property name="project.mainclass" value="com.gitblit.Launcher" />\r
        <property name="project.build.dir" value="${basedir}/build" />\r
-       <property name="project.deploy.dir" value="${basedir}/deploy" />\r
+       <property name="project.deploy.dir" value="${basedir}/deploy" />        \r
        <property name="project.war.dir" value="${basedir}/war" />\r
        <property name="project.jar.dir" value="${basedir}/jar" />\r
-       <property name="project.site.dir" value="${basedir}/site" />\r
+       <property name="project.site.dir" value="${basedir}/target/site" />\r
+       <property name="project.target.dir" value="${basedir}/target" />\r
        <property name="project.resources.dir" value="${basedir}/resources" />  \r
        <property name="project.express.dir" value="${basedir}/express" />\r
        <property name="project.maven.repo.url" value="enter here your Maven repo URL" />\r
        -->\r
        <target name="compile" depends="buildinfo" description="Retrieves dependencies and compiles Gitblit from source">\r
 \r
-               <!-- copy required distribution files to project folder -->\r
-               <copy todir="${basedir}" overwrite="false">\r
+               <!-- cleanup old builds -->\r
+               <delete dir="${project.target.dir}" />\r
+               <mkdir dir="${project.target.dir}" />\r
+               \r
+               <!-- cleanup old builds -->\r
+               <delete>\r
+                       <fileset dir="${basedir}">\r
+                               <include name="*.zip" />\r
+                               <include name="*.war" />\r
+                               <include name="*.jar" />\r
+                       </fileset>\r
+               </delete>\r
+               \r
+               <!-- copy required distribution files to data folder -->\r
+               <mkdir dir="${basedir}/data" />\r
+               <copy todir="${basedir}/data" overwrite="false">\r
                        <fileset dir="${basedir}/distrib">\r
                                <include name="gitblit.properties" />\r
                                <include name="users.conf" />\r
+                               <include name="projects.conf" />\r
                        </fileset>\r
                </copy>\r
                \r
                <!-- copy required distribution files to project folder -->\r
-               <mkdir dir="${basedir}/certs" />\r
-               <copy todir="${basedir}/certs" overwrite="false">\r
+               <mkdir dir="${basedir}/data/certs" />\r
+               <copy todir="${basedir}/data/certs" overwrite="false">\r
                        <fileset dir="${basedir}/distrib">\r
                                <include name="authority.conf" />\r
                                <include name="*.tmpl" />\r
                        </fileset>\r
                </copy>\r
+               \r
+               <!-- copy required distribution files to project folder -->\r
+               <mkdir dir="${basedir}/data/groovy" />\r
+               <copy todir="${basedir}/data/groovy" overwrite="false">\r
+                       <fileset dir="${basedir}/distrib/groovy" />\r
+               </copy>\r
+               \r
+               <!-- upgrade existing workspace to data folder -->\r
+               <move todir="${basedir}/data" overwrite="true" failonerror="false">\r
+                       <fileset dir="${basedir}">\r
+                               <include name="users.conf" />\r
+                               <include name="projects.conf" />\r
+                               <include name="gitblit.properties" />\r
+                               <include name="serverKeyStore.jks" />\r
+                               <include name="serverTrustStore.jks" />\r
+                       </fileset>\r
+               </move>\r
+               <move todir="${basedir}/data/certs" overwrite="true" failonerror="false">\r
+                       <fileset dir="${basedir}/certs" />\r
+               </move>\r
+               <move todir="${basedir}/data/git" overwrite="true" failonerror="false">\r
+                       <fileset dir="${basedir}/git" />\r
+               </move>\r
+               <move todir="${basedir}/data/proposals" overwrite="true" failonerror="false">\r
+                       <fileset dir="${basedir}/proposals" />\r
+               </move>\r
+               <delete dir="${basedir}/javadoc" failonerror="false" />\r
+               <delete dir="${basedir}/site" failonerror="false" />\r
+               <delete dir="${basedir}/temp" failonerror="false" />\r
 \r
                <!-- copy gitblit.properties to the WEB-INF folder.\r
                     this file is only used for parsing setting descriptions. -->\r
                                <exclude name="federation.properties" />\r
                                <exclude name="openshift.mkd" />\r
                                <exclude name="authority.conf" />\r
+                               <exclude name="users.conf" />\r
+                               <exclude name="projects.conf" />\r
+                               <exclude name="gitblit.properties" />\r
                                <exclude name="*.tmpl" />\r
+                               <exclude name="groovy/**" />\r
                        </fileset>\r
                        <fileset dir="${basedir}">\r
                                <include name="LICENSE" />\r
                                <include name="NOTICE" />\r
                        </fileset>                      \r
                </copy>\r
-               <copy tofile="${project.deploy.dir}/authority.jar" file="${basedir}/authority-${gb.version}.jar" />\r
                \r
+               <!-- Copy the supported Groovy hook scripts -->\r
+               <mkdir dir="${project.deploy.dir}/data/groovy" />\r
+               <copy todir="${project.deploy.dir}/data/groovy">\r
+                       <fileset dir="${basedir}/distrib/groovy">\r
+                               <include name="sendmail.groovy" />\r
+                               <include name="sendmail-html.groovy" />\r
+                               <include name="jenkins.groovy" />\r
+                               <include name="protect-refs.groovy" />\r
+                       </fileset>\r
+               </copy>\r
+               \r
+               <copy tofile="${project.deploy.dir}/authority.jar" file="${project.target.dir}/authority-${gb.version}.jar" />\r
+               \r
+               <!-- Prepare the data folder -->\r
+               <mkdir dir="${project.deploy.dir}/data"/>\r
+               <copy todir="${project.deploy.dir}/data">\r
+                       <fileset dir="${basedir}/distrib">\r
+                               <include name="users.conf" />\r
+                               <include name="projects.conf" />\r
+                               <include name="gitblit.properties" />\r
+                       </fileset>\r
+               </copy>\r
+                                               \r
                <!-- Certificate templates -->\r
-               <mkdir dir="${project.deploy.dir}/certs"/>\r
-               <copy todir="${project.deploy.dir}/certs">\r
+               <mkdir dir="${project.deploy.dir}/data/certs"/>\r
+               <mkdir dir="${project.deploy.dir}/data/certs"/>\r
+               <copy todir="${project.deploy.dir}/data/certs">\r
                        <fileset dir="${basedir}/distrib">\r
                                <include name="*.tmpl" />\r
                                <include name="authority.conf" />\r
                        <param name="docs.output.dir" value="${project.deploy.dir}/docs" />\r
                </antcall>\r
                \r
-               <!-- Copy the supported Groovy hook scripts -->\r
-               <mkdir dir="${project.deploy.dir}/groovy" />\r
-               <copy todir="${project.deploy.dir}/groovy">\r
-                       <fileset dir="${basedir}/groovy">\r
-                               <include name="sendmail.groovy" />\r
-                               <include name="sendmail-html.groovy" />\r
-                               <include name="jenkins.groovy" />\r
-                               <include name="protect-refs.groovy" />\r
-                               <include name="localclone.groovy" />\r
-                       </fileset>\r
-               </copy>\r
-       \r
                <!-- Create Zip deployment -->          \r
-               <zip destfile="${distribution.zipfile}">\r
+               <zip destfile="${project.target.dir}/${distribution.zipfile}">\r
                        <fileset dir="${project.deploy.dir}">\r
                                <include name="**/*" />\r
                        </fileset>\r
 \r
                <!-- Copy web.xml and users.conf to WEB-INF -->\r
                <copy todir="${project.war.dir}/WEB-INF">\r
-                       <fileset dir="${basedir}/distrib">\r
-                               <include name="users.conf" />\r
-                       </fileset>\r
                        <fileset dir="${basedir}/src/WEB-INF">\r
                                <include name="web.xml" />\r
                        </fileset>\r
                        <param name="docs.output.dir" value="${project.war.dir}/WEB-INF/docs" />\r
                </antcall>\r
 \r
+               <!-- Copy users.conf to WEB-INF/data -->\r
+               <mkdir dir="${project.war.dir}/WEB-INF/data" />\r
+               <copy todir="${project.war.dir}/WEB-INF/data">\r
+                       <fileset dir="${basedir}/distrib">\r
+                               <include name="users.conf" />\r
+                               <include name="projects.conf" />\r
+                               <include name="gitblit.properties" />\r
+                       </fileset>\r
+               </copy>\r
+\r
                <!-- Copy the supported Groovy hook scripts -->\r
-               <mkdir dir="${project.war.dir}/WEB-INF/groovy" />\r
-               <copy todir="${project.war.dir}/WEB-INF/groovy">\r
-                       <fileset dir="${basedir}/groovy">\r
+               <mkdir dir="${project.war.dir}/WEB-INF/data/groovy" />\r
+               <copy todir="${project.war.dir}/WEB-INF/data/groovy">\r
+                       <fileset dir="${basedir}/distrib/groovy">\r
                                <include name="sendmail.groovy" />\r
                                <include name="sendmail-html.groovy" />\r
                                <include name="jenkins.groovy" />\r
                                <include name="protect-refs.groovy" />\r
-                               <include name="localclone.groovy" />\r
                        </fileset>\r
                </copy>\r
 \r
-               <!-- Build the WAR web.xml from the prototype web.xml and gitblit.properties --> \r
+               <!-- Build the WAR web.xml from the prototype web.xml --> \r
                <java classpath="${project.build.dir}" classname="com.gitblit.build.BuildWebXml">\r
                        <classpath refid="master-classpath" />\r
                        \r
                        <arg value="--destinationFile" />\r
                        <arg value="${project.war.dir}/WEB-INF/web.xml" />\r
                        \r
-                       <arg value="--propertiesFile" />\r
-                       <arg value="${basedir}/distrib/gitblit.properties" />\r
                </java>\r
 \r
                <!-- Gitblit resources -->\r
                </copy>\r
 \r
                <!-- Build the WAR file -->\r
-               <jar basedir="${project.war.dir}" destfile="${distribution.warfile}" compress="true" />\r
+               <jar basedir="${project.war.dir}" destfile="${project.target.dir}/${distribution.warfile}" compress="true" />\r
        </target>\r
 \r
        \r
        <target name="buildFederationClient" depends="compile" description="Builds the stand-alone Gitblit federation client">\r
                <echo>Building Gitblit Federation Client ${gb.version}</echo>\r
        \r
-               <genjar jarfile="fedclient.jar">\r
+               <genjar jarfile="${project.target.dir}/fedclient.jar">\r
                        <class name="com.gitblit.FederationClientLauncher" />\r
                        <resource file="${project.build.dir}/log4j.properties" />\r
                        <classfilter>\r
                </genjar>\r
                \r
                <!-- Build the federation client zip file -->\r
-               <zip destfile="${fedclient.zipfile}">\r
+               <zip destfile="${project.target.dir}/${fedclient.zipfile}">\r
                        <fileset dir="${basedir}">\r
-                               <include name="fedclient.jar" />\r
                                <include name="LICENSE" />\r
                                <include name="NOTICE" />\r
                        </fileset>\r
+                       <fileset dir="${project.target.dir}">\r
+                               <include name="fedclient.jar" />\r
+                       </fileset>\r
                        <fileset dir="${basedir}/distrib">\r
                                <include name="federation.properties" />\r
                        </fileset>\r
                </zip>\r
+               \r
+               <!-- Cleanup -->\r
+               <delete file="${project.target.dir}/fedclient.jar" />\r
        </target>\r
 \r
 \r
                <copy tofile="${deployments.root}/WEB-INF/reference.properties" \r
                        file="${basedir}/distrib/gitblit.properties"/>\r
 \r
+               <!-- Copy users.conf and gitblit.properties -->\r
+               <mkdir dir="${deployments.root}/WEB-INF/data" />\r
+               <copy todir="${deployments.root}/WEB-INF/data">\r
+                       <fileset dir="${basedir}/distrib">\r
+                               <include name="users.conf" />\r
+                               <include name="projects.conf" />\r
+                               <include name="gitblit.properties" />\r
+                       </fileset>\r
+               </copy>\r
+                                       \r
                <!-- Copy the supported Groovy hook scripts -->\r
-               <mkdir dir="${deployments.root}/WEB-INF/groovy" />\r
-               <copy todir="${deployments.root}/WEB-INF/groovy">\r
-                       <fileset dir="${basedir}/groovy">\r
+               <mkdir dir="${deployments.root}/WEB-INF/data/groovy" />\r
+               <copy todir="${deployments.root}/WEB-INF/data/groovy">\r
+                       <fileset dir="${basedir}/distrib/groovy">\r
                                <include name="sendmail.groovy" />\r
                                <include name="sendmail-html.groovy" />\r
                                <include name="jenkins.groovy" />\r
                                <exclude name="hamcrest*.jar" />\r
                                <exclude name="servlet*.jar" />\r
                                <exclude name="javax.servlet*.jar" />\r
+                               <exclude name="jsslutils*.jar" />\r
+                               <exclude name="jcalendar*.jar" />\r
                        </fileset>\r
                </copy>\r
 \r
                </jar>\r
 \r
                <!-- Build Express Zip file -->\r
-               <zip destfile="${express.zipfile}">\r
+               <zip destfile="${project.target.dir}/${express.zipfile}">\r
                        <fileset dir="${project.express.dir}" />\r
                </zip>\r
 \r
        <target name="buildManager" depends="compile" description="Builds the stand-alone Gitblit Manager">\r
                <echo>Building Gitblit Manager ${gb.version}</echo>\r
 \r
-               <genjar jarfile="manager-${gb.version}.jar">\r
+               <genjar jarfile="${project.target.dir}/manager-${gb.version}.jar">\r
                        <resource file="${basedir}/src/com/gitblit/client/splash.png" />\r
                        <resource file="${basedir}/resources/gitblt-favicon.png" />\r
                        <resource file="${basedir}/resources/gitweb-favicon.png" />\r
                </genjar>\r
 \r
                <!-- Build Manager Zip file -->\r
-               <zip destfile="${manager.zipfile}">\r
+               <zip destfile="${project.target.dir}/${manager.zipfile}">\r
                        <fileset dir="${basedir}">\r
-                               <include name="manager-${gb.version}.jar" />\r
                                <include name="LICENSE" />\r
                                <include name="NOTICE" />\r
                        </fileset>\r
+                       <fileset dir="${project.target.dir}">\r
+                               <include name="manager-${gb.version}.jar" />\r
+                       </fileset>\r
                </zip>\r
+               \r
+               <!-- Cleanup -->\r
+               <delete file="${project.target.dir}/manager-${gb.version}.jar" />\r
        </target>\r
        \r
        \r
        <target name="buildAuthority" depends="compile" description="Builds the stand-alone Gitblit Authority">\r
                <echo>Building Gitblit Authority ${gb.version}</echo>\r
 \r
-               <genjar jarfile="authority-${gb.version}.jar">\r
+               <genjar jarfile="${project.target.dir}/authority-${gb.version}.jar">\r
                        <resource file="${basedir}/src/com/gitblit/client/splash.png" />\r
                        <resource file="${basedir}/resources/gitblt-favicon.png" />\r
                        <resource file="${basedir}/resources/user_16x16.png" />\r
                </genjar>\r
 \r
                <!-- Build Authority Zip file -->\r
-               <zip destfile="${authority.zipfile}">\r
+               <zip destfile="${project.target.dir}/${authority.zipfile}">\r
                        <fileset dir="${basedir}">\r
-                               <include name="authority-${gb.version}.jar" />\r
                                <include name="LICENSE" />\r
                                <include name="NOTICE" />\r
                        </fileset>\r
-                       <zipfileset dir="${basedir}/distrib" prefix="certs">\r
+                       <fileset dir="${project.target.dir}">\r
+                               <include name="authority-${gb.version}.jar" />\r
+                       </fileset>\r
+                       <zipfileset dir="${basedir}/distrib" prefix="data/certs">\r
                                <include name="authority.conf" />\r
                                <include name="mail.tmpl" />\r
                                <include name="instructions.tmpl" />\r
                <echo>Building Gitblit API Library ${gb.version}</echo>\r
        \r
                <!-- Build API Library jar -->\r
-               <genjar jarfile="gbapi-${gb.version}.jar">\r
+               <genjar jarfile="${project.target.dir}/gbapi-${gb.version}.jar">\r
                        <class name="com.gitblit.Keys" />\r
                        <class name="com.gitblit.client.GitblitClient" />\r
                        <classpath refid="master-classpath" />\r
                </genjar>\r
                \r
                <!-- Build API sources jar -->\r
-               <zip destfile="gbapi-${gb.version}-sources.jar">\r
+               <zip destfile="${project.target.dir}/gbapi-${gb.version}-sources.jar">\r
                        <fileset dir="${basedir}/src" defaultexcludes="yes">\r
                                <include name="com/gitblit/Constants.java"/>\r
                                <include name="com/gitblit/GitBlitException.java"/>\r
                </zip>\r
                \r
                <!-- Build API JavaDoc jar -->\r
-               <javadoc destdir="${basedir}/javadoc">\r
+               <javadoc destdir="${project.target.dir}/javadoc">\r
                        <fileset dir="${basedir}/src" defaultexcludes="yes">\r
                                <include name="com/gitblit/Constants.java"/>\r
                                <include name="com/gitblit/GitBlitException.java"/>\r
                                <include name="com/gitblit/utils/**/*.java"/>                                   \r
                        </fileset>\r
                </javadoc>\r
-               <zip destfile="gbapi-${gb.version}-javadoc.jar">\r
-                       <fileset dir="${basedir}/javadoc" />\r
+               <zip destfile="${project.target.dir}/gbapi-${gb.version}-javadoc.jar">\r
+                       <fileset dir="${project.target.dir}/javadoc" />\r
                </zip>\r
                \r
                <!-- Build the API library zip file -->\r
-               <zip destfile="${gbapi.zipfile}">\r
+               <zip destfile="${project.target.dir}/${gbapi.zipfile}">\r
                        <fileset dir="${basedir}">\r
+                               <include name="LICENSE" />\r
+                               <include name="NOTICE" />\r
+                       </fileset>\r
+                       <fileset dir="${project.target.dir}">\r
                                <include name="gbapi-${gb.version}.jar" />\r
                                <include name="gbapi-${gb.version}-sources.jar" />\r
                                <include name="gbapi-${gb.version}-javadoc.jar" />\r
-                               <include name="LICENSE" />\r
-                               <include name="NOTICE" />\r
                        </fileset>\r
                        <fileset dir="${basedir}/ext">\r
                                <exclude name="src/**" />\r
                                <include name="jdom*.jar" />\r
                        </fileset>\r
                </zip>\r
+               \r
+               <!-- Cleanup -->\r
+               <delete>\r
+                       <fileset dir="${project.target.dir}">\r
+                               <include name="javadoc/**" />\r
+                               <include name="gbapi-${gb.version}.jar" />\r
+                               <include name="gbapi-${gb.version}-sources.jar" />\r
+                               <include name="gbapi-${gb.version}-javadoc.jar" />\r
+               </fileset>\r
+               </delete>\r
        </target>\r
                \r
                \r
index 145f5242f19475b6a31fcfb16d0988544c5e737b..75cb0cf79df5f47c4754ee86e0cde42296d06d3e 100644 (file)
@@ -1 +1 @@
-@java -jar authority.jar\r
+@java -jar authority.jar --baseFolder data\r
index cd1f967e3ba845446d91fd8a73520cf72a866723..6c74d547c9504c433d73c79988a0d18f80bb5c78 100644 (file)
@@ -3,6 +3,7 @@
 set -e
 
 GITBLIT_PATH=/opt/gitblit
+GITBLIT_BASE_FOLDER=/opt/gitblit/data
 GITBLIT_HTTP_PORT=0
 GITBLIT_HTTPS_PORT=8443
 source ${GITBLIT_PATH}/java-proxy-config.sh
@@ -14,13 +15,13 @@ case "$1" in
   start)
         log_action_begin_msg "Starting gitblit server"
         cd $GITBLIT_PATH
-        $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT > /dev/null &
+        $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT --baseFolder $GITBLIT_BASE_FOLDER > /dev/null &
         log_action_end_msg $?
         ;;
   stop)
         log_action_begin_msg "Stopping gitblit server"
         cd $GITBLIT_PATH
-        $JAVA $GITBLIT_PATH/gitblit.jar --stop > /dev/null &
+        $JAVA $GITBLIT_PATH/gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --stop > /dev/null &
         log_action_end_msg $?
         ;;
   force-reload|restart)
index c608097e632a50fec084c43c7c3f7561049dfecb..04c9a9b4b8a74e2f68165b44cfd436ee13777c9a 100644 (file)
@@ -6,6 +6,7 @@
 
 # change theses values (default values)
 GITBLIT_PATH=/opt/gitblit
+GITBLIT_BASE_FOLDER=/opt/gitblit/data
 GITBLIT_HTTP_PORT=0
 GITBLIT_HTTPS_PORT=8443
 source ${GITBLIT_PATH}/java-proxy-config.sh
@@ -19,7 +20,7 @@ case "$1" in
       then
       echo $"Starting gitblit server"
       cd $GITBLIT_PATH
-      $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT > /dev/null &
+      $JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT --baseFolder $GITBLIT_BASE_FOLDER > /dev/null &
       echo "."
       exit $RETVAL
     fi
@@ -30,7 +31,7 @@ case "$1" in
       then
       echo $"Stopping gitblit server"
       cd $GITBLIT_PATH
-      $JAVA $GITBLIT_PATH/gitblit.jar --stop > /dev/null &
+      $JAVA $GITBLIT_PATH/gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --stop > /dev/null &
       echo "."
       exit $RETVAL
     fi
index c139d57b78903ce1f891e230e6c2efd4094cc1a2..5820c491d468621fb6d9bc4d11d6aee6ac5a7f5f 100644 (file)
@@ -1 +1 @@
-@java -jar gitblit.jar --stop\r
+@java -jar gitblit.jar --stop --baseFolder data\r
index b047ed97804af01de6f6856c6affb142e157687c..4ff275d0d46dcbfeaf0625a6ae88e695e01f4730 100644 (file)
@@ -8,9 +8,10 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin
 
 # change theses values (default values)
 GITBLIT_PATH=/opt/gitblit
+GITBLIT_BASE_FOLDER=/opt/gitblit/data
 GITBLIT_USER="gitblit"
 source ${GITBLIT_PATH}/java-proxy-config.sh
-ARGS="-server -Xmx1024M ${JAVA_PROXY_CONFIG} -Djava.awt.headless=true -jar gitblit.jar"
+ARGS="-server -Xmx1024M ${JAVA_PROXY_CONFIG} -Djava.awt.headless=true -jar gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER"
 
 RETVAL=0
 
index ce96a797feff537a5f1836ec2862f7753bc75376..3006a6878c4282cdb2f6ca78f13a4e849c4c7eb4 100644 (file)
@@ -1 +1 @@
-@java -jar gitblit.jar\r
+@java -jar gitblit.jar --baseFolder data\r
index 758137e3253d95ae9f86055d2e6a3639edc3ffbb..f5cc19b6ac992c969beb9e613bb0951d92432bca 100644 (file)
@@ -1,4 +1,19 @@
 #\r
+# Gitblit Settings\r
+#\r
+\r
+# This settings file supports parameterization from the command-line for the\r
+# following command-line parameters:\r
+#\r
+#   --baseFolder    ${baseFolder}    SINCE 1.2.1\r
+#\r
+# Settings that support ${baseFolder} parameter substitution are indicated with the\r
+# BASEFOLDER attribute.  If the --baseFolder argument is unspecified, ${baseFolder}\r
+# and it's trailing / will be discarded from the setting value leaving a relative\r
+# path that is equivalent to pre-1.2.1 releases.\r
+#\r
+# e.g. "${baseFolder}/git" becomes "git", if --baseFolder is unspecified \r
+#\r
 # Git Servlet Settings\r
 #\r
 \r
@@ -10,7 +25,8 @@
 #\r
 # SINCE 0.5.0\r
 # RESTART REQUIRED\r
-git.repositoriesFolder = git\r
+# BASEFOLDER\r
+git.repositoriesFolder = ${baseFolder}/git\r
 \r
 # Build the available repository list at startup and cache this list for reuse.\r
 # This reduces disk io when presenting the repositories page, responding to rpcs,\r
@@ -299,14 +315,16 @@ git.packedGitMmap = false
 #\r
 # RESTART REQUIRED\r
 # SINCE 0.8.0\r
-groovy.scriptsFolder = groovy\r
+# BASEFOLDER\r
+groovy.scriptsFolder = ${baseFolder}/groovy\r
 \r
 # Specify the directory Grape uses for downloading libraries.\r
 # http://groovy.codehaus.org/Grape\r
 #\r
 # RESTART REQUIRED\r
 # SINCE 1.0.0\r
-groovy.grapeFolder = groovy/grape\r
+# BASEFOLDER\r
+groovy.grapeFolder = ${baseFolder}/groovy/grape\r
 \r
 # Scripts to execute on Pre-Receive.\r
 #\r
@@ -437,7 +455,8 @@ web.allowCookieAuthentication = true
 # Config file for storing project metadata\r
 #\r
 # SINCE 1.2.0\r
-web.projectsFile = projects.conf\r
+# BASEFOLDER\r
+web.projectsFile = ${baseFolder}/projects.conf\r
 \r
 # Either the full path to a user config file (users.conf)\r
 # OR the full path to a simple user properties file (users.properties)\r
@@ -451,7 +470,8 @@ web.projectsFile = projects.conf
 #\r
 # SINCE 0.5.0\r
 # RESTART REQUIRED\r
-realm.userService = users.conf\r
+# BASEFOLDER\r
+realm.userService = ${baseFolder}/users.conf\r
 \r
 # How to store passwords.\r
 # Valid values are plain, md5, or combined-md5.  md5 is the hash of password.\r
@@ -510,7 +530,8 @@ web.enableRpcAdministration = false
 # http://googlewebmastercentral.blogspot.com/2008/06/improving-on-robots-exclusion-protocol.html\r
 #\r
 # SINCE 1.0.0\r
-web.robots.txt = \r
+# BASEFOLDER\r
+web.robots.txt = ${baseFolder}/robots.txt\r
 \r
 # If true, the web ui layout will respond and adapt to the browser's dimensions.\r
 # if false, the web ui will use a 940px fixed-width layout.\r
@@ -609,6 +630,7 @@ web.showFederationRegistrations = false
 # Specifying "gitblit" uses the internal login message.\r
 #\r
 # SINCE 0.7.0\r
+# BASEFOLDER\r
 web.loginMessage = gitblit\r
 \r
 # This is the message displayed above the repositories table.\r
@@ -616,6 +638,7 @@ web.loginMessage = gitblit
 # Specifying "gitblit" uses the internal welcome message.\r
 #\r
 # SINCE 0.5.0\r
+# BASEFOLDER\r
 web.repositoriesMessage = gitblit\r
 \r
 # Ordered list of charsets/encodings to use when trying to display a blob.\r
@@ -925,7 +948,8 @@ federation.allowProposals = false
 # Use forward slashes even on Windows!!\r
 #\r
 # SINCE 0.6.0\r
-federation.proposalsFolder = proposals\r
+# BASEFOLDER\r
+federation.proposalsFolder = ${baseFolder}/proposals\r
 \r
 # The default pull frequency if frequency is unspecified on a registration\r
 #\r
@@ -1027,7 +1051,8 @@ realm.ldap.password = password
 #\r
 # SINCE 1.0.0\r
 # RESTART REQUIRED\r
-realm.ldap.backingUserService = users.conf\r
+# BASEFOLDER\r
+realm.ldap.backingUserService = ${baseFolder}/users.conf\r
 \r
 # Delegate team membership control to LDAP.\r
 #\r
@@ -1123,7 +1148,8 @@ realm.ldap.email = email
 # default: users.conf\r
 #\r
 # RESTART REQUIRED\r
-realm.redmine.backingUserService = users.conf\r
+# BASEFOLDER\r
+realm.redmine.backingUserService = ${baseFolder}/users.conf\r
 \r
 # URL of the Redmine.\r
 realm.redmine.url = http://example.com/redmine\r
@@ -1136,7 +1162,8 @@ realm.redmine.url = http://example.com/redmine
 #\r
 # SINCE 0.5.0\r
 # RESTART REQUIRED\r
-server.tempFolder = temp\r
+# BASEFOLDER\r
+server.tempFolder = ${baseFolder}/temp\r
 \r
 # Use Jetty NIO connectors.  If false, Jetty Socket connectors will be used.\r
 #\r
diff --git a/distrib/groovy/.gitignore b/distrib/groovy/.gitignore
new file mode 100644 (file)
index 0000000..e58dc47
--- /dev/null
@@ -0,0 +1 @@
+/grape
diff --git a/distrib/groovy/blockpush.groovy b/distrib/groovy/blockpush.groovy
new file mode 100644 (file)
index 0000000..caef330
--- /dev/null
@@ -0,0 +1,94 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import java.text.MessageFormat;\r
+\r
+import com.gitblit.GitBlit\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.UserModel\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+import com.gitblit.utils.ClientLogger\r
+\r
+/**\r
+ * Sample Gitblit Pre-Receive Hook: blockpush\r
+ * \r
+ * This script could and perhaps should be further developed to provide\r
+ * a full repository-branch permissions system similar to gitolite or gitosis.\r
+ *\r
+ * The Pre-Receive hook is executed after an incoming push has been parsed,\r
+ * validated, and objects have been written but BEFORE the refs are updated.\r
+ * This is the appropriate point to block a push for some reason.\r
+ *\r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push.  If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ * \r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ *\r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ * \r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ *\r
+ * Bound Variables:\r
+ *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
+ *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
+ *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
+ *  user                       Gitblit User                            com.gitblit.models.UserModel\r
+ *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ *     url                             Base url for Gitblit            String\r
+ *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
+ *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ *   def myCustomField = repository.customFields.myCustomField\r
+ *  \r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("blockpush hook triggered by ${user.username} for ${repository.name}: checking ${commands.size} commands")\r
+\r
+/*\r
+ * Example rejection of pushes to the master branch of example.git\r
+ */\r
+def blocked = false\r
+switch (repository.name) {\r
+       case 'ex@mple.git':\r
+               for (ReceiveCommand command : commands) {\r
+                       def updatedRef = command.refName\r
+                       if (updatedRef.equals('refs/heads/master')) {\r
+                               // to reject a command set it's result to anything other than Result.NOT_ATTEMPTED\r
+                               command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")\r
+                               blocked = true\r
+                       }\r
+               }\r
+               break\r
+\r
+       default:\r
+               break\r
+}\r
+\r
+if (blocked) {\r
+       // return false to break the push hook chain\r
+       return false\r
+}
\ No newline at end of file
diff --git a/distrib/groovy/jenkins.groovy b/distrib/groovy/jenkins.groovy
new file mode 100644 (file)
index 0000000..d76a3d6
--- /dev/null
@@ -0,0 +1,76 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: jenkins\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository.  This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push.  If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ * \r
+ * Bound Variables:\r
+ *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
+ *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
+ *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
+ *  user                       Gitblit User                            com.gitblit.models.UserModel\r
+ *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ *     url                             Base url for Gitblit            String\r
+ *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
+ *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ *   def myCustomField = repository.customFields.myCustomField\r
+ *  \r
+ */\r
+// Indicate we have started the script\r
+logger.info("jenkins hook triggered by ${user.username} for ${repository.name}")\r
+\r
+// This script requires Jenkins Git plugin 1.1.14 or later\r
+// http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/\r
+\r
+// define your jenkins url here or set groovy.jenkinsServer in \r
+// gitblit.properties or web.xml\r
+def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins')\r
+\r
+// define the trigger url\r
+def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=$url/git/$repository.name"\r
+\r
+// trigger the build\r
+new URL(triggerUrl).getContent()\r
diff --git a/distrib/groovy/localclone.groovy b/distrib/groovy/localclone.groovy
new file mode 100644 (file)
index 0000000..49b7f8b
--- /dev/null
@@ -0,0 +1,106 @@
+/*\r
+ * Copyright 2012 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import com.gitblit.utils.StringUtils\r
+import java.text.SimpleDateFormat\r
+import org.eclipse.jgit.api.CloneCommand\r
+import org.eclipse.jgit.api.Git\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.eclipse.jgit.util.FileUtils\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: localclone\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository.  This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push.  If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ *\r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ * \r
+ * Bound Variables:\r
+ *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
+ *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
+ *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
+ *  user                       Gitblit User                            com.gitblit.models.UserModel\r
+ *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ *     url                             Base url for Gitblit            String\r
+ *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
+ *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ *   def myCustomField = repository.customFields.myCustomField\r
+ *  \r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("localclone hook triggered by ${user.username} for ${repository.name}")\r
+\r
+def rootFolder = 'c:/test'\r
+def bare = false\r
+def cloneAllBranches = true\r
+def cloneBranch = 'refs/heads/master'\r
+def includeSubmodules = true\r
+\r
+def repoName = repository.name\r
+def destinationFolder = new File(rootFolder, StringUtils.stripDotGit(repoName))\r
+def srcUrl = 'file://' + new File(GitBlit.getRepositoriesFolder(), repoName).absolutePath\r
+\r
+// delete any previous clone\r
+if (destinationFolder.exists()) {\r
+       FileUtils.delete(destinationFolder, FileUtils.RECURSIVE)\r
+}\r
+\r
+// clone the repository\r
+logger.info("cloning ${srcUrl} to ${destinationFolder}")\r
+CloneCommand cmd = Git.cloneRepository();\r
+cmd.setBare(bare)\r
+if (cloneAllBranches)\r
+       cmd.setCloneAllBranches(true)\r
+else\r
+       cmd.setBranch(cloneBranch)\r
+cmd.setCloneSubmodules(includeSubmodules)\r
+cmd.setURI(srcUrl)\r
+cmd.setDirectory(destinationFolder)\r
+Git git = cmd.call();\r
+git.repository.close()\r
+\r
+// report clone operation success back to pushing Git client\r
+clientLogger.info("${repoName} cloned to ${destinationFolder}")
\ No newline at end of file
diff --git a/distrib/groovy/protect-refs.groovy b/distrib/groovy/protect-refs.groovy
new file mode 100644 (file)
index 0000000..b1b611f
--- /dev/null
@@ -0,0 +1,113 @@
+/*\r
+ * Copyright 2012 Philip L. McMahon.\r
+ *\r
+ * Derived from blockpush.groovy, copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.UserModel\r
+\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Pre-Receive Hook: protect-refs\r
+ * \r
+ * This script provides basic authorization of receive command types for a list\r
+ * of known ref patterns. Command types and unmatched ref patterns will be\r
+ * ignored, meaning this script has an "allow by default" policy.\r
+ *\r
+ * This script works best when a repository requires authentication on push, but\r
+ * can be used to enforce fast-forward commits or prohibit ref deletion by\r
+ * setting the *authorizedTeams* variable to an empty list and adding a ".+"\r
+ * entry to the *protectedRefs* list.\r
+ *\r
+ * The Pre-Receive hook is executed after an incoming push has been parsed,\r
+ * validated, and objects have been written but BEFORE the refs are updated.\r
+ * This is the appropriate point to block a push for some reason.\r
+ *\r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push.  If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ * \r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ *\r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ * \r
+ * This script may reject one or more commands, but will never return false.\r
+ * Subsequent scripts, if any, will always be invoked.\r
+ *\r
+ * Bound Variables:\r
+ *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
+ *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
+ *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
+ *  user                       Gitblit User                            com.gitblit.models.UserModel\r
+ *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ *     url                             Base url for Gitblit            String\r
+ *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
+ *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ *   def myCustomField = repository.customFields.myCustomField\r
+ *  \r
+ */\r
+\r
+// map of protected command types to returned results type\r
+// commands not included will skip authz check\r
+def protectedCmds = [\r
+       UPDATE_NONFASTFORWARD:  Result.REJECTED_NONFASTFORWARD,\r
+       DELETE:                                 Result.REJECTED_NODELETE\r
+]\r
+\r
+// list of regex patterns for protected refs\r
+def protectedRefs = [\r
+       "refs/heads/master",\r
+       "refs/tags/.+"\r
+]\r
+\r
+// teams which are authorized to perform protected commands on protected refs\r
+def authorizedTeams = [ "admins" ]\r
+\r
+for (ReceiveCommand command : commands) {\r
+       def updateType = command.type\r
+       def updatedRef = command.refName\r
+       \r
+       // find first regex which matches updated ref, if any\r
+       def refPattern = protectedRefs.find { updatedRef.matches ~it }\r
+       \r
+       // find rejection result for update type, if any\r
+       def result = protectedCmds[updateType.name()]\r
+       \r
+       // command requires authz if ref is protected and has a mapped rejection result\r
+       if (refPattern && result) {\r
+       \r
+               // verify user is a member of any authorized team\r
+               def team = authorizedTeams.find { user.isTeamMember it }\r
+               if (team) {\r
+                       // don't adjust command result\r
+                       logger.info "${user.username} authorized for ${updateType} of protected ref ${repository.name}:${updatedRef} (${command.oldId.name} -> ${command.newId.name})"\r
+               } else {\r
+                       // mark command result as rejected\r
+                       command.setResult(result, "${user.username} cannot ${updateType} protected ref ${repository.name}:${updatedRef} matching pattern ${refPattern}")\r
+               }\r
+       }\r
+}\r
diff --git a/distrib/groovy/sendmail-html.groovy b/distrib/groovy/sendmail-html.groovy
new file mode 100644 (file)
index 0000000..1692073
--- /dev/null
@@ -0,0 +1,516 @@
+/*\r
+ * Copyright 2012 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import java.text.SimpleDateFormat\r
+\r
+import org.eclipse.jgit.api.Status;\r
+import org.eclipse.jgit.api.errors.JGitInternalException;\r
+import org.eclipse.jgit.diff.DiffEntry;\r
+import org.eclipse.jgit.diff.DiffFormatter;\r
+import org.eclipse.jgit.diff.RawTextComparator;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
+import org.eclipse.jgit.lib.Constants;\r
+import org.eclipse.jgit.lib.IndexDiff;\r
+import org.eclipse.jgit.lib.ObjectId;\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.patch.FileHeader;\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.revwalk.RevWalk;\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.eclipse.jgit.treewalk.FileTreeIterator;\r
+import org.eclipse.jgit.treewalk.EmptyTreeIterator;\r
+import org.eclipse.jgit.treewalk.CanonicalTreeParser;\r
+import org.eclipse.jgit.util.io.DisabledOutputStream;\r
+import org.slf4j.Logger\r
+import groovy.xml.MarkupBuilder\r
+\r
+import java.io.IOException;\r
+import java.security.MessageDigest\r
+\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: sendmail-html\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository.  This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push.  If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ *\r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ * \r
+ * Bound Variables:\r
+ *  gitblit         Gitblit Server               com.gitblit.GitBlit\r
+ *  repository      Gitblit Repository           com.gitblit.models.RepositoryModel\r
+ *  user            Gitblit User                 com.gitblit.models.UserModel\r
+ *  commands        JGit commands                Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ *  url             Base url for Gitblit         java.lang.String\r
+ *  logger          Logs messages to Gitblit     org.slf4j.Logger\r
+ *  clientLogger    Logs messages to Git client  com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ *   def myCustomField = repository.customFields.myCustomField\r
+ *  \r
+ */\r
+\r
+com.gitblit.models.UserModel userModel = user\r
+\r
+// Indicate we have started the script\r
+logger.info("sendmail-html hook triggered by ${user.username} for ${repository.name}")\r
+\r
+/*\r
+ * Primitive email notification.\r
+ * This requires the mail settings to be properly configured in Gitblit.\r
+ */\r
+\r
+Repository r = gitblit.getRepository(repository.name)\r
+\r
+// reuse existing repository config settings, if available\r
+Config config = r.getConfig()\r
+def mailinglist = config.getString('hooks', null, 'mailinglist')\r
+def emailprefix = config.getString('hooks', null, 'emailprefix')\r
+\r
+// set default values\r
+def toAddresses = []\r
+if (emailprefix == null) {\r
+    emailprefix = '[Gitblit]'\r
+}\r
+\r
+if (mailinglist != null) {\r
+    def addrs = mailinglist.split(/(,|\s)/)\r
+    toAddresses.addAll(addrs)\r
+}\r
+\r
+// add all mailing lists defined in gitblit.properties or web.xml\r
+toAddresses.addAll(GitBlit.getStrings(Keys.mail.mailingLists))\r
+\r
+// add all team mailing lists\r
+def teams = gitblit.getRepositoryTeams(repository)\r
+for (team in teams) {\r
+    TeamModel model = gitblit.getTeamModel(team)\r
+    if (model.mailingLists) {\r
+        toAddresses.addAll(model.mailingLists)\r
+    }\r
+}\r
+\r
+// add all mailing lists for the repository\r
+toAddresses.addAll(repository.mailingLists)\r
+\r
+// define the summary and commit urls\r
+def repo = repository.name\r
+def summaryUrl = url + "/summary?r=$repo"\r
+def baseCommitUrl = url + "/commit?r=$repo&h="\r
+def baseBlobDiffUrl = url + "/blobdiff/?r=$repo&h="\r
+def baseCommitDiffUrl = url + "/commitdiff/?r=$repo&h="\r
+def forwardSlashChar = gitblit.getString(Keys.web.forwardSlashCharacter, '/')\r
+\r
+if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
+    repo = repo.replace('/', forwardSlashChar).replace('/', '%2F')\r
+    summaryUrl = url + "/summary/$repo"\r
+    baseCommitUrl = url + "/commit/$repo/"\r
+    baseBlobDiffUrl = url + "/blobdiff/$repo/"\r
+    baseCommitDiffUrl = url + "/commitdiff/$repo/"\r
+}\r
+\r
+class HtmlMailWriter {\r
+    Repository repository\r
+    def url\r
+    def baseCommitUrl\r
+    def baseCommitDiffUrl\r
+    def baseBlobDiffUrl\r
+    def mountParameters\r
+       def forwardSlashChar\r
+       def includeGravatar\r
+       def shortCommitIdLength\r
+    def commitCount = 0\r
+    def commands\r
+    def writer = new StringWriter();\r
+    def builder = new MarkupBuilder(writer)\r
+\r
+    def writeStyle() {\r
+        builder.style(type:"text/css", '''\r
+    .table td {\r
+        vertical-align: middle;\r
+    }\r
+    tr.noborder td {\r
+        border: none;\r
+        padding-top: 0px;\r
+    }\r
+    .gravatar-column {\r
+        width: 5%; \r
+    }\r
+    .author-column {\r
+        width: 20%; \r
+    }\r
+    .commit-column {\r
+        width: 5%; \r
+    }\r
+    .status-column {\r
+        width: 10%;\r
+    }\r
+    .table-disable-hover.table tbody tr:hover td,\r
+    .table-disable-hover.table tbody tr:hover th {\r
+        background-color: inherit;\r
+    }\r
+    .table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,\r
+    .table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {\r
+      background-color: #f9f9f9;\r
+    }\r
+    ''')\r
+    }\r
+\r
+    def writeBranchTitle(type, name, action, number) {\r
+        builder.div('class' : 'pageTitle') {\r
+                       builder.span('class':'project') {\r
+                               mkp.yield "$type "\r
+                               span('class': 'repository', name )\r
+                               if (number > 0) {\r
+                                       mkp.yield " $action ($number commits)"\r
+                               } else {\r
+                                       mkp.yield " $action"\r
+                               }\r
+                       }\r
+        }\r
+    }\r
+\r
+    def writeBranchDeletedTitle(type, name) {\r
+               builder.div('class' : 'pageTitle', 'style':'color:red') {\r
+                       builder.span('class':'project') {\r
+                               mkp.yield "$type "\r
+                               span('class': 'repository', name )\r
+                               mkp.yield " deleted"\r
+                       }\r
+               }\r
+    }\r
+\r
+    def commitUrl(RevCommit commit) {\r
+        "${baseCommitUrl}$commit.id.name"\r
+    }\r
+\r
+    def commitDiffUrl(RevCommit commit) {\r
+        "${baseCommitDiffUrl}$commit.id.name"\r
+    }\r
+\r
+    def encoded(String path) {\r
+        path.replace('/', forwardSlashChar).replace('/', '%2F')\r
+    }\r
+\r
+    def blobDiffUrl(objectId, path) {\r
+        if (mountParameters) {\r
+            // REST style\r
+            "${baseBlobDiffUrl}${objectId.name()}/${encoded(path)}"\r
+        } else {\r
+            "${baseBlobDiffUrl}${objectId.name()}&f=${path}"\r
+        }\r
+\r
+    }\r
+\r
+    def writeCommitTable(commits, includeChangedPaths=true) {\r
+        // Write commits table\r
+        builder.table('class':"table table-disable-hover") {\r
+            thead {\r
+                tr {\r
+                                       th(colspan: includeGravatar ? 2 : 1, "Author")\r
+                    th( "Commit" )\r
+                    th( "Message" )\r
+                }\r
+            }\r
+            tbody() {\r
+\r
+                // Write all the commits\r
+                for (commit in commits) {\r
+                    writeCommit(commit)\r
+\r
+                                       if (includeChangedPaths) {\r
+                                               // Write detail on that particular commit\r
+                                               tr('class' : 'noborder') {\r
+                                                       td (colspan: includeGravatar ? 3 : 2)\r
+                                                       td (colspan:2) { writeStatusTable(commit) }\r
+                                               }\r
+                                       }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    def writeCommit(commit) {\r
+        def abbreviated = repository.newObjectReader().abbreviate(commit.id, shortCommitIdLength).name()\r
+        def author = commit.authorIdent.name\r
+        def email = commit.authorIdent.emailAddress\r
+        def message = commit.shortMessage\r
+        builder.tr {\r
+                       if (includeGravatar) {\r
+                               td('class':"gravatar-column") {\r
+                                       img(src:gravatarUrl(email), 'class':"gravatar")\r
+                               }\r
+                       }\r
+            td('class':"author-column", author)\r
+            td('class':"commit-column") {\r
+                a(href:commitUrl(commit)) {\r
+                    span('class':"label label-info",  abbreviated )\r
+                }\r
+            }\r
+            td {\r
+                mkp.yield message\r
+                a('class':'link', href:commitDiffUrl(commit), " [commitdiff]" )\r
+            }\r
+        }\r
+    }\r
+\r
+    def writeStatusLabel(style, tooltip) {\r
+        builder.span('class' : style,  'title' : tooltip )\r
+    }\r
+\r
+    def writeAddStatusLine(ObjectId id, FileHeader header) {           \r
+        builder.td('class':'changeType') {\r
+            writeStatusLabel("addition", "addition")\r
+        }\r
+        builder.td {\r
+            a(href:blobDiffUrl(id, header.newPath), header.newPath)\r
+        }\r
+    }\r
+\r
+    def writeCopyStatusLine(ObjectId id, FileHeader header) {\r
+        builder.td('class':'changeType') {\r
+            writeStatusLabel("rename", "rename")\r
+        }\r
+        builder.td() {\r
+            a(href:blobDiffUrl(id, header.newPath), header.oldPath + " copied to " + header.newPath)\r
+        }\r
+    }\r
+\r
+    def writeDeleteStatusLine(ObjectId id, FileHeader header) {\r
+        builder.td('class':'changeType') {\r
+            writeStatusLabel("deletion", "deletion")\r
+        }\r
+        builder.td() {\r
+            a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
+        }\r
+    }\r
+\r
+    def writeModifyStatusLine(ObjectId id, FileHeader header) {\r
+        builder.td('class':'changeType') {\r
+                       writeStatusLabel("modification", "modification")\r
+        }\r
+        builder.td() {\r
+            a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
+        }\r
+    }\r
+\r
+    def writeRenameStatusLine(ObjectId id, FileHeader header) {\r
+        builder.td('class':'changeType') {\r
+             writeStatusLabel("rename", "rename")\r
+        }\r
+        builder.td() {\r
+            mkp.yield header.oldPath\r
+                       mkp.yieldUnescaped "<b> -&rt; </b>"\r
+                       a(href:blobDiffUrl(id, header.newPath),  header.newPath)\r
+        }\r
+    }\r
+\r
+    def writeStatusLine(ObjectId id, FileHeader header) {\r
+        builder.tr {\r
+            switch (header.changeType) {\r
+                case ChangeType.ADD:\r
+                    writeAddStatusLine(id, header)\r
+                    break;\r
+                case ChangeType.COPY:\r
+                    writeCopyStatusLine(id, header)\r
+                    break;\r
+                case ChangeType.DELETE:\r
+                    writeDeleteStatusLine(id, header)\r
+                    break;\r
+                case ChangeType.MODIFY:\r
+                    writeModifyStatusLine(id, header)\r
+                    break;\r
+                case ChangeType.RENAME:\r
+                    writeRenameStatusLine(id, header)\r
+                    break;\r
+            }\r
+        }\r
+    }\r
+\r
+    def writeStatusTable(RevCommit commit) {\r
+        DiffFormatter formatter = new DiffFormatter(DisabledOutputStream.INSTANCE)\r
+        formatter.setRepository(repository)\r
+        formatter.setDetectRenames(true)\r
+        formatter.setDiffComparator(RawTextComparator.DEFAULT);\r
+\r
+        def diffs\r
+               RevWalk rw = new RevWalk(repository)\r
+        if (commit.parentCount > 0) {\r
+                       RevCommit parent = rw.parseCommit(commit.parents[0].id)\r
+            diffs = formatter.scan(parent.tree, commit.tree)\r
+        } else {\r
+            diffs = formatter.scan(new EmptyTreeIterator(),\r
+                                   new CanonicalTreeParser(null, rw.objectReader, commit.tree))\r
+        }\r
+               rw.dispose()\r
+        // Write status table\r
+        builder.table('class':"plain") {\r
+            tbody() {\r
+                for (DiffEntry entry in diffs) {\r
+                    FileHeader header = formatter.toFileHeader(entry)\r
+                    writeStatusLine(commit.id, header)\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+\r
+    def md5(text) {\r
+\r
+        def digest = MessageDigest.getInstance("MD5")\r
+\r
+        //Quick MD5 of text\r
+        def hash = new BigInteger(1, digest.digest(text.getBytes()))\r
+                         .toString(16)\r
+                         .padLeft(32, "0")\r
+        hash.toString()\r
+    }\r
+\r
+    def gravatarUrl(email) {\r
+        def cleaned = email.trim().toLowerCase()\r
+        "http://www.gravatar.com/avatar/${md5(cleaned)}?s=30"\r
+    }\r
+\r
+    def writeNavbar() {\r
+        builder.div('class':"navbar navbar-fixed-top") {\r
+            div('class':"navbar-inner") {\r
+                div('class':"container") {\r
+                    a('class':"brand", href:"${url}", title:"GitBlit") {\r
+                        img(src:"${url}/gitblt_25_white.png",\r
+                            width:"79",\r
+                            height:"25",\r
+                            'class':"logo")\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    def write() {\r
+        builder.html {\r
+            head {\r
+                link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap.css")\r
+                link(rel:"stylesheet", href:"${url}/gitblit.css")\r
+                               link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap-responsive.css")\r
+                writeStyle()\r
+            }\r
+            body {\r
+\r
+                writeNavbar()\r
+\r
+                               div('class':"container") {\r
+\r
+                for (command in commands) {\r
+                    def ref = command.refName\r
+                    def refType = 'Branch'\r
+                    if (ref.startsWith('refs/heads/')) {\r
+                        ref  = command.refName.substring('refs/heads/'.length())\r
+                    } else if (ref.startsWith('refs/tags/')) {\r
+                        ref  = command.refName.substring('refs/tags/'.length())\r
+                        refType = 'Tag'\r
+                    }\r
+\r
+                    switch (command.type) {\r
+                        case ReceiveCommand.Type.CREATE:\r
+                                                       def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
+                                                       commitCount += commits.size()\r
+                                                       if (refType == 'Branch') {\r
+                                                               // new branch\r
+                                                               writeBranchTitle(refType, ref, "created", commits.size())\r
+                                                               writeCommitTable(commits, true)\r
+                                                       } else {\r
+                                                               // new tag\r
+                                                               writeBranchTitle(refType, ref, "created", 0)\r
+                                                               writeCommitTable(commits, false)\r
+                                                       }\r
+                            break\r
+                        case ReceiveCommand.Type.UPDATE:\r
+                            def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
+                            commitCount += commits.size()\r
+                            // fast-forward branch commits table\r
+                            // Write header\r
+                            writeBranchTitle(refType, ref, "updated", commits.size())\r
+                            writeCommitTable(commits)\r
+                            break\r
+                        case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
+                            def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
+                            commitCount += commits.size()\r
+                            // non-fast-forward branch commits table\r
+                            // Write header\r
+                            writeBranchTitle(refType, ref, "updated [NON fast-forward]", commits.size())\r
+                            writeCommitTable(commits)\r
+                            break\r
+                        case ReceiveCommand.Type.DELETE:\r
+                            // deleted branch/tag\r
+                            writeBranchDeletedTitle(refType, ref)\r
+                            break\r
+                        default:\r
+                            break\r
+                    }\r
+                }\r
+                }\r
+            }\r
+        }\r
+        writer.toString()\r
+    }\r
+\r
+}\r
+\r
+def mailWriter = new HtmlMailWriter()\r
+mailWriter.repository = r\r
+mailWriter.baseCommitUrl = baseCommitUrl\r
+mailWriter.baseBlobDiffUrl = baseBlobDiffUrl\r
+mailWriter.baseCommitDiffUrl = baseCommitDiffUrl\r
+mailWriter.forwardSlashChar = forwardSlashChar\r
+mailWriter.commands = commands\r
+mailWriter.url = url\r
+mailWriter.mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true)\r
+mailWriter.includeGravatar = GitBlit.getBoolean(Keys.web.allowGravatar, true)\r
+mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)\r
+\r
+def content = mailWriter.write()\r
+\r
+// close the repository reference\r
+r.close()\r
+\r
+// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
+def repositoryName = repository.name.substring(0, repository.name.length() - 4)\r
+gitblit.sendHtmlMail("${emailprefix} ${userModel.displayName} pushed ${mailWriter.commitCount} commits => $repositoryName",\r
+                     content,\r
+                     toAddresses)\r
diff --git a/distrib/groovy/sendmail.groovy b/distrib/groovy/sendmail.groovy
new file mode 100644 (file)
index 0000000..c832bc6
--- /dev/null
@@ -0,0 +1,176 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import java.text.SimpleDateFormat\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+\r
+/**\r
+ * Sample Gitblit Post-Receive Hook: sendmail\r
+ *\r
+ * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
+ * to the Git repository.  This is the appropriate point to trigger an\r
+ * integration build or to send a notification.\r
+ * \r
+ * This script is only executed when pushing to *Gitblit*, not to other Git\r
+ * tooling you may be using.\r
+ * \r
+ * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
+ * or web.xml then it will be executed by any repository when it receives a\r
+ * push.  If you choose to share your script then you may have to consider\r
+ * tailoring control-flow based on repository access restrictions.\r
+ *\r
+ * Scripts may also be specified per-repository in the repository settings page.\r
+ * Shared scripts will be excluded from this list of available scripts.\r
+ * \r
+ * This script is dynamically reloaded and it is executed within it's own\r
+ * exception handler so it will not crash another script nor crash Gitblit.\r
+ *\r
+ * If you want this hook script to fail and abort all subsequent scripts in the\r
+ * chain, "return false" at the appropriate failure points.\r
+ * \r
+ * Bound Variables:\r
+ *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
+ *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
+ *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
+ *  user                       Gitblit User                            com.gitblit.models.UserModel\r
+ *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
+ *     url                             Base url for Gitblit            String\r
+ *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
+ *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
+ *\r
+ * Accessing Gitblit Custom Fields:\r
+ *   def myCustomField = repository.customFields.myCustomField\r
+ *  \r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("sendmail hook triggered by ${user.username} for ${repository.name}")\r
+\r
+/*\r
+ * Primitive email notification.\r
+ * This requires the mail settings to be properly configured in Gitblit.\r
+ */\r
+\r
+Repository r = gitblit.getRepository(repository.name)\r
+\r
+// reuse existing repository config settings, if available\r
+Config config = r.getConfig()\r
+def mailinglist = config.getString('hooks', null, 'mailinglist')\r
+def emailprefix = config.getString('hooks', null, 'emailprefix')\r
+\r
+// set default values\r
+def toAddresses = []\r
+if (emailprefix == null)\r
+emailprefix = '[Gitblit]'\r
+\r
+if (mailinglist != null) {\r
+       def addrs = mailinglist.split(/(,|\s)/)\r
+       toAddresses.addAll(addrs)\r
+}\r
+\r
+// add all mailing lists defined in gitblit.properties or web.xml\r
+toAddresses.addAll(gitblit.getStrings(Keys.mail.mailingLists))\r
+\r
+// add all team mailing lists\r
+def teams = gitblit.getRepositoryTeams(repository)\r
+for (team in teams) {\r
+       TeamModel model = gitblit.getTeamModel(team)\r
+       if (model.mailingLists) {\r
+               toAddresses.addAll(model.mailingLists)\r
+       }\r
+}\r
+\r
+// add all mailing lists for the repository\r
+toAddresses.addAll(repository.mailingLists)\r
+\r
+// define the summary and commit urls\r
+def repo = repository.name\r
+def summaryUrl\r
+def commitUrl\r
+if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
+       repo = repo.replace('/', gitblit.getString(Keys.web.forwardSlashCharacter, '/')).replace('/', '%2F')\r
+       summaryUrl = url + "/summary/$repo"\r
+       commitUrl = url + "/commit/$repo/"\r
+} else {\r
+       summaryUrl = url + "/summary?r=$repo"\r
+       commitUrl = url + "/commit?r=$repo&h="\r
+}\r
+\r
+// construct a simple text summary of the changes contained in the push\r
+def branchBreak = '>---------------------------------------------------------------\n'\r
+def commitBreak = '\n\n ----\n'\r
+def commitCount = 0\r
+def changes = ''\r
+SimpleDateFormat df = new SimpleDateFormat(gitblit.getString(Keys.web.datetimestampLongFormat, 'EEEE, MMMM d, yyyy h:mm a z'))\r
+def table = { "\n ${JGitUtils.getDisplayName(it.authorIdent)}\n ${df.format(JGitUtils.getCommitDate(it))}\n\n $it.shortMessage\n\n $commitUrl$it.id.name" }\r
+for (command in commands) {\r
+       def ref = command.refName\r
+       def refType = 'branch'\r
+       if (ref.startsWith('refs/heads/')) {\r
+               ref  = command.refName.substring('refs/heads/'.length())\r
+       } else if (ref.startsWith('refs/tags/')) {\r
+               ref  = command.refName.substring('refs/tags/'.length())\r
+               refType = 'tag'\r
+       }\r
+               \r
+       switch (command.type) {\r
+               case ReceiveCommand.Type.CREATE:\r
+                       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+                       commitCount += commits.size()\r
+                       // new branch\r
+                       changes += "\n$branchBreak new $refType $ref created ($commits.size commits)\n$branchBreak"\r
+                       changes += commits.collect(table).join(commitBreak)\r
+                       changes += '\n'\r
+                       break\r
+               case ReceiveCommand.Type.UPDATE:\r
+                       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+                       commitCount += commits.size()\r
+                       // fast-forward branch commits table\r
+                       changes += "\n$branchBreak $ref $refType updated ($commits.size commits)\n$branchBreak"\r
+                       changes += commits.collect(table).join(commitBreak)\r
+                       changes += '\n'\r
+                       break\r
+               case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
+                       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+                       commitCount += commits.size()\r
+                       // non-fast-forward branch commits table\r
+                       changes += "\n$branchBreak $ref $refType updated [NON fast-forward] ($commits.size commits)\n$branchBreak"\r
+                       changes += commits.collect(table).join(commitBreak)\r
+                       changes += '\n'\r
+                       break\r
+               case ReceiveCommand.Type.DELETE:\r
+                       // deleted branch/tag\r
+                       changes += "\n$branchBreak $ref $refType deleted\n$branchBreak"\r
+                       break\r
+               default:\r
+                       break\r
+       }\r
+}\r
+// close the repository reference\r
+r.close()\r
+\r
+// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
+gitblit.sendMail("$emailprefix $user.username pushed $commitCount commits => $repository.name", "$summaryUrl\n$changes", toAddresses)
\ No newline at end of file
diff --git a/distrib/groovy/thebuggenie.groovy b/distrib/groovy/thebuggenie.groovy
new file mode 100644 (file)
index 0000000..b4385a2
--- /dev/null
@@ -0,0 +1,88 @@
+/*\r
+ * Copyright 2011 Wolfgang Gassler gassler.org\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+import com.gitblit.GitBlit\r
+import com.gitblit.Keys\r
+import com.gitblit.models.RepositoryModel\r
+import com.gitblit.models.TeamModel\r
+import com.gitblit.models.UserModel\r
+import com.gitblit.utils.JGitUtils\r
+import java.text.SimpleDateFormat\r
+import org.eclipse.jgit.lib.Repository\r
+import org.eclipse.jgit.lib.Config\r
+import org.eclipse.jgit.revwalk.RevCommit\r
+import org.eclipse.jgit.transport.ReceiveCommand\r
+import org.eclipse.jgit.transport.ReceiveCommand.Result\r
+import org.slf4j.Logger\r
+import org.eclipse.jgit.lib.IndexDiff\r
+import org.eclipse.jgit.lib.Constants\r
+import com.gitblit.utils.DiffUtils\r
+\r
+/**\r
+ * Gitblit Post-Receive Hook: thebuggenie\r
+ * www.thebuggenie.com\r
+ * \r
+ * Submit the commit information to thebuggenie bug tracker by calling thebuggenie client tool\r
+ *  \r
+ * Config of the Script:\r
+ * \r
+ * Setup a custom gitblit field in the proprties file of gitblit by adding the following line\r
+ *   groovy.customFields = "thebuggenieProjectId=TheBugGennie project id (used for thebuggenie hoocks)"\r
+ * This field allows to specify the project id of thebuggenie project in the edit section of gitblit\r
+ * \r
+ * Furthermore you need to set the path to thebuggenie client tool by adding the following property to\r
+ * the gitblit properties file\r
+ *   thebuggenie.tbg_cli = /var/www/thebuggenie_root/tbg_cli\r
+ */\r
+\r
+// Indicate we have started the script\r
+logger.info("thebuggenie hook triggered by ${user.username} for ${repository.name}")\r
+\r
+//fetch the repository data\r
+Repository r = gitblit.getRepository(repository.name)\r
+\r
+//get project id which is defined in the git repo metadata\r
+def tbgProjectId = repository.customFields.thebuggenieProjectId\r
+//get path to the thebuggenie client tool which is defined in the gitblit proprties files\r
+def tbgCliPath = gitblit.getString('thebuggenie.tbg_cli', '/var/www/thebuggenie/tbg_cli')\r
+def tbgCliDirPath = new File(tbgCliPath).getParent()\r
+\r
+for(command in commands) {\r
+       //fetch all pushed commits\r
+       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
+       for (commit in commits) {\r
+               //get hashes and author data of commit\r
+               def oldhash = commit.getParent(0).getId().getName()\r
+               def newhash = commit.getId().getName()\r
+               def authorIdent = commit.getAuthorIdent()\r
+               def author = "${authorIdent.name} <${authorIdent.emailAddress}>"\r
+               //fetch all changed files of the commit\r
+               def files = JGitUtils.getFilesInCommit(r,commit)\r
+               def changedFiles = ""\r
+               for (f in files) {\r
+                       //transform file data to the format which is needed by thebuggenie\r
+                       changedFiles += f.changeType.toString().substring(0,1)+"\t${f.path}\n"\r
+               }\r
+               //ok let's submit all information to thebuggenie by calling the client tool\r
+//             def shc = "$tbgCliPath vcs_integration:report_commit $tbgProjectId \"$author\" $newhash  \"${commit.fullMessage}\" \"$changedFiles\" $oldhash ${commit.commitTime}"\r
+               def shc = [tbgCliPath, "vcs_integration:report_commit", tbgProjectId, author, newhash, commit.getFullMessage(), changedFiles, oldhash, commit.getCommitTime()];\r
+               logger.info("executing in path " + tbgCliDirPath + ": "+shc)\r
+               shc.execute(null, new File(tbgCliDirPath))\r
+       }\r
+}\r
+\r
+// close the repository reference\r
+r.close()\r
index 77b641e8c92ddb98f558671f2cf4672e3e044261..d254d679a96c9bcc35911f1c76afb157f304c0bd 100644 (file)
@@ -25,12 +25,12 @@ SET ARCH=amd64
                 --StartPath="%CD%" ^\r
                 --StartClass=com.gitblit.Launcher ^\r
                 --StartMethod=main ^\r
-                --StartParams="--storePassword;gitblit" ^\r
+                --StartParams="--storePassword;gitblit;--baseFolder;%CD%\data" ^\r
                 --StartMode=jvm ^\r
                 --StopPath="%CD%" ^\r
                 --StopClass=com.gitblit.Launcher ^\r
                 --StopMethod=main ^\r
-                --StopParams="--stop" ^\r
+                --StopParams="--stop;--baseFolder;%CD%\data" ^\r
                 --StopMode=jvm ^\r
                 --Classpath="%CD%\gitblit.jar" ^\r
                 --Jvm=auto ^\r
diff --git a/distrib/projects.conf b/distrib/projects.conf
new file mode 100644 (file)
index 0000000..d43f482
--- /dev/null
@@ -0,0 +1,3 @@
+[project "main"]\r
+       title = Main Repositories\r
+       description = main group of repositories
\ No newline at end of file
index be0e191f6a91c9eb4b5c39379fa9a21ef225a7a1..cea1d692516e604628bc0df8e8445620e685f008 100644 (file)
@@ -1,53 +1,55 @@
-## Gitblit WAR Setup\r
+## Gitblit WAR Installation & Setup\r
 \r
 1. Download [Gitblit WAR %VERSION%](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) to the webapps folder of your servlet container.  \r
 2. You may have to manually extract the WAR (zip file) to a folder within your webapps folder.\r
-3. Copy the `WEB-INF/users.conf` file to a location outside the webapps folder that is accessible by your servlet container.  \r
-Optionally copy the example hook scripts in `WEB-INF/groovy` to a location outside the webapps folder that is accesible by your servlet container.\r
-4. The Gitblit webapp is configured through its `web.xml` file.  \r
-Open `web.xml` in your favorite text editor and make sure to review and set:\r
-    - &lt;context-parameter&gt; *git.repositoryFolder* (set the full path to your repositories folder)\r
-    - &lt;context-parameter&gt; *groovy.scriptsFolder* (set the full path to your Groovy hook scripts folder)\r
-    - &lt;context-parameter&gt; *groovy.grapeFolder* (set the full path to your Groovy Grape artifact cache)\r
-    - &lt;context-parameter&gt; *web.projectsFile* (set the full path to your projects metadata file)\r
-    - &lt;context-parameter&gt; *realm.userService* (set the full path to `users.conf`)\r
+3. By default, the Gitblit webapp is configured through `WEB-INF/data/gitblit.properties`.<br/>\r
+Open `WEB-INF/data/gitblit.properties` in your favorite text editor and make sure to review and set:\r
     - &lt;context-parameter&gt; *git.packedGitLimit* (set larger than the size of your largest repository)\r
     - &lt;context-parameter&gt; *git.streamFileThreshold* (set larger than the size of your largest committed file)\r
-5. You may have to restart your servlet container. \r
-6. Open your browser to <http://localhost/gitblit> or whatever the url should be.\r
-7. Enter the default administrator credentials: **admin / admin** and click the *Login* button  \r
+4. You may have to restart your servlet container. \r
+5. Open your browser to <http://localhost/gitblit> or whatever the url should be.\r
+6. Enter the default administrator credentials: **admin / admin** and click the *Login* button  \r
     **NOTE:** Make sure to change the administrator username and/or password!! \r
 \r
-## Gitblit GO Setup\r
+### WAR Data Location\r
+By default, Gitblit WAR stores all data (users, settings, repositories, etc) in `${contextFolder}/WEB-INF/data`.  This is fine for a quick setup, but there are many reasons why you don't want to keep your data within the webapps folder of your servlet container.  You may specify an external location for your data by editing `WEB-INF/web.xml` and manipulating the *baseFolder* context parameter.  Choose a location that is writeable by your servlet container.  Your servlet container may be smart enough to recognize the change and to restart Gitblit.\r
+\r
+On the next restart of Gitblit, Gitblit will copy the contents of the `WEB-INF/data` folder to your specified *baseFolder* **IF** the file `${baseFolder}/gitblit.properties` does not already exist.  This allows you to get going with minimal fuss.\r
+\r
+Specifying an alternate *baseFolder* also allows for simpler upgrades in the future.\r
+\r
+## Gitblit GO Installation & Setup\r
 \r
 1. Download and unzip [Gitblit GO %VERSION%](http://code.google.com/p/gitblit/downloads/detail?name=%GO%).  \r
 *Its best to eliminate spaces in the path name.* \r
-2. The server itself is configured through a simple text file.  \r
-Open `gitblit.properties` in your favorite text editor and make sure to review and set:\r
-    - *git.repositoryFolder* (path may be relative or absolute)\r
-    - *groovy.scriptsFolder* (path may be relative or absolute)\r
-    - *groovy.grapeFolder* (path may be relative or absolute)\r
-    - *server.tempFolder* (path may be relative or absolute)\r
+2. The server itself is configured through a simple text file.<br/>\r
+Open `data/gitblit.properties` in your favorite text editor and make sure to review and set:\r
     - *server.httpPort* and *server.httpsPort*\r
     - *server.httpBindInterface* and *server.httpsBindInterface*  \r
        - *server.storePassword*\r
     **https** is strongly recommended because passwords are insecurely transmitted form your browser/git client using Basic authentication!\r
     - *git.packedGitLimit* (set larger than the size of your largest repository)\r
     - *git.streamFileThreshold* (set larger than the size of your largest committed file)\r
-3. Execute `authority.cmd` or `java -jar authority.jar` from a command-line\r
+3. Execute `authority.cmd` or `java -jar authority.jar --baseFolder data` from a command-line\r
     1. fill out the fields in the *new certificate defaults* dialog\r
        2. enter the store password used in *server.storePassword* when prompted.  This generates an SSL certificate for **localhost**.\r
        3. you may want to generate an SSL certificate for the hostname or ip address hostnames you are serving from<br/>**NOTE:** You can only have **one** SSL certificate specified for a port.\r
        5. exit the authority app\r
-4. Execute `gitblit.cmd` or `java -jar gitblit.jar` from a command-line\r
+4. Execute `gitblit.cmd` or `java -jar gitblit.jar --baseFolder data` from a command-line\r
 5. Open your browser to <http://localhost:8080> or <https://localhost:8443> depending on your chosen configuration.\r
 6. Enter the default administrator credentials: **admin / admin** and click the *Login* button    \r
     **NOTE:** Make sure to change the administrator username and/or password!! \r
 \r
+### GO Data Location\r
+\r
+By default, Gitblit GO stores all data (users, settings, repositories, etc) in the `data` subfolder of your GO installation.  You may specify an external location for your data on the command-line by setting the *--baseFolder* argument.  If you relocate the data folder then you must supply the *--baseFolder* argument to both GO and the Certificate Authority.\r
+\r
+If you are deploying Gitblit to a *nix platform, you might consider moving the data folder out of the GO installation folder and then creating a symlink named "data" that points to your moved folder.\r
+\r
 ### Creating your own Self-Signed SSL Certificate\r
 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*.\r
 \r
-Remote Eclipse/EGit/JGit clients (<= 2.1.0) will fail to communicate using this certificate because JGit always verifies the hostname of the certificate, regardless of the *http.sslVerify=false* client-side setting.\r
+Remote Eclipse/EGit/JGit clients (<= 2.2.0) will fail to communicate using this certificate because JGit always verifies the hostname of the certificate, regardless of the *http.sslVerify=false* client-side setting.\r
 \r
 The EGit failure message is something like:\r
 \r
@@ -56,7 +58,7 @@ The EGit failure message is something like:
 \r
 If you want to serve your repositories to another machine over https then you will want to generate a new certificate for the hostname or ip address you are serving from.\r
 \r
-1. `authority.cmd` or `java -jar authority.jar`\r
+1. `authority.cmd` or `java -jar authority.jar --baseFolder data`\r
 2. Click the *new ssl certificate* button (red rosette in the toolbar in upper left of window)\r
 3. Enter the hostname or ip address\r
 4. Make sure the checkbox *serve https with this certificate* is checked\r
@@ -64,11 +66,11 @@ If you want to serve your repositories to another machine over https then you wi
  \r
 If you decide to change the value of *server.storePassword* (recommended) <u>after</u> you have already started Gitblit or Gitblit Certificate Authority, then you will have to delete the following files and then restart the Gitblit Certificate Authority app:\r
 \r
-1. serverKeyStore.jks\r
-2. serverTrustStore.jks\r
-3. certs/caKeyStore.jks\r
-4. certs/ca.crt\r
-5. certs/caRevocationList.crl (optional)\r
+1. data/serverKeyStore.jks\r
+2. data/serverTrustStore.jks\r
+3. data/certs/caKeyStore.jks\r
+4. data/certs/ca.crt\r
+5. data/certs/caRevocationList.crl (optional)\r
 \r
 ### Client SSL Certificates\r
 SINCE 1.2.0\r
@@ -84,6 +86,7 @@ Gitblit must be able to map the DN of the certificate to an *existing* account u
 How do you make your servlet container trust a client certificate?\r
 \r
 In the WAR variant, you will have to manually setup your servlet container to:\r
+\r
 1. want/need client certificates\r
 2. trust a CA certificate used to sign your client certificates\r
 3. generate client certificates signed by your CA certificate\r
@@ -92,9 +95,9 @@ Alternatively, Gitblit GO is designed to facilitate use of client certificate au
 \r
 #### Creating SSL Certificates with Gitblit Certificate Authority\r
 \r
-When you generate a new client certificate, a zip file bundle is created which includes a P12 keystore for browsers and a PEM keystore for Git.  Both of these are password-protected.  Additionally, a personalized README file is generated with setup instructions for popular browsers and Git.  The README is generated from `certs\instructions.tmpl` and can be modified to suit your needs.\r
+When you generate a new client certificate, a zip file bundle is created which includes a P12 keystore for browsers and a PEM keystore for Git.  Both of these are password-protected.  Additionally, a personalized README file is generated with setup instructions for popular browsers and Git.  The README is generated from `data\certs\instructions.tmpl` and can be modified to suit your needs.\r
 \r
-1. `authority.cmd` or `java -jar authority.jar`\r
+1. `authority.cmd` or `java -jar authority.jar --baseFolder data`\r
 2. Select the user for which to generate the certificate\r
 3. Click the *new certificate* button and enter the expiration date of the certificate.  You must also enter a password for the generated keystore.  This password is *not* the same as the user's login password.  This password is used to protect the privatekey and public certificate you will generate for the selected user.  You must also enter a password hint for the user.\r
 4. If your mail server settings are properly configured you will have a *send email* checkbox which you can use to immediately send the generated certificate bundle to the user.\r
@@ -130,6 +133,7 @@ C:\Program Files\Java\jre6\bin\server\jvm.dll</pre>
 #### Command-Line Parameters\r
 Command-Line parameters override the values in `gitblit.properties` at runtime.\r
 \r
+    --baseFolder           The default base folder for all relative file reference settings\r
        --repositoriesFolder   Git Repositories Folder\r
     --userService          Authentication and Authorization Service (filename or fully qualified classname)\r
     --useNio               Use NIO Connector else use Socket Connector.\r
@@ -143,7 +147,7 @@ Command-Line parameters override the values in `gitblit.properties` at runtime.
     \r
 **Example**\r
 \r
-    java -jar gitblit.jar --userService c:\myrealm.config --storePassword something\r
+    java -jar gitblit.jar --userService c:/myrealm.config --storePassword something --baseFolder c:/data\r
 \r
 #### Overriding Gitblit GO's Log4j Configuration\r
 \r
@@ -221,9 +225,6 @@ ProxyPreserveHost On
     Alternatively, you can respecify *web.forwardSlashCharacter*.\r
 \r
 ## Upgrading Gitblit\r
-Generally, upgrading is easy.\r
-\r
-Since Gitblit does not use a database the only files you have to worry about are your configuration file (`gitblit.properties` or `web.xml`) and possibly your `users.conf` or `users.properties` file.\r
 \r
 Any important changes to the setting keys or default values will always be mentioned in the [release log](releases.html).\r
 \r
@@ -231,26 +232,47 @@ Gitblit v0.8.0 introduced a new default user service implementation which serial
 \r
 `users.properties` and its user service implementation are deprecated as of v0.8.0.\r
 \r
-### Upgrading Gitblit WAR\r
-1. Backup your `web.xml` file  \r
-Backup your `web.properties` file (if you have one, these are the setting overrides from using the RPC administration service)\r
-2. Delete currently deployed gitblit WAR\r
-3. Deploy new WAR and overwrite the `web.xml` file with your backup\r
-4. Review and optionally apply any new settings as indicated in the [release log](releases.html). \r
+### Upgrading Gitblit WAR (1.2.1+)\r
+1. Make sure your `WEB-INF/web.xml` *baseFolder* context parameter is not `${contextFolder}/WEB-INF/data`!<br/>\r
+If it is, move your `WEB-INF/data` folder to a location writeable by your servlet container.\r
+2. Deploy new WAR\r
+3. Edit the new WAR's `WEB-INF/web.xml` file and set the *baseFolder* context parameter to your external baseFolder.\r
+4. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `${baseFolder}/gitblit.properties`\r
  \r
-### Upgrading Gitblit GO\r
+### Upgrading Gitblit GO (1.2.1+)\r
  \r
-1. Backup your `gitblit.properties` file\r
-2. Backup your `users.properties` file *(if it is located in the Gitblit GO folder)*  \r
-OR  \r
-Backup your `users.conf` file *(if it is located in the Gitblit GO folder)*\r
-3. Backup your Groovy hook scripts\r
-4. Unzip Gitblit GO to a new folder\r
-5. Overwrite the `gitblit.properties` file with your backup\r
-6. Overwrite the `users.properties` file with your backup *(if it was located in the Gitblit GO folder)*  \r
-OR  \r
-Overwrite the `users.conf` file with your backup *(if it was located in the Gitblit GO folder)*\r
-7. Review and optionally apply any new settings as indicated in the [release log](releases.html).\r
+1. Unzip Gitblit GO to a new folder\r
+2. Copy your `data` folder from your current Gitblit installation to the new folder and overwrite any conflicts\r
+3. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `data/gitblit.properties`.\r
+\r
+In *nix systems, there are other tricks you can play like symlinking the `data` folder or symlinking the GO folder.\r
+All platforms support the *--baseFolder* command-line argument.\r
+\r
+### Upgrading Gitblit WAR (pre-1.2.1)\r
+\r
+1. Create a `data` as outlined in step 1 of *Upgrading Gitblit GO (pre-1.2.1)*\r
+2. Copy your existing web.xml to your data folder\r
+3. Deploy new WAR\r
+4. Copy the new WAR's `WEB-INF/data/gitblit.properties` file to your data folder\r
+5. Manually apply any changes you made to your original web.xml file to the gitblit.properties file you copied to your data folder\r
+6. Edit the new WAR's `WEB-INF/web.xml` file and set the *baseFolder* context parameter to your external baseFolder.\r
+\r
+### Upgrading Gitblit GO (pre-1.2.1)\r
+1. Create a `data` folder and copy the following files and folders to it:\r
+    - users.conf\r
+       - projects.conf *(if you have one)*\r
+       - gitblit.properties\r
+       - serverKeystore.jks\r
+       - serverTrustStore.jks\r
+       - certs folder\r
+       - groovy folder\r
+       - proposals folder\r
+    - and any other custom files (robots.txt, welcome/login markdown files, etc)\r
+2. Unzip Gitblit GO to a new folder\r
+3. Copy your `data` folder and overwrite the folder of the same name in the just-unzipped version\r
+4. Review and optionally apply any new settings as indicated in the [release log](releases.html) to `data/gitblit.properties`.\r
+\r
+**NOTE:** You may need to adjust your service definitions to include the `--baseFolder data` argument.\r
 \r
 #### Upgrading Windows Service\r
 You may need to delete your old service definition and install a new one depending on what has changed in the release.\r
@@ -277,7 +299,7 @@ All repository settings are stored within the repository `.git/config` file unde
            federationSets = \r
 \r
 #### Repository Names\r
-Repository names must be unique and are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS.  The name must be composed of letters, digits, or `/ _ - . ~`<br/>\r
+Repository names must be case-insensitive-unique but are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS.  The name must be composed of letters, digits, or `/ _ - . ~`<br/>\r
 Whitespace is illegal.\r
 \r
 Repositories can be grouped within subfolders.  e.g. *libraries/mycoollib.git* and *libraries/myotherlib.git*\r
@@ -366,6 +388,10 @@ All checks are case-insensitive.
 \r
 You can not use fast-forward merges on your client when using committer verification.  You must specify *--no-ff* to ensure that a merge commit is created with your identity as the committer.  Only the first parent chain is traversed when verifying commits.\r
 \r
+#### Push Log\r
+\r
+Gitblit v1.2.1 introduces an incomplete push mechanism.  All pushes are logged since 1.2.1, but the log has not yet been exposed through the web ui.  This will be a feature of an upcoming release.\r
+\r
 ### Teams\r
 \r
 Since v0.8.0, Gitblit supports *teams* for the original `users.properties` user service and the current default user service `users.conf`.  Teams have assigned users and assigned repositories.  A user can be a member of multiple teams and a repository may belong to multiple teams.  This allows the administrator to quickly add a user to a team without having to keep track of all the appropriate repositories. \r
index fa088b2a2e9346a4dd2d4c2a5c34df23108d5520..a76e3c79d01b1209072c098db554c91f3d7f540a 100644 (file)
@@ -2,6 +2,14 @@
 \r
 ### Current Release\r
 \r
+<div class="alert alert-info">\r
+<h4>Update Note 1.2.1</h4>\r
+Because there are now several types of files and folders that must be considered Gitblit data, the default location for data has changed.\r
+<p>You will need to move a few files around when upgrading.  Please see the Upgrading section of the <a href="setup.html">setup</a> page for details.</p>\r
+\r
+<b>Express Users</b> make sure to update your web.xml file with the ${baseFolder} values!\r
+</div>\r
+\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
@@ -10,7 +18,7 @@
 - Added nullchecking when concurrently forking a repository and trying to display it's fork network (issue-187)\r
 - Fixed bug where permission changes were not visible in the web ui to a logged-in user until the user logged-out and then logged back in again (issue-186)\r
 - Fixed nullpointer on creating a repository with mixed case (issue 185)\r
-- Fixed nullpointer when using web.allowForking = true && git.cacheRepositoryList = false (issue 182)\r
+- Fixed nullpointer when using *web.allowForking = true* && *git.cacheRepositoryList = false* (issue 182)\r
 - Likely fix for commit and commitdiff page failures when a submodule reference changes (issue 178)\r
 - Build project models from the repository model cache, when possible, to reduce page load time (issue 172)\r
 - Fixed loading of Brazilian Portuguese translation from *nix server (github/inaiat)\r
@@ -30,6 +38,10 @@ The push log is not currently visible in the ui, but the data will be collected
 \r
 #### changes\r
 \r
+- Gitblit GO and Gitblit WAR are now both configured by `gitblit.properties`. WAR is no longer configured by `web.xml`.<br/>\r
+However, Express for OpenShift continues to be configured by `web.xml`.\r
+- Support for a *--baseFolder* command-line argument for Gitblit GO and Gitblit Certificate Authority\r
+- Support for specifying a *${baseFolder}* parameter in `gitblit.properties` and `web.xml` for several settings\r
 - Improve history display of a submodule link\r
 - Updated Korean translation (github/ds5apn)\r
 - Updated checkstyle definition (github/mystygage)\r
@@ -37,7 +49,7 @@ The push log is not currently visible in the ui, but the data will be collected
 ### Older Releases\r
 \r
 <div class="alert alert-info">\r
-<h4>Update Note</h4>\r
+<h4>Update Note 1.2.0</h4>\r
 The permissions model has changed in the 1.2.0 release.\r
 <p>If you are updating your server, you must also update any Gitblit Manager and Federation Client installs to 1.2.0 as well.  The data model used by the RPC mechanism has changed slightly for the new permissions infrastructure.</p>\r
 </div>\r
@@ -142,7 +154,7 @@ If *realm.ldap.maintainTeams==true* **AND** *realm.ldap.admins* is not empty, th
 <hr/>\r
 \r
 <div class="alert alert-error">\r
-<h4>Update Note</h4>\r
+<h4>Update Note 1.1.0</h4>\r
 If you are updating from an earlier release AND you have indexed branches with the Lucene indexing feature, you need to be aware that this release will completely re-index your repositories.  Please be sure to provide ample heap resources as appropriate for your installation.\r
 </div>\r
 \r
diff --git a/groovy/.gitignore b/groovy/.gitignore
deleted file mode 100644 (file)
index e58dc47..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/grape
diff --git a/groovy/blockpush.groovy b/groovy/blockpush.groovy
deleted file mode 100644 (file)
index caef330..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import java.text.MessageFormat;\r
-\r
-import com.gitblit.GitBlit\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.UserModel\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-import com.gitblit.utils.ClientLogger\r
-\r
-/**\r
- * Sample Gitblit Pre-Receive Hook: blockpush\r
- * \r
- * This script could and perhaps should be further developed to provide\r
- * a full repository-branch permissions system similar to gitolite or gitosis.\r
- *\r
- * The Pre-Receive hook is executed after an incoming push has been parsed,\r
- * validated, and objects have been written but BEFORE the refs are updated.\r
- * This is the appropriate point to block a push for some reason.\r
- *\r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push.  If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- * \r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- *\r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- * \r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- *\r
- * Bound Variables:\r
- *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
- *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
- *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
- *  user                       Gitblit User                            com.gitblit.models.UserModel\r
- *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- *     url                             Base url for Gitblit            String\r
- *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
- *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- *   def myCustomField = repository.customFields.myCustomField\r
- *  \r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("blockpush hook triggered by ${user.username} for ${repository.name}: checking ${commands.size} commands")\r
-\r
-/*\r
- * Example rejection of pushes to the master branch of example.git\r
- */\r
-def blocked = false\r
-switch (repository.name) {\r
-       case 'ex@mple.git':\r
-               for (ReceiveCommand command : commands) {\r
-                       def updatedRef = command.refName\r
-                       if (updatedRef.equals('refs/heads/master')) {\r
-                               // to reject a command set it's result to anything other than Result.NOT_ATTEMPTED\r
-                               command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")\r
-                               blocked = true\r
-                       }\r
-               }\r
-               break\r
-\r
-       default:\r
-               break\r
-}\r
-\r
-if (blocked) {\r
-       // return false to break the push hook chain\r
-       return false\r
-}
\ No newline at end of file
diff --git a/groovy/jenkins.groovy b/groovy/jenkins.groovy
deleted file mode 100644 (file)
index d76a3d6..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: jenkins\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository.  This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push.  If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- * \r
- * Bound Variables:\r
- *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
- *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
- *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
- *  user                       Gitblit User                            com.gitblit.models.UserModel\r
- *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- *     url                             Base url for Gitblit            String\r
- *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
- *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- *   def myCustomField = repository.customFields.myCustomField\r
- *  \r
- */\r
-// Indicate we have started the script\r
-logger.info("jenkins hook triggered by ${user.username} for ${repository.name}")\r
-\r
-// This script requires Jenkins Git plugin 1.1.14 or later\r
-// http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/\r
-\r
-// define your jenkins url here or set groovy.jenkinsServer in \r
-// gitblit.properties or web.xml\r
-def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins')\r
-\r
-// define the trigger url\r
-def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=$url/git/$repository.name"\r
-\r
-// trigger the build\r
-new URL(triggerUrl).getContent()\r
diff --git a/groovy/localclone.groovy b/groovy/localclone.groovy
deleted file mode 100644 (file)
index 49b7f8b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*\r
- * Copyright 2012 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import com.gitblit.utils.StringUtils\r
-import java.text.SimpleDateFormat\r
-import org.eclipse.jgit.api.CloneCommand\r
-import org.eclipse.jgit.api.Git\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.eclipse.jgit.util.FileUtils\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: localclone\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository.  This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push.  If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- *\r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- * \r
- * Bound Variables:\r
- *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
- *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
- *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
- *  user                       Gitblit User                            com.gitblit.models.UserModel\r
- *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- *     url                             Base url for Gitblit            String\r
- *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
- *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- *   def myCustomField = repository.customFields.myCustomField\r
- *  \r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("localclone hook triggered by ${user.username} for ${repository.name}")\r
-\r
-def rootFolder = 'c:/test'\r
-def bare = false\r
-def cloneAllBranches = true\r
-def cloneBranch = 'refs/heads/master'\r
-def includeSubmodules = true\r
-\r
-def repoName = repository.name\r
-def destinationFolder = new File(rootFolder, StringUtils.stripDotGit(repoName))\r
-def srcUrl = 'file://' + new File(GitBlit.getRepositoriesFolder(), repoName).absolutePath\r
-\r
-// delete any previous clone\r
-if (destinationFolder.exists()) {\r
-       FileUtils.delete(destinationFolder, FileUtils.RECURSIVE)\r
-}\r
-\r
-// clone the repository\r
-logger.info("cloning ${srcUrl} to ${destinationFolder}")\r
-CloneCommand cmd = Git.cloneRepository();\r
-cmd.setBare(bare)\r
-if (cloneAllBranches)\r
-       cmd.setCloneAllBranches(true)\r
-else\r
-       cmd.setBranch(cloneBranch)\r
-cmd.setCloneSubmodules(includeSubmodules)\r
-cmd.setURI(srcUrl)\r
-cmd.setDirectory(destinationFolder)\r
-Git git = cmd.call();\r
-git.repository.close()\r
-\r
-// report clone operation success back to pushing Git client\r
-clientLogger.info("${repoName} cloned to ${destinationFolder}")
\ No newline at end of file
diff --git a/groovy/protect-refs.groovy b/groovy/protect-refs.groovy
deleted file mode 100644 (file)
index b1b611f..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*\r
- * Copyright 2012 Philip L. McMahon.\r
- *\r
- * Derived from blockpush.groovy, copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.UserModel\r
-\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Pre-Receive Hook: protect-refs\r
- * \r
- * This script provides basic authorization of receive command types for a list\r
- * of known ref patterns. Command types and unmatched ref patterns will be\r
- * ignored, meaning this script has an "allow by default" policy.\r
- *\r
- * This script works best when a repository requires authentication on push, but\r
- * can be used to enforce fast-forward commits or prohibit ref deletion by\r
- * setting the *authorizedTeams* variable to an empty list and adding a ".+"\r
- * entry to the *protectedRefs* list.\r
- *\r
- * The Pre-Receive hook is executed after an incoming push has been parsed,\r
- * validated, and objects have been written but BEFORE the refs are updated.\r
- * This is the appropriate point to block a push for some reason.\r
- *\r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.preReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push.  If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- * \r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- *\r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- * \r
- * This script may reject one or more commands, but will never return false.\r
- * Subsequent scripts, if any, will always be invoked.\r
- *\r
- * Bound Variables:\r
- *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
- *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
- *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
- *  user                       Gitblit User                            com.gitblit.models.UserModel\r
- *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- *     url                             Base url for Gitblit            String\r
- *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
- *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- *   def myCustomField = repository.customFields.myCustomField\r
- *  \r
- */\r
-\r
-// map of protected command types to returned results type\r
-// commands not included will skip authz check\r
-def protectedCmds = [\r
-       UPDATE_NONFASTFORWARD:  Result.REJECTED_NONFASTFORWARD,\r
-       DELETE:                                 Result.REJECTED_NODELETE\r
-]\r
-\r
-// list of regex patterns for protected refs\r
-def protectedRefs = [\r
-       "refs/heads/master",\r
-       "refs/tags/.+"\r
-]\r
-\r
-// teams which are authorized to perform protected commands on protected refs\r
-def authorizedTeams = [ "admins" ]\r
-\r
-for (ReceiveCommand command : commands) {\r
-       def updateType = command.type\r
-       def updatedRef = command.refName\r
-       \r
-       // find first regex which matches updated ref, if any\r
-       def refPattern = protectedRefs.find { updatedRef.matches ~it }\r
-       \r
-       // find rejection result for update type, if any\r
-       def result = protectedCmds[updateType.name()]\r
-       \r
-       // command requires authz if ref is protected and has a mapped rejection result\r
-       if (refPattern && result) {\r
-       \r
-               // verify user is a member of any authorized team\r
-               def team = authorizedTeams.find { user.isTeamMember it }\r
-               if (team) {\r
-                       // don't adjust command result\r
-                       logger.info "${user.username} authorized for ${updateType} of protected ref ${repository.name}:${updatedRef} (${command.oldId.name} -> ${command.newId.name})"\r
-               } else {\r
-                       // mark command result as rejected\r
-                       command.setResult(result, "${user.username} cannot ${updateType} protected ref ${repository.name}:${updatedRef} matching pattern ${refPattern}")\r
-               }\r
-       }\r
-}\r
diff --git a/groovy/sendmail-html.groovy b/groovy/sendmail-html.groovy
deleted file mode 100644 (file)
index 1692073..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*\r
- * Copyright 2012 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import java.text.SimpleDateFormat\r
-\r
-import org.eclipse.jgit.api.Status;\r
-import org.eclipse.jgit.api.errors.JGitInternalException;\r
-import org.eclipse.jgit.diff.DiffEntry;\r
-import org.eclipse.jgit.diff.DiffFormatter;\r
-import org.eclipse.jgit.diff.RawTextComparator;\r
-import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
-import org.eclipse.jgit.lib.Constants;\r
-import org.eclipse.jgit.lib.IndexDiff;\r
-import org.eclipse.jgit.lib.ObjectId;\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.patch.FileHeader;\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.revwalk.RevWalk;\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.eclipse.jgit.treewalk.FileTreeIterator;\r
-import org.eclipse.jgit.treewalk.EmptyTreeIterator;\r
-import org.eclipse.jgit.treewalk.CanonicalTreeParser;\r
-import org.eclipse.jgit.util.io.DisabledOutputStream;\r
-import org.slf4j.Logger\r
-import groovy.xml.MarkupBuilder\r
-\r
-import java.io.IOException;\r
-import java.security.MessageDigest\r
-\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: sendmail-html\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository.  This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push.  If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- *\r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- * \r
- * Bound Variables:\r
- *  gitblit         Gitblit Server               com.gitblit.GitBlit\r
- *  repository      Gitblit Repository           com.gitblit.models.RepositoryModel\r
- *  user            Gitblit User                 com.gitblit.models.UserModel\r
- *  commands        JGit commands                Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- *  url             Base url for Gitblit         java.lang.String\r
- *  logger          Logs messages to Gitblit     org.slf4j.Logger\r
- *  clientLogger    Logs messages to Git client  com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- *   def myCustomField = repository.customFields.myCustomField\r
- *  \r
- */\r
-\r
-com.gitblit.models.UserModel userModel = user\r
-\r
-// Indicate we have started the script\r
-logger.info("sendmail-html hook triggered by ${user.username} for ${repository.name}")\r
-\r
-/*\r
- * Primitive email notification.\r
- * This requires the mail settings to be properly configured in Gitblit.\r
- */\r
-\r
-Repository r = gitblit.getRepository(repository.name)\r
-\r
-// reuse existing repository config settings, if available\r
-Config config = r.getConfig()\r
-def mailinglist = config.getString('hooks', null, 'mailinglist')\r
-def emailprefix = config.getString('hooks', null, 'emailprefix')\r
-\r
-// set default values\r
-def toAddresses = []\r
-if (emailprefix == null) {\r
-    emailprefix = '[Gitblit]'\r
-}\r
-\r
-if (mailinglist != null) {\r
-    def addrs = mailinglist.split(/(,|\s)/)\r
-    toAddresses.addAll(addrs)\r
-}\r
-\r
-// add all mailing lists defined in gitblit.properties or web.xml\r
-toAddresses.addAll(GitBlit.getStrings(Keys.mail.mailingLists))\r
-\r
-// add all team mailing lists\r
-def teams = gitblit.getRepositoryTeams(repository)\r
-for (team in teams) {\r
-    TeamModel model = gitblit.getTeamModel(team)\r
-    if (model.mailingLists) {\r
-        toAddresses.addAll(model.mailingLists)\r
-    }\r
-}\r
-\r
-// add all mailing lists for the repository\r
-toAddresses.addAll(repository.mailingLists)\r
-\r
-// define the summary and commit urls\r
-def repo = repository.name\r
-def summaryUrl = url + "/summary?r=$repo"\r
-def baseCommitUrl = url + "/commit?r=$repo&h="\r
-def baseBlobDiffUrl = url + "/blobdiff/?r=$repo&h="\r
-def baseCommitDiffUrl = url + "/commitdiff/?r=$repo&h="\r
-def forwardSlashChar = gitblit.getString(Keys.web.forwardSlashCharacter, '/')\r
-\r
-if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
-    repo = repo.replace('/', forwardSlashChar).replace('/', '%2F')\r
-    summaryUrl = url + "/summary/$repo"\r
-    baseCommitUrl = url + "/commit/$repo/"\r
-    baseBlobDiffUrl = url + "/blobdiff/$repo/"\r
-    baseCommitDiffUrl = url + "/commitdiff/$repo/"\r
-}\r
-\r
-class HtmlMailWriter {\r
-    Repository repository\r
-    def url\r
-    def baseCommitUrl\r
-    def baseCommitDiffUrl\r
-    def baseBlobDiffUrl\r
-    def mountParameters\r
-       def forwardSlashChar\r
-       def includeGravatar\r
-       def shortCommitIdLength\r
-    def commitCount = 0\r
-    def commands\r
-    def writer = new StringWriter();\r
-    def builder = new MarkupBuilder(writer)\r
-\r
-    def writeStyle() {\r
-        builder.style(type:"text/css", '''\r
-    .table td {\r
-        vertical-align: middle;\r
-    }\r
-    tr.noborder td {\r
-        border: none;\r
-        padding-top: 0px;\r
-    }\r
-    .gravatar-column {\r
-        width: 5%; \r
-    }\r
-    .author-column {\r
-        width: 20%; \r
-    }\r
-    .commit-column {\r
-        width: 5%; \r
-    }\r
-    .status-column {\r
-        width: 10%;\r
-    }\r
-    .table-disable-hover.table tbody tr:hover td,\r
-    .table-disable-hover.table tbody tr:hover th {\r
-        background-color: inherit;\r
-    }\r
-    .table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,\r
-    .table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {\r
-      background-color: #f9f9f9;\r
-    }\r
-    ''')\r
-    }\r
-\r
-    def writeBranchTitle(type, name, action, number) {\r
-        builder.div('class' : 'pageTitle') {\r
-                       builder.span('class':'project') {\r
-                               mkp.yield "$type "\r
-                               span('class': 'repository', name )\r
-                               if (number > 0) {\r
-                                       mkp.yield " $action ($number commits)"\r
-                               } else {\r
-                                       mkp.yield " $action"\r
-                               }\r
-                       }\r
-        }\r
-    }\r
-\r
-    def writeBranchDeletedTitle(type, name) {\r
-               builder.div('class' : 'pageTitle', 'style':'color:red') {\r
-                       builder.span('class':'project') {\r
-                               mkp.yield "$type "\r
-                               span('class': 'repository', name )\r
-                               mkp.yield " deleted"\r
-                       }\r
-               }\r
-    }\r
-\r
-    def commitUrl(RevCommit commit) {\r
-        "${baseCommitUrl}$commit.id.name"\r
-    }\r
-\r
-    def commitDiffUrl(RevCommit commit) {\r
-        "${baseCommitDiffUrl}$commit.id.name"\r
-    }\r
-\r
-    def encoded(String path) {\r
-        path.replace('/', forwardSlashChar).replace('/', '%2F')\r
-    }\r
-\r
-    def blobDiffUrl(objectId, path) {\r
-        if (mountParameters) {\r
-            // REST style\r
-            "${baseBlobDiffUrl}${objectId.name()}/${encoded(path)}"\r
-        } else {\r
-            "${baseBlobDiffUrl}${objectId.name()}&f=${path}"\r
-        }\r
-\r
-    }\r
-\r
-    def writeCommitTable(commits, includeChangedPaths=true) {\r
-        // Write commits table\r
-        builder.table('class':"table table-disable-hover") {\r
-            thead {\r
-                tr {\r
-                                       th(colspan: includeGravatar ? 2 : 1, "Author")\r
-                    th( "Commit" )\r
-                    th( "Message" )\r
-                }\r
-            }\r
-            tbody() {\r
-\r
-                // Write all the commits\r
-                for (commit in commits) {\r
-                    writeCommit(commit)\r
-\r
-                                       if (includeChangedPaths) {\r
-                                               // Write detail on that particular commit\r
-                                               tr('class' : 'noborder') {\r
-                                                       td (colspan: includeGravatar ? 3 : 2)\r
-                                                       td (colspan:2) { writeStatusTable(commit) }\r
-                                               }\r
-                                       }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    def writeCommit(commit) {\r
-        def abbreviated = repository.newObjectReader().abbreviate(commit.id, shortCommitIdLength).name()\r
-        def author = commit.authorIdent.name\r
-        def email = commit.authorIdent.emailAddress\r
-        def message = commit.shortMessage\r
-        builder.tr {\r
-                       if (includeGravatar) {\r
-                               td('class':"gravatar-column") {\r
-                                       img(src:gravatarUrl(email), 'class':"gravatar")\r
-                               }\r
-                       }\r
-            td('class':"author-column", author)\r
-            td('class':"commit-column") {\r
-                a(href:commitUrl(commit)) {\r
-                    span('class':"label label-info",  abbreviated )\r
-                }\r
-            }\r
-            td {\r
-                mkp.yield message\r
-                a('class':'link', href:commitDiffUrl(commit), " [commitdiff]" )\r
-            }\r
-        }\r
-    }\r
-\r
-    def writeStatusLabel(style, tooltip) {\r
-        builder.span('class' : style,  'title' : tooltip )\r
-    }\r
-\r
-    def writeAddStatusLine(ObjectId id, FileHeader header) {           \r
-        builder.td('class':'changeType') {\r
-            writeStatusLabel("addition", "addition")\r
-        }\r
-        builder.td {\r
-            a(href:blobDiffUrl(id, header.newPath), header.newPath)\r
-        }\r
-    }\r
-\r
-    def writeCopyStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':'changeType') {\r
-            writeStatusLabel("rename", "rename")\r
-        }\r
-        builder.td() {\r
-            a(href:blobDiffUrl(id, header.newPath), header.oldPath + " copied to " + header.newPath)\r
-        }\r
-    }\r
-\r
-    def writeDeleteStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':'changeType') {\r
-            writeStatusLabel("deletion", "deletion")\r
-        }\r
-        builder.td() {\r
-            a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
-        }\r
-    }\r
-\r
-    def writeModifyStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':'changeType') {\r
-                       writeStatusLabel("modification", "modification")\r
-        }\r
-        builder.td() {\r
-            a(href:blobDiffUrl(id, header.oldPath), header.oldPath)\r
-        }\r
-    }\r
-\r
-    def writeRenameStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':'changeType') {\r
-             writeStatusLabel("rename", "rename")\r
-        }\r
-        builder.td() {\r
-            mkp.yield header.oldPath\r
-                       mkp.yieldUnescaped "<b> -&rt; </b>"\r
-                       a(href:blobDiffUrl(id, header.newPath),  header.newPath)\r
-        }\r
-    }\r
-\r
-    def writeStatusLine(ObjectId id, FileHeader header) {\r
-        builder.tr {\r
-            switch (header.changeType) {\r
-                case ChangeType.ADD:\r
-                    writeAddStatusLine(id, header)\r
-                    break;\r
-                case ChangeType.COPY:\r
-                    writeCopyStatusLine(id, header)\r
-                    break;\r
-                case ChangeType.DELETE:\r
-                    writeDeleteStatusLine(id, header)\r
-                    break;\r
-                case ChangeType.MODIFY:\r
-                    writeModifyStatusLine(id, header)\r
-                    break;\r
-                case ChangeType.RENAME:\r
-                    writeRenameStatusLine(id, header)\r
-                    break;\r
-            }\r
-        }\r
-    }\r
-\r
-    def writeStatusTable(RevCommit commit) {\r
-        DiffFormatter formatter = new DiffFormatter(DisabledOutputStream.INSTANCE)\r
-        formatter.setRepository(repository)\r
-        formatter.setDetectRenames(true)\r
-        formatter.setDiffComparator(RawTextComparator.DEFAULT);\r
-\r
-        def diffs\r
-               RevWalk rw = new RevWalk(repository)\r
-        if (commit.parentCount > 0) {\r
-                       RevCommit parent = rw.parseCommit(commit.parents[0].id)\r
-            diffs = formatter.scan(parent.tree, commit.tree)\r
-        } else {\r
-            diffs = formatter.scan(new EmptyTreeIterator(),\r
-                                   new CanonicalTreeParser(null, rw.objectReader, commit.tree))\r
-        }\r
-               rw.dispose()\r
-        // Write status table\r
-        builder.table('class':"plain") {\r
-            tbody() {\r
-                for (DiffEntry entry in diffs) {\r
-                    FileHeader header = formatter.toFileHeader(entry)\r
-                    writeStatusLine(commit.id, header)\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-    def md5(text) {\r
-\r
-        def digest = MessageDigest.getInstance("MD5")\r
-\r
-        //Quick MD5 of text\r
-        def hash = new BigInteger(1, digest.digest(text.getBytes()))\r
-                         .toString(16)\r
-                         .padLeft(32, "0")\r
-        hash.toString()\r
-    }\r
-\r
-    def gravatarUrl(email) {\r
-        def cleaned = email.trim().toLowerCase()\r
-        "http://www.gravatar.com/avatar/${md5(cleaned)}?s=30"\r
-    }\r
-\r
-    def writeNavbar() {\r
-        builder.div('class':"navbar navbar-fixed-top") {\r
-            div('class':"navbar-inner") {\r
-                div('class':"container") {\r
-                    a('class':"brand", href:"${url}", title:"GitBlit") {\r
-                        img(src:"${url}/gitblt_25_white.png",\r
-                            width:"79",\r
-                            height:"25",\r
-                            'class':"logo")\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    def write() {\r
-        builder.html {\r
-            head {\r
-                link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap.css")\r
-                link(rel:"stylesheet", href:"${url}/gitblit.css")\r
-                               link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap-responsive.css")\r
-                writeStyle()\r
-            }\r
-            body {\r
-\r
-                writeNavbar()\r
-\r
-                               div('class':"container") {\r
-\r
-                for (command in commands) {\r
-                    def ref = command.refName\r
-                    def refType = 'Branch'\r
-                    if (ref.startsWith('refs/heads/')) {\r
-                        ref  = command.refName.substring('refs/heads/'.length())\r
-                    } else if (ref.startsWith('refs/tags/')) {\r
-                        ref  = command.refName.substring('refs/tags/'.length())\r
-                        refType = 'Tag'\r
-                    }\r
-\r
-                    switch (command.type) {\r
-                        case ReceiveCommand.Type.CREATE:\r
-                                                       def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
-                                                       commitCount += commits.size()\r
-                                                       if (refType == 'Branch') {\r
-                                                               // new branch\r
-                                                               writeBranchTitle(refType, ref, "created", commits.size())\r
-                                                               writeCommitTable(commits, true)\r
-                                                       } else {\r
-                                                               // new tag\r
-                                                               writeBranchTitle(refType, ref, "created", 0)\r
-                                                               writeCommitTable(commits, false)\r
-                                                       }\r
-                            break\r
-                        case ReceiveCommand.Type.UPDATE:\r
-                            def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
-                            commitCount += commits.size()\r
-                            // fast-forward branch commits table\r
-                            // Write header\r
-                            writeBranchTitle(refType, ref, "updated", commits.size())\r
-                            writeCommitTable(commits)\r
-                            break\r
-                        case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
-                            def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()\r
-                            commitCount += commits.size()\r
-                            // non-fast-forward branch commits table\r
-                            // Write header\r
-                            writeBranchTitle(refType, ref, "updated [NON fast-forward]", commits.size())\r
-                            writeCommitTable(commits)\r
-                            break\r
-                        case ReceiveCommand.Type.DELETE:\r
-                            // deleted branch/tag\r
-                            writeBranchDeletedTitle(refType, ref)\r
-                            break\r
-                        default:\r
-                            break\r
-                    }\r
-                }\r
-                }\r
-            }\r
-        }\r
-        writer.toString()\r
-    }\r
-\r
-}\r
-\r
-def mailWriter = new HtmlMailWriter()\r
-mailWriter.repository = r\r
-mailWriter.baseCommitUrl = baseCommitUrl\r
-mailWriter.baseBlobDiffUrl = baseBlobDiffUrl\r
-mailWriter.baseCommitDiffUrl = baseCommitDiffUrl\r
-mailWriter.forwardSlashChar = forwardSlashChar\r
-mailWriter.commands = commands\r
-mailWriter.url = url\r
-mailWriter.mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true)\r
-mailWriter.includeGravatar = GitBlit.getBoolean(Keys.web.allowGravatar, true)\r
-mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)\r
-\r
-def content = mailWriter.write()\r
-\r
-// close the repository reference\r
-r.close()\r
-\r
-// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
-def repositoryName = repository.name.substring(0, repository.name.length() - 4)\r
-gitblit.sendHtmlMail("${emailprefix} ${userModel.displayName} pushed ${mailWriter.commitCount} commits => $repositoryName",\r
-                     content,\r
-                     toAddresses)\r
diff --git a/groovy/sendmail.groovy b/groovy/sendmail.groovy
deleted file mode 100644 (file)
index c832bc6..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import java.text.SimpleDateFormat\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-\r
-/**\r
- * Sample Gitblit Post-Receive Hook: sendmail\r
- *\r
- * The Post-Receive hook is executed AFTER the pushed commits have been applied\r
- * to the Git repository.  This is the appropriate point to trigger an\r
- * integration build or to send a notification.\r
- * \r
- * This script is only executed when pushing to *Gitblit*, not to other Git\r
- * tooling you may be using.\r
- * \r
- * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties\r
- * or web.xml then it will be executed by any repository when it receives a\r
- * push.  If you choose to share your script then you may have to consider\r
- * tailoring control-flow based on repository access restrictions.\r
- *\r
- * Scripts may also be specified per-repository in the repository settings page.\r
- * Shared scripts will be excluded from this list of available scripts.\r
- * \r
- * This script is dynamically reloaded and it is executed within it's own\r
- * exception handler so it will not crash another script nor crash Gitblit.\r
- *\r
- * If you want this hook script to fail and abort all subsequent scripts in the\r
- * chain, "return false" at the appropriate failure points.\r
- * \r
- * Bound Variables:\r
- *  gitblit                    Gitblit Server                          com.gitblit.GitBlit\r
- *  repository         Gitblit Repository                      com.gitblit.models.RepositoryModel\r
- *  receivePack                JGit Receive Pack                       org.eclipse.jgit.transport.ReceivePack\r
- *  user                       Gitblit User                            com.gitblit.models.UserModel\r
- *  commands           JGit commands                           Collection<org.eclipse.jgit.transport.ReceiveCommand>\r
- *     url                             Base url for Gitblit            String\r
- *  logger                     Logs messages to Gitblit        org.slf4j.Logger\r
- *  clientLogger       Logs messages to Git client     com.gitblit.utils.ClientLogger\r
- *\r
- * Accessing Gitblit Custom Fields:\r
- *   def myCustomField = repository.customFields.myCustomField\r
- *  \r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("sendmail hook triggered by ${user.username} for ${repository.name}")\r
-\r
-/*\r
- * Primitive email notification.\r
- * This requires the mail settings to be properly configured in Gitblit.\r
- */\r
-\r
-Repository r = gitblit.getRepository(repository.name)\r
-\r
-// reuse existing repository config settings, if available\r
-Config config = r.getConfig()\r
-def mailinglist = config.getString('hooks', null, 'mailinglist')\r
-def emailprefix = config.getString('hooks', null, 'emailprefix')\r
-\r
-// set default values\r
-def toAddresses = []\r
-if (emailprefix == null)\r
-emailprefix = '[Gitblit]'\r
-\r
-if (mailinglist != null) {\r
-       def addrs = mailinglist.split(/(,|\s)/)\r
-       toAddresses.addAll(addrs)\r
-}\r
-\r
-// add all mailing lists defined in gitblit.properties or web.xml\r
-toAddresses.addAll(gitblit.getStrings(Keys.mail.mailingLists))\r
-\r
-// add all team mailing lists\r
-def teams = gitblit.getRepositoryTeams(repository)\r
-for (team in teams) {\r
-       TeamModel model = gitblit.getTeamModel(team)\r
-       if (model.mailingLists) {\r
-               toAddresses.addAll(model.mailingLists)\r
-       }\r
-}\r
-\r
-// add all mailing lists for the repository\r
-toAddresses.addAll(repository.mailingLists)\r
-\r
-// define the summary and commit urls\r
-def repo = repository.name\r
-def summaryUrl\r
-def commitUrl\r
-if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
-       repo = repo.replace('/', gitblit.getString(Keys.web.forwardSlashCharacter, '/')).replace('/', '%2F')\r
-       summaryUrl = url + "/summary/$repo"\r
-       commitUrl = url + "/commit/$repo/"\r
-} else {\r
-       summaryUrl = url + "/summary?r=$repo"\r
-       commitUrl = url + "/commit?r=$repo&h="\r
-}\r
-\r
-// construct a simple text summary of the changes contained in the push\r
-def branchBreak = '>---------------------------------------------------------------\n'\r
-def commitBreak = '\n\n ----\n'\r
-def commitCount = 0\r
-def changes = ''\r
-SimpleDateFormat df = new SimpleDateFormat(gitblit.getString(Keys.web.datetimestampLongFormat, 'EEEE, MMMM d, yyyy h:mm a z'))\r
-def table = { "\n ${JGitUtils.getDisplayName(it.authorIdent)}\n ${df.format(JGitUtils.getCommitDate(it))}\n\n $it.shortMessage\n\n $commitUrl$it.id.name" }\r
-for (command in commands) {\r
-       def ref = command.refName\r
-       def refType = 'branch'\r
-       if (ref.startsWith('refs/heads/')) {\r
-               ref  = command.refName.substring('refs/heads/'.length())\r
-       } else if (ref.startsWith('refs/tags/')) {\r
-               ref  = command.refName.substring('refs/tags/'.length())\r
-               refType = 'tag'\r
-       }\r
-               \r
-       switch (command.type) {\r
-               case ReceiveCommand.Type.CREATE:\r
-                       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
-                       commitCount += commits.size()\r
-                       // new branch\r
-                       changes += "\n$branchBreak new $refType $ref created ($commits.size commits)\n$branchBreak"\r
-                       changes += commits.collect(table).join(commitBreak)\r
-                       changes += '\n'\r
-                       break\r
-               case ReceiveCommand.Type.UPDATE:\r
-                       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
-                       commitCount += commits.size()\r
-                       // fast-forward branch commits table\r
-                       changes += "\n$branchBreak $ref $refType updated ($commits.size commits)\n$branchBreak"\r
-                       changes += commits.collect(table).join(commitBreak)\r
-                       changes += '\n'\r
-                       break\r
-               case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
-                       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
-                       commitCount += commits.size()\r
-                       // non-fast-forward branch commits table\r
-                       changes += "\n$branchBreak $ref $refType updated [NON fast-forward] ($commits.size commits)\n$branchBreak"\r
-                       changes += commits.collect(table).join(commitBreak)\r
-                       changes += '\n'\r
-                       break\r
-               case ReceiveCommand.Type.DELETE:\r
-                       // deleted branch/tag\r
-                       changes += "\n$branchBreak $ref $refType deleted\n$branchBreak"\r
-                       break\r
-               default:\r
-                       break\r
-       }\r
-}\r
-// close the repository reference\r
-r.close()\r
-\r
-// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
-gitblit.sendMail("$emailprefix $user.username pushed $commitCount commits => $repository.name", "$summaryUrl\n$changes", toAddresses)
\ No newline at end of file
diff --git a/groovy/thebuggenie.groovy b/groovy/thebuggenie.groovy
deleted file mode 100644 (file)
index b4385a2..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*\r
- * Copyright 2011 Wolfgang Gassler gassler.org\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-import com.gitblit.GitBlit\r
-import com.gitblit.Keys\r
-import com.gitblit.models.RepositoryModel\r
-import com.gitblit.models.TeamModel\r
-import com.gitblit.models.UserModel\r
-import com.gitblit.utils.JGitUtils\r
-import java.text.SimpleDateFormat\r
-import org.eclipse.jgit.lib.Repository\r
-import org.eclipse.jgit.lib.Config\r
-import org.eclipse.jgit.revwalk.RevCommit\r
-import org.eclipse.jgit.transport.ReceiveCommand\r
-import org.eclipse.jgit.transport.ReceiveCommand.Result\r
-import org.slf4j.Logger\r
-import org.eclipse.jgit.lib.IndexDiff\r
-import org.eclipse.jgit.lib.Constants\r
-import com.gitblit.utils.DiffUtils\r
-\r
-/**\r
- * Gitblit Post-Receive Hook: thebuggenie\r
- * www.thebuggenie.com\r
- * \r
- * Submit the commit information to thebuggenie bug tracker by calling thebuggenie client tool\r
- *  \r
- * Config of the Script:\r
- * \r
- * Setup a custom gitblit field in the proprties file of gitblit by adding the following line\r
- *   groovy.customFields = "thebuggenieProjectId=TheBugGennie project id (used for thebuggenie hoocks)"\r
- * This field allows to specify the project id of thebuggenie project in the edit section of gitblit\r
- * \r
- * Furthermore you need to set the path to thebuggenie client tool by adding the following property to\r
- * the gitblit properties file\r
- *   thebuggenie.tbg_cli = /var/www/thebuggenie_root/tbg_cli\r
- */\r
-\r
-// Indicate we have started the script\r
-logger.info("thebuggenie hook triggered by ${user.username} for ${repository.name}")\r
-\r
-//fetch the repository data\r
-Repository r = gitblit.getRepository(repository.name)\r
-\r
-//get project id which is defined in the git repo metadata\r
-def tbgProjectId = repository.customFields.thebuggenieProjectId\r
-//get path to the thebuggenie client tool which is defined in the gitblit proprties files\r
-def tbgCliPath = gitblit.getString('thebuggenie.tbg_cli', '/var/www/thebuggenie/tbg_cli')\r
-def tbgCliDirPath = new File(tbgCliPath).getParent()\r
-\r
-for(command in commands) {\r
-       //fetch all pushed commits\r
-       def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse()\r
-       for (commit in commits) {\r
-               //get hashes and author data of commit\r
-               def oldhash = commit.getParent(0).getId().getName()\r
-               def newhash = commit.getId().getName()\r
-               def authorIdent = commit.getAuthorIdent()\r
-               def author = "${authorIdent.name} <${authorIdent.emailAddress}>"\r
-               //fetch all changed files of the commit\r
-               def files = JGitUtils.getFilesInCommit(r,commit)\r
-               def changedFiles = ""\r
-               for (f in files) {\r
-                       //transform file data to the format which is needed by thebuggenie\r
-                       changedFiles += f.changeType.toString().substring(0,1)+"\t${f.path}\n"\r
-               }\r
-               //ok let's submit all information to thebuggenie by calling the client tool\r
-//             def shc = "$tbgCliPath vcs_integration:report_commit $tbgProjectId \"$author\" $newhash  \"${commit.fullMessage}\" \"$changedFiles\" $oldhash ${commit.commitTime}"\r
-               def shc = [tbgCliPath, "vcs_integration:report_commit", tbgProjectId, author, newhash, commit.getFullMessage(), changedFiles, oldhash, commit.getCommitTime()];\r
-               logger.info("executing in path " + tbgCliDirPath + ": "+shc)\r
-               shc.execute(null, new File(tbgCliDirPath))\r
-       }\r
-}\r
-\r
-// close the repository reference\r
-r.close()\r
index 85b24d55ef03dc18ec53279066c3d7b7339cadbd..75ccf9bdd1ccc40722dadbf09f3c46fa041d88db 100644 (file)
@@ -3,6 +3,30 @@
        xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">\r
 \r
+       <!-- The base folder is used to specify the root location of your Gitblit data.\r
+       \r
+                       ${baseFolder}/gitblit.properties\r
+                       ${baseFolder}/users.conf\r
+                       ${baseFolder}/projects.conf\r
+                       ${baseFolder}/robots.txt\r
+                       ${baseFolder}/git\r
+                       ${baseFolder}/groovy\r
+                       ${baseFolder}/groovy/grape\r
+                       ${baseFolder}/proposals\r
+\r
+               By default, this location is WEB-INF/data.  It is recommended to set this\r
+               path to a location outside your webapps folder that is writable by your\r
+               servlet container.  Gitblit will copy the WEB-INF/data files to that\r
+               location for you when it restarts.  This approach makes upgrading simpler.\r
+               All you have to do is set this parameter for the new release and then\r
+               review the defaults for any new settings.  Settings are always versioned\r
+               with a SINCE x.y.z attribute and also noted in the release changelog.\r
+               -->\r
+       <context-param>\r
+               <param-name>baseFolder</param-name>\r
+               <param-value>${contextFolder}/WEB-INF/data</param-value>\r
+       </context-param>\r
+\r
        <!-- PARAMS --> \r
         \r
        <!-- Gitblit Context Listener --><!-- STRIP      \r
index 4dd1471269a9d7c64664d53e5b82b3e4752fb94c..ca55118442a0e03e557326d6fcb9a923a55ef1d7 100644 (file)
@@ -90,10 +90,16 @@ public class Constants {
        \r
        public static final String R_GITBLIT = "refs/gitblit/";\r
        \r
+       public static final String baseFolder = "baseFolder";\r
+       \r
+       public static final String baseFolder$ = "${" + baseFolder + "}";\r
+       \r
+       public static final String contextFolder$ = "${contextFolder}";\r
+       \r
        public static String getGitBlitVersion() {\r
                return NAME + " v" + VERSION;\r
        }\r
-\r
+       \r
        /**\r
         * Enumeration representing the four access restriction levels.\r
         */\r
index daa9bfbfc481ea4597e4aa3b4c478fc725602229..f66613942d22535920014d8b133c57b63a814dce 100644 (file)
@@ -76,7 +76,7 @@ public class FederationClient {
                }\r
 \r
                // configure the Gitblit singleton for minimal, non-server operation\r
-               GitBlit.self().configureContext(settings, false);\r
+               GitBlit.self().configureContext(settings, null, false);\r
                FederationPullExecutor executor = new FederationPullExecutor(registrations, params.isDaemon);\r
                executor.run();\r
                if (!params.isDaemon) {\r
index e3ecebd839dff4149c2687f9a6d4d9e15d72d5b0..7f06b35cc1d0b42c6a03d5297ffd2db43f92e106 100644 (file)
@@ -163,6 +163,8 @@ public class GitBlit implements ServletContextListener {
        private final ObjectCache<String> projectRepositoriesMarkdownCache = new ObjectCache<String>();\r
 \r
        private ServletContext servletContext;\r
+       \r
+       private File baseFolder;\r
 \r
        private File repositoriesFolder;\r
 \r
@@ -394,12 +396,8 @@ public class GitBlit implements ServletContextListener {
         * @return the file\r
         */\r
        public static File getFileOrFolder(String fileOrFolder) {\r
-               String openShift = System.getenv("OPENSHIFT_DATA_DIR");\r
-               if (!StringUtils.isEmpty(openShift)) {\r
-                       // running on RedHat OpenShift\r
-                       return new File(openShift, fileOrFolder);\r
-               }\r
-               return new File(fileOrFolder);\r
+               return com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$,\r
+                               self().baseFolder, fileOrFolder);\r
        }\r
 \r
        /**\r
@@ -409,7 +407,7 @@ public class GitBlit implements ServletContextListener {
         * @return the repositories folder path\r
         */\r
        public static File getRepositoriesFolder() {\r
-               return getFileOrFolder(Keys.git.repositoriesFolder, "git");\r
+               return getFileOrFolder(Keys.git.repositoriesFolder, "${baseFolder}/git");\r
        }\r
 \r
        /**\r
@@ -419,7 +417,7 @@ public class GitBlit implements ServletContextListener {
         * @return the proposals folder path\r
         */\r
        public static File getProposalsFolder() {\r
-               return getFileOrFolder(Keys.federation.proposalsFolder, "proposals");\r
+               return getFileOrFolder(Keys.federation.proposalsFolder, "${baseFolder}/proposals");\r
        }\r
 \r
        /**\r
@@ -429,9 +427,9 @@ public class GitBlit implements ServletContextListener {
         * @return the Groovy scripts folder path\r
         */\r
        public static File getGroovyScriptsFolder() {\r
-               return getFileOrFolder(Keys.groovy.scriptsFolder, "groovy");\r
+               return getFileOrFolder(Keys.groovy.scriptsFolder, "${baseFolder}/groovy");\r
        }\r
-\r
+       \r
        /**\r
         * Updates the list of server settings.\r
         * \r
@@ -1652,7 +1650,7 @@ public class GitBlit implements ServletContextListener {
                }\r
                RepositoryModel model = new RepositoryModel();\r
                model.isBare = r.isBare();\r
-               File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "git");\r
+               File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "${baseFolder}/git");\r
                if (model.isBare) {\r
                        model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());\r
                } else {\r
@@ -3043,12 +3041,15 @@ public class GitBlit implements ServletContextListener {
         * \r
         * @param settings\r
         */\r
-       public void configureContext(IStoredSettings settings, boolean startFederation) {\r
-               logger.info("Reading configuration from " + settings.toString());\r
+       public void configureContext(IStoredSettings settings, File folder, boolean startFederation) {\r
                this.settings = settings;\r
+               this.baseFolder = folder;\r
 \r
                repositoriesFolder = getRepositoriesFolder();\r
-               logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());\r
+\r
+               logger.info("Gitblit base folder     = " + folder.getAbsolutePath());\r
+               logger.info("Git repositories folder = " + repositoriesFolder.getAbsolutePath());\r
+               logger.info("Gitblit settings        = " + settings.toString());\r
 \r
                // prepare service executors\r
                mailExecutor = new MailExecutor(settings);\r
@@ -3070,7 +3071,7 @@ public class GitBlit implements ServletContextListener {
                serverStatus = new ServerStatus(isGO());\r
 \r
                if (this.userService == null) {\r
-                       String realm = settings.getString(Keys.realm.userService, "users.properties");\r
+                       String realm = settings.getString(Keys.realm.userService, "${baseFolder}/users.properties");\r
                        IUserService loginService = null;\r
                        try {\r
                                // check to see if this "file" is a login service class\r
@@ -3083,7 +3084,7 @@ public class GitBlit implements ServletContextListener {
                }\r
                \r
                // load and cache the project metadata\r
-               projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "projects.conf"), FS.detect());\r
+               projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());\r
                getProjectConfigs();\r
                \r
                // schedule mail engine\r
@@ -3198,39 +3199,63 @@ public class GitBlit implements ServletContextListener {
        public void contextInitialized(ServletContextEvent contextEvent, InputStream referencePropertiesInputStream) {\r
                servletContext = contextEvent.getServletContext();\r
                if (settings == null) {\r
-                       // Gitblit WAR is running in a servlet container\r
+                       // Gitblit is running in a servlet container\r
                        ServletContext context = contextEvent.getServletContext();\r
                        WebXmlSettings webxmlSettings = new WebXmlSettings(context);\r
-\r
-                       // gitblit.properties file located within the webapp\r
-                       String webProps = context.getRealPath("/WEB-INF/gitblit.properties");\r
-                       if (!StringUtils.isEmpty(webProps)) {\r
-                               File overrideFile = new File(webProps);\r
-                               webxmlSettings.applyOverrides(overrideFile);\r
-                       }\r
+                       File contextFolder = new File(context.getRealPath("/"));\r
+                       String openShift = System.getenv("OPENSHIFT_DATA_DIR");\r
                        \r
-                       // gitblit.properties file located outside the deployed war\r
-                       // folder lie, for example, on RedHat OpenShift.\r
-                       File overrideFile = getFileOrFolder("gitblit.properties");\r
-                       if (!overrideFile.getPath().equals("gitblit.properties")) {\r
+                       if (!StringUtils.isEmpty(openShift)) {\r
+                               // Gitblit is running in OpenShift/JBoss\r
+                               File base = new File(openShift);\r
+\r
+                               // gitblit.properties setting overrides\r
+                               File overrideFile = new File(base, "gitblit.properties");\r
                                webxmlSettings.applyOverrides(overrideFile);\r
-                       }\r
-                       \r
-                       configureContext(webxmlSettings, true);\r
-\r
-                       // Copy the included scripts to the configured groovy folder\r
-                       File localScripts = getFileOrFolder(Keys.groovy.scriptsFolder, "groovy");\r
-                       if (!localScripts.exists()) {\r
-                               File includedScripts = new File(context.getRealPath("/WEB-INF/groovy"));\r
-                               if (!includedScripts.equals(localScripts)) {\r
-                                       try {\r
-                                               com.gitblit.utils.FileUtils.copy(localScripts, includedScripts.listFiles());\r
-                                       } catch (IOException e) {\r
-                                               logger.error(MessageFormat.format(\r
-                                                               "Failed to copy included Groovy scripts from {0} to {1}",\r
-                                                               includedScripts, localScripts));\r
+                               \r
+                               // Copy the included scripts to the configured groovy folder\r
+                               File localScripts = new File(base, webxmlSettings.getString(Keys.groovy.scriptsFolder, "groovy"));\r
+                               if (!localScripts.exists()) {\r
+                                       File warScripts = new File(contextFolder, "/WEB-INF/data/groovy");\r
+                                       if (!warScripts.equals(localScripts)) {\r
+                                               try {\r
+                                                       com.gitblit.utils.FileUtils.copy(localScripts, warScripts.listFiles());\r
+                                               } catch (IOException e) {\r
+                                                       logger.error(MessageFormat.format(\r
+                                                                       "Failed to copy included Groovy scripts from {0} to {1}",\r
+                                                                       warScripts, localScripts));\r
+                                               }\r
                                        }\r
                                }\r
+                               \r
+                               // configure context using the web.xml\r
+                               configureContext(webxmlSettings, base, true);\r
+                       } else {\r
+                               // Gitblit is running in a standard servlet container\r
+                               logger.info("WAR contextFolder is " + contextFolder.getAbsolutePath());\r
+                               \r
+                               String path = webxmlSettings.getString(Constants.baseFolder, Constants.contextFolder$ + "/WEB-INF/data");\r
+                               File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path);\r
+                               base.mkdirs();\r
+                               \r
+                               // try to copy the data folder contents to the baseFolder\r
+                               File localSettings = new File(base, "gitblit.properties");\r
+                               if (!localSettings.exists()) {\r
+                                       File contextData = new File(contextFolder, "/WEB-INF/data");\r
+                                       if (!base.equals(contextData)) {\r
+                                               try {\r
+                                                       com.gitblit.utils.FileUtils.copy(base, contextData.listFiles());\r
+                                               } catch (IOException e) {\r
+                                                       logger.error(MessageFormat.format(\r
+                                                                       "Failed to copy included data from {0} to {1}",\r
+                                                               contextData, base));\r
+                                               }\r
+                                       }\r
+                               }\r
+                               \r
+                               // delegate all config to baseFolder/gitblit.properties file\r
+                               FileSettings settings = new FileSettings(localSettings.getAbsolutePath());                              \r
+                               configureContext(settings, base, true);\r
                        }\r
                }\r
                \r
index 4c0e89f6c5139912b976364e8c075cebd1507f08..feddb93f29b04f53a8d74032dcf31c597932288b 100644 (file)
@@ -84,10 +84,29 @@ public class GitBlitServer {
        private static Logger logger;\r
 \r
        public static void main(String... args) {\r
+               // filter out the baseFolder parameter\r
+               List<String> filtered = new ArrayList<String>();\r
+               String folder = "data";\r
+               for (int i = 0; i< args.length; i++) {\r
+                       String arg = args[i];\r
+                       if (arg.equals("--baseFolder")) {\r
+                               if (i + 1 == args.length) {\r
+                                       System.out.println("Invalid --baseFolder parameter!");\r
+                                       System.exit(-1);\r
+                               } else if (args[i + 1] != ".") {\r
+                                       folder = args[i + 1];\r
+                               }\r
+                               i = i + 1;\r
+                       } else {\r
+                               filtered.add(arg);\r
+                       }\r
+               }\r
+               \r
+               Params.baseFolder = folder;\r
                Params params = new Params();\r
                JCommander jc = new JCommander(params);\r
                try {\r
-                       jc.parse(args);\r
+                       jc.parse(filtered.toArray(new String[filtered.size()]));\r
                        if (params.help) {\r
                                usage(jc, null);\r
                        }\r
@@ -147,13 +166,13 @@ public class GitBlitServer {
         * Start Gitblit GO.\r
         */\r
        private static void start(Params params) {\r
-               FileSettings settings = Params.FILESETTINGS;\r
+               final File baseFolder = new File(Params.baseFolder).getAbsoluteFile();\r
+               FileSettings settings = params.FILESETTINGS;\r
                if (!StringUtils.isEmpty(params.settingsfile)) {\r
                        if (new File(params.settingsfile).exists()) {\r
                                settings = new FileSettings(params.settingsfile);                               \r
                        }\r
                }\r
-\r
                logger = LoggerFactory.getLogger(GitBlitServer.class);\r
                logger.info(Constants.BORDER);\r
                logger.info("            _____  _  _    _      _  _  _");\r
@@ -197,11 +216,10 @@ public class GitBlitServer {
 \r
                // conditionally configure the https connector\r
                if (params.securePort > 0) {\r
-                       final File folder = new File(System.getProperty("user.dir"));\r
-                       File certificatesConf = new File(folder, X509Utils.CA_CONFIG);\r
-                       File serverKeyStore = new File(folder, X509Utils.SERVER_KEY_STORE);\r
-                       File serverTrustStore = new File(folder, X509Utils.SERVER_TRUST_STORE);\r
-                       File caRevocationList = new File(folder, X509Utils.CA_REVOCATION_LIST);\r
+                       File certificatesConf = new File(baseFolder, X509Utils.CA_CONFIG);\r
+                       File serverKeyStore = new File(baseFolder, X509Utils.SERVER_KEY_STORE);\r
+                       File serverTrustStore = new File(baseFolder, X509Utils.SERVER_TRUST_STORE);\r
+                       File caRevocationList = new File(baseFolder, X509Utils.CA_REVOCATION_LIST);\r
 \r
                        // generate CA & web certificates, create certificate stores\r
                        X509Metadata metadata = new X509Metadata("localhost", params.storePassword);\r
@@ -218,12 +236,12 @@ public class GitBlitServer {
                        }\r
                        \r
                        metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);\r
-                       X509Utils.prepareX509Infrastructure(metadata, folder, new X509Log() {\r
+                       X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {\r
                                @Override\r
                                public void log(String message) {\r
                                        BufferedWriter writer = null;\r
                                        try {\r
-                                               writer = new BufferedWriter(new FileWriter(new File(folder, X509Utils.CERTS + File.separator + "log.txt"), true));\r
+                                               writer = new BufferedWriter(new FileWriter(new File(baseFolder, X509Utils.CERTS + File.separator + "log.txt"), true));\r
                                                writer.write(MessageFormat.format("{0,date,yyyy-MM-dd HH:mm}: {1}", new Date(), message));\r
                                                writer.newLine();\r
                                                writer.flush();\r
@@ -277,7 +295,7 @@ public class GitBlitServer {
 \r
                // tempDir is where the embedded Gitblit web application is expanded and\r
                // where Jetty creates any necessary temporary files\r
-               File tempDir = new File(params.temp);\r
+               File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);            \r
                if (tempDir.exists()) {\r
                        try {\r
                                FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);\r
@@ -361,7 +379,7 @@ public class GitBlitServer {
 \r
                // Setup the GitBlit context\r
                GitBlit gitblit = GitBlit.self();\r
-               gitblit.configureContext(settings, true);\r
+               gitblit.configureContext(settings, baseFolder, true);\r
                rootContext.addEventListener(gitblit);\r
 \r
                try {\r
@@ -532,7 +550,9 @@ public class GitBlitServer {
        @Parameters(separators = " ")\r
        private static class Params {\r
 \r
-               private static final FileSettings FILESETTINGS = new FileSettings(Constants.PROPERTIES_FILE);\r
+               public static String baseFolder;\r
+\r
+               private final FileSettings FILESETTINGS = new FileSettings(new File(baseFolder, Constants.PROPERTIES_FILE).getAbsolutePath());\r
 \r
                /*\r
                 * Server parameters\r
@@ -551,14 +571,14 @@ public class GitBlitServer {
                 */\r
                @Parameter(names = { "--repositoriesFolder" }, description = "Git Repositories Folder")\r
                public String repositoriesFolder = FILESETTINGS.getString(Keys.git.repositoriesFolder,\r
-                               "repos");\r
+                               "git");\r
 \r
                /*\r
                 * Authentication Parameters\r
                 */\r
                @Parameter(names = { "--userService" }, description = "Authentication and Authorization Service (filename or fully qualified classname)")\r
                public String userService = FILESETTINGS.getString(Keys.realm.userService,\r
-                               "users.properties");\r
+                               "users.conf");\r
 \r
                /*\r
                 * JETTY Parameters\r
@@ -567,10 +587,10 @@ public class GitBlitServer {
                public Boolean useNIO = FILESETTINGS.getBoolean(Keys.server.useNio, true);\r
 \r
                @Parameter(names = "--httpPort", description = "HTTP port for to serve. (port <= 0 will disable this connector)")\r
-               public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 80);\r
+               public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 0);\r
 \r
                @Parameter(names = "--httpsPort", description = "HTTPS port to serve.  (port <= 0 will disable this connector)")\r
-               public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 443);\r
+               public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 8443);\r
 \r
                @Parameter(names = "--ajpPort", description = "AJP port to serve.  (port <= 0 will disable this connector)")\r
                public Integer ajpPort = FILESETTINGS.getInteger(Keys.server.ajpPort, 0);\r
index ff1ea7e9004527d0136dcb048e54056d97ca7406..77be963f0933f309eada352368d5aaf2201aaec2 100644 (file)
@@ -86,7 +86,7 @@ public class GitServlet extends org.eclipse.jgit.http.server.GitServlet {
                groovyDir = GitBlit.getGroovyScriptsFolder();\r
                try {\r
                        // set Grape root\r
-                       File grapeRoot = new File(GitBlit.getString(Keys.groovy.grapeFolder, "groovy/grape")).getAbsoluteFile();\r
+                       File grapeRoot = GitBlit.getFileOrFolder(Keys.groovy.grapeFolder, "${baseFolder}/groovy/grape").getAbsoluteFile();\r
                        grapeRoot.mkdirs();\r
                        System.setProperty("grape.root", grapeRoot.getAbsolutePath());\r
                        \r
index db450cfcaadfa8f0f5e2c09d786e7c91e69dbef8..37f22b0151600f2b3d54cf900f53160a03ee177d 100644 (file)
@@ -60,7 +60,7 @@ public class GitblitUserService implements IUserService {
 \r
        @Override\r
        public void setup(IStoredSettings settings) {\r
-               File realmFile = GitBlit.getFileOrFolder(Keys.realm.userService, "users.conf");\r
+               File realmFile = GitBlit.getFileOrFolder(Keys.realm.userService, "${baseFolder}/users.conf");\r
                serviceImpl = createUserService(realmFile);\r
                logger.info("GUS delegating to " + serviceImpl.toString());\r
        }\r
index 3c032b5673895a689e7a360256e29304bd838c77..595c65899f00b76ae734e9d5551143115971b48f 100644 (file)
@@ -61,7 +61,7 @@ public class LdapUserService extends GitblitUserService {
        @Override\r
        public void setup(IStoredSettings settings) {\r
                this.settings = settings;\r
-               String file = settings.getString(Keys.realm.ldap.backingUserService, "users.conf");\r
+               String file = settings.getString(Keys.realm.ldap.backingUserService, "${baseFolder}/users.conf");\r
                File realmFile = GitBlit.getFileOrFolder(file);\r
 \r
                serviceImpl = createUserService(realmFile);\r
index 84194d5b37f9820e1374ba9acc4f251dc42961b4..9d571e374d3503d6deb95cf1b34fa6a2d7427c33 100644 (file)
@@ -47,7 +47,7 @@ public class RedmineUserService extends GitblitUserService {
     public void setup(IStoredSettings settings) {\r
         this.settings = settings;\r
 \r
-        String file = settings.getString(Keys.realm.redmine.backingUserService, "users.conf");\r
+        String file = settings.getString(Keys.realm.redmine.backingUserService, "${baseFolder}/users.conf");\r
         File realmFile = GitBlit.getFileOrFolder(file);\r
 \r
         serviceImpl = createUserService(realmFile);\r
index c142be0dd6e6f952c9228ee31d1a95e767e8c88b..d66ebf43241b9a0a29aa147ffbf30ac3ec05d7a0 100644 (file)
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;\r
 \r
 import com.gitblit.utils.FileUtils;\r
-import com.gitblit.utils.StringUtils;\r
 \r
 /**\r
  * Handles requests for robots.txt\r
@@ -55,13 +54,10 @@ public class RobotsTxtServlet extends HttpServlet {
        protected void processRequest(javax.servlet.http.HttpServletRequest request,\r
                        javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,\r
                        java.io.IOException {\r
-               String robotstxt = GitBlit.getString(Keys.web.robots.txt, null);                \r
+               File file = GitBlit.getFileOrFolder(Keys.web.robots.txt, null);\r
                String content = "";\r
-               if (!StringUtils.isEmpty(robotstxt)) {\r
-                       File robotsfile = new File(robotstxt);\r
-                       if (robotsfile.exists()) {\r
-                               content = FileUtils.readContent(robotsfile, "\n");\r
-                       }\r
+               if (file.exists()) {\r
+                       content = FileUtils.readContent(file, "\n");\r
                }\r
                response.getWriter().append(content);\r
        }\r
index 909831fe9cf71f09fbb9b81d0dc53131fc8a2ac7..c3d81848f1bf599262dafffc45b10231a14744f9 100644 (file)
@@ -138,6 +138,21 @@ public class GitblitAuthority extends JFrame implements X509Log {
        private JButton newSSLCertificate;\r
 \r
        public static void main(String... args) {\r
+               // filter out the baseFolder parameter\r
+               String folder = "data";\r
+               for (int i = 0; i< args.length; i++) {\r
+                       String arg = args[i];\r
+                       if (arg.equals("--baseFolder")) {\r
+                               if (i + 1 == args.length) {\r
+                                       System.out.println("Invalid --baseFolder parameter!");\r
+                                       System.exit(-1);\r
+                               } else if (args[i + 1] != ".") {\r
+                                       folder = args[i+1];\r
+                               }\r
+                               break;\r
+                       }\r
+               }\r
+               final String baseFolder = folder;\r
                EventQueue.invokeLater(new Runnable() {\r
                        public void run() {\r
                                try {\r
@@ -145,7 +160,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
                                } catch (Exception e) {\r
                                }\r
                                GitblitAuthority authority = new GitblitAuthority();\r
-                               authority.initialize();\r
+                               authority.initialize(baseFolder);\r
                                authority.setLocationRelativeTo(null);\r
                                authority.setVisible(true);\r
                        }\r
@@ -158,7 +173,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
                defaultSorter = new TableRowSorter<UserCertificateTableModel>(tableModel);\r
        }\r
        \r
-       public void initialize() {\r
+       public void initialize(String baseFolder) {\r
                setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());\r
                setTitle("Gitblit Certificate Authority v" + Constants.VERSION + " (" + Constants.VERSION_DATE + ")");\r
                setContentPane(getUI());\r
@@ -174,10 +189,10 @@ public class GitblitAuthority extends JFrame implements X509Log {
                        }\r
                });             \r
 \r
-               setSizeAndPosition();\r
-               \r
-               File folder = new File(System.getProperty("user.dir"));\r
+               File folder = new File(baseFolder).getAbsoluteFile();\r
                load(folder);\r
+               \r
+               setSizeAndPosition();\r
        }\r
        \r
        private void setSizeAndPosition() {\r
@@ -230,7 +245,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
        }\r
        \r
        private StoredConfig getConfig() throws IOException, ConfigInvalidException {\r
-               File configFile  = new File(System.getProperty("user.dir"), X509Utils.CA_CONFIG);\r
+               File configFile  = new File(folder, X509Utils.CA_CONFIG);\r
                FileBasedConfig config = new FileBasedConfig(configFile, FS.detect());\r
                config.load();\r
                return config;\r
@@ -243,30 +258,31 @@ public class GitblitAuthority extends JFrame implements X509Log {
                }\r
                gitblitSettings = new FileSettings(file.getAbsolutePath());\r
                mail = new MailExecutor(gitblitSettings);\r
-               String us = gitblitSettings.getString(Keys.realm.userService, "users.conf");\r
+               String us = gitblitSettings.getString(Keys.realm.userService, "${baseFolder}/users.conf");\r
                String ext = us.substring(us.lastIndexOf(".") + 1).toLowerCase();\r
                IUserService service = null;\r
                if (!ext.equals("conf") && !ext.equals("properties")) {\r
                        if (us.equals("com.gitblit.LdapUserService")) {\r
-                               us = gitblitSettings.getString(Keys.realm.ldap.backingUserService, "users.conf");               \r
+                               us = gitblitSettings.getString(Keys.realm.ldap.backingUserService, "${baseFolder}/users.conf");         \r
                        } else if (us.equals("com.gitblit.LdapUserService")) {\r
-                               us = gitblitSettings.getString(Keys.realm.redmine.backingUserService, "users.conf");\r
+                               us = gitblitSettings.getString(Keys.realm.redmine.backingUserService, "${baseFolder}/users.conf");\r
                        }\r
                }\r
 \r
                if (us.endsWith(".conf")) {\r
-                       service = new ConfigUserService(new File(us));\r
+                       service = new ConfigUserService(FileUtils.resolveParameter(Constants.baseFolder$, folder, us));\r
                } else {\r
                        throw new RuntimeException("Unsupported user service: " + us);\r
                }\r
                \r
-               service = new ConfigUserService(new File(us));\r
+               service = new ConfigUserService(FileUtils.resolveParameter(Constants.baseFolder$, folder, us));\r
                return service;\r
        }\r
        \r
        private void load(File folder) {\r
                this.folder = folder;\r
                this.userService = loadUsers(folder);\r
+               System.out.println(Constants.baseFolder$ + " set to " + folder);\r
                if (userService == null) {\r
                        JOptionPane.showMessageDialog(this, MessageFormat.format("Sorry, {0} doesn't look like a Gitblit GO installation.", folder));\r
                } else {\r
index 336c45de350cd85aa286f7b8e26a6f059ae07fa4..ecc072af55f3ab8f6bb39f05c814053b4c114241 100644 (file)
@@ -217,7 +217,7 @@ public class Build {
                Properties properties = new Properties();\r
                FileInputStream is = null;\r
                try {\r
-                       is = new FileInputStream(Constants.PROPERTIES_FILE);\r
+                       is = new FileInputStream(new File("distrib", Constants.PROPERTIES_FILE));\r
                        properties.load(is);\r
                } catch (Throwable t) {\r
                        t.printStackTrace();\r
index 4fcc6e97564e3ebec2c63a770e24ea2ecf948961..49a12ab24be6f8bcf73ae3bfdb13c2a14964a308 100644 (file)
@@ -60,44 +60,44 @@ public class BuildWebXml {
        }\r
 \r
        private static void generateWebXml(Params params) throws Exception {\r
+               StringBuilder parameters = new StringBuilder();\r
                // Read the current Gitblit properties\r
-               BufferedReader propertiesReader = new BufferedReader(new FileReader(new File(\r
-                               params.propertiesFile)));\r
-\r
-               Vector<Setting> settings = new Vector<Setting>();\r
-               List<String> comments = new ArrayList<String>();\r
-               String line = null;\r
-               while ((line = propertiesReader.readLine()) != null) {\r
-                       if (line.length() == 0) {\r
-                               comments.clear();\r
-                       } else {\r
-                               if (line.charAt(0) == '#') {\r
-                                       if (line.length() > 1) {\r
-                                               comments.add(line.substring(1).trim());\r
-                                       }\r
+               if (params.propertiesFile != null) {\r
+                       BufferedReader propertiesReader = new BufferedReader(new FileReader(new File(\r
+                                       params.propertiesFile)));\r
+\r
+                       Vector<Setting> settings = new Vector<Setting>();\r
+                       List<String> comments = new ArrayList<String>();\r
+                       String line = null;\r
+                       while ((line = propertiesReader.readLine()) != null) {\r
+                               if (line.length() == 0) {\r
+                                       comments.clear();\r
                                } else {\r
-                                       String[] kvp = line.split("=", 2);\r
-                                       String key = kvp[0].trim();\r
-                                       if (!skipKey(key)) {\r
-                                               Setting s = new Setting(key, kvp[1].trim(), comments);\r
-                                               settings.add(s);\r
+                                       if (line.charAt(0) == '#') {\r
+                                               if (line.length() > 1) {\r
+                                                       comments.add(line.substring(1).trim());\r
+                                               }\r
+                                       } else {\r
+                                               String[] kvp = line.split("=", 2);\r
+                                               String key = kvp[0].trim();\r
+                                               if (!skipKey(key)) {\r
+                                                       Setting s = new Setting(key, kvp[1].trim(), comments);\r
+                                                       settings.add(s);\r
+                                               }\r
+                                               comments.clear();\r
                                        }\r
-                                       comments.clear();\r
                                }\r
                        }\r
-               }\r
-               propertiesReader.close();\r
+                       propertiesReader.close();\r
 \r
-               StringBuilder parameters = new StringBuilder();\r
-\r
-               for (Setting setting : settings) {\r
-                       for (String comment : setting.comments) {\r
-                               parameters.append(MessageFormat.format(COMMENT_PATTERN, comment));\r
+                       for (Setting setting : settings) {\r
+                               for (String comment : setting.comments) {\r
+                                       parameters.append(MessageFormat.format(COMMENT_PATTERN, comment));\r
+                               }\r
+                               parameters.append(MessageFormat.format(PARAM_PATTERN, setting.name,\r
+                                               StringUtils.escapeForHtml(setting.value, false)));\r
                        }\r
-                       parameters.append(MessageFormat.format(PARAM_PATTERN, setting.name,\r
-                                       StringUtils.escapeForHtml(setting.value, false)));\r
                }\r
-\r
                // Read the prototype web.xml file\r
                File webxml = new File(params.sourceFile);\r
                char[] buffer = new char[(int) webxml.length()];\r
@@ -150,11 +150,11 @@ public class BuildWebXml {
                @Parameter(names = { "--sourceFile" }, description = "Source web.xml file", required = true)\r
                public String sourceFile;\r
 \r
-               @Parameter(names = { "--propertiesFile" }, description = "Properties settings file", required = true)\r
+               @Parameter(names = { "--propertiesFile" }, description = "Properties settings file")\r
                public String propertiesFile;\r
 \r
                @Parameter(names = { "--destinationFile" }, description = "Destination web.xml file", required = true)\r
                public String destinationFile;\r
-\r
+               \r
        }\r
 }\r
index 083486709d82bcc47b62275cb24ebc0f8e3c6724..a21b5128b2a125726e55826c4d06dab673dd20a9 100644 (file)
@@ -274,4 +274,19 @@ public class FileUtils {
                        return path.getAbsoluteFile();\r
                }\r
        }\r
+\r
+       public static File resolveParameter(String parameter, File aFolder, String path) {\r
+               if (aFolder == null) {\r
+                       // strip any parameter reference                \r
+                       path = path.replace(parameter, "").trim();\r
+                       if (path.length() > 0 && path.charAt(0) == '/') {\r
+                               // strip leading /\r
+                               path = path.substring(1);\r
+                       }\r
+               } else if (path.contains(parameter)) {\r
+                       // replace parameter with path\r
+                       path = path.replace(parameter, aFolder.getAbsolutePath());\r
+               }\r
+               return new File(path);\r
+       }\r
 }\r
index 3741853f4f32bc41701001e2684ca1906362c1a0..c4014208f00164ca2c56fe3cdbe7d7c325ec9bce 100644 (file)
@@ -54,7 +54,7 @@ public class ChangePasswordPage extends RootSubPage {
                UserModel user = GitBlitWebSession.get().getUser();             \r
                if (!GitBlit.self().supportsCredentialChanges(user)) {\r
                        error(MessageFormat.format(getString("gb.userServiceDoesNotPermitPasswordChanges"),\r
-                                       GitBlit.getString(Keys.realm.userService, "users.conf")), true);\r
+                                       GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
                }\r
                \r
                setupPage(getString("gb.changePassword"), user.username);\r
index 4939e97c22f0b67ce6396c3ba6f166d33401dce5..c060f237ba7caefd76022df2c9bfaccc94e60b24 100644 (file)
@@ -57,7 +57,7 @@ public class EditUserPage extends RootSubPage {
                super();\r
                if (!GitBlit.self().supportsAddUser()) {\r
                        error(MessageFormat.format(getString("gb.userServiceDoesNotPermitAddUser"),\r
-                                       GitBlit.getString(Keys.realm.userService, "users.conf")), true);\r
+                                       GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
                }\r
                isCreate = true;\r
                setupPage(new UserModel(""));\r
index 4816d45cd5cae170ee0e9f21ce1d591afa781455..4bce77f552467292951cc2bd12a2976da375564f 100644 (file)
@@ -119,7 +119,7 @@ public class RepositoriesPage extends RootPage {
                } else {\r
                        // Read user-supplied message\r
                        if (!StringUtils.isEmpty(messageSource)) {\r
-                               File file = new File(messageSource);\r
+                               File file = GitBlit.getFileOrFolder(messageSource);\r
                                if (file.exists()) {\r
                                        try {\r
                                                FileInputStream fis = new FileInputStream(file);\r
index 6997dde72fa39e4c51ef7205b9be0574fe865e37..f16f5c5a8fe5bf44701555561c2d4bf808554770 100644 (file)
@@ -2,10 +2,10 @@
 # Gitblit Unit Testing properties
 #
 
-git.repositoriesFolder = git
+git.repositoriesFolder = ${baseFolder}/git
 git.searchRepositoriesSubfolders = true
 git.enableGitServlet = true
-groovy.scriptsFolder = groovy
+groovy.scriptsFolder = ${baseFolder}/groovy
 groovy.preReceiveScripts = blockpush
 groovy.postReceiveScripts = sendmail
 web.authenticateViewPages = false
@@ -77,7 +77,7 @@ federation.sets = animal mineral vegetable
 #federation.example1.mirror = true 
 #federation.example1.mergeAccounts = true
 
-server.tempFolder = temp
+server.tempFolder = ${baseFolder}/temp
 server.useNio = true
 server.contextPath = /
 server.httpPort = 0
index 5220a6a3c44cd4406bc3eb4a78d2b4b57eff8e5c..b0179c37cc4a535b5a668d09d04bf20802231e00 100644 (file)
@@ -63,7 +63,7 @@ import com.gitblit.utils.JGitUtils;
                FanoutServiceTest.class })\r
 public class GitBlitSuite {\r
 \r
-       public static final File REPOSITORIES = new File("git");\r
+       public static final File REPOSITORIES = new File("data/git");\r
 \r
        static int port = 8280;\r
        static int shutdownPort = 8281;\r
@@ -117,7 +117,8 @@ public class GitBlitSuite {
                                GitBlitServer.main("--httpPort", "" + port, "--httpsPort", "0", "--shutdownPort",\r
                                                "" + shutdownPort, "--repositoriesFolder",\r
                                                "\"" + GitBlitSuite.REPOSITORIES.getAbsolutePath() + "\"", "--userService",\r
-                                               "test-users.conf", "--settings", "test-gitblit.properties");\r
+                                               "test-users.conf", "--settings", "test-gitblit.properties",\r
+                                               "--baseFolder", "data");\r
                        }\r
                });\r
 \r
index 1c9bbd00355d6b0c721250d3af379308f1dcc59a..786614f810e549744250462fc91c41d49573c750 100644 (file)
@@ -138,7 +138,7 @@ public class GitBlitTest {
                assertEquals(5, settings.getInteger("realm.realmFile", 5));\r
 \r
                assertTrue(settings.getBoolean("git.enableGitServlet", false));\r
-               assertEquals("users.conf", settings.getString("realm.userService", null));\r
+               assertEquals("${baseFolder}/users.conf", settings.getString("realm.userService", null));\r
                assertEquals(5, settings.getInteger("realm.minPasswordLength", 0));\r
                List<String> mdExtensions = settings.getStrings("web.markdownExtensions");\r
                assertTrue(mdExtensions.size() > 0);\r