From c5069a16da0a78d349b9c86b9d66dd4799257476 Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 25 Nov 2013 00:12:31 -0500 Subject: [PATCH] Serve repositories on /r in addition to /git Change-Id: I3cd332a6509e434d901e1b262600f4c8ce57752b --- releases.moxie | 1 + src/main/java/com/gitblit/Constants.java | 2 ++ src/main/java/com/gitblit/git/GitServlet.java | 2 -- .../java/com/gitblit/manager/FederationManager.java | 2 +- src/main/java/com/gitblit/manager/GitblitManager.java | 2 +- src/main/java/com/gitblit/servlet/GitFilter.java | 10 +++------- src/main/java/com/gitblit/servlet/GitblitContext.java | 3 ++- src/main/java/com/gitblit/servlet/RpcServlet.java | 7 ++----- .../com/gitblit/servlet/SparkleShareInviteServlet.java | 5 ++--- 9 files changed, 14 insertions(+), 20 deletions(-) diff --git a/releases.moxie b/releases.moxie index d834f230..3f9c0744 100644 --- a/releases.moxie +++ b/releases.moxie @@ -36,6 +36,7 @@ r20: { - Removed the repository setting to enable Markdown document enumeration, this is now automatic and expanded - Retrieve LDAP groups with dereferencing aliases (pr-122) - Revised committer verification to require a matching displayname or account name AND the email address + - Serve repositories on both /r and /git, displaying /r because it is shorter additions: - Added an optional MirrorExecutor which will periodically fetch ref updates from source repositories for mirrors (issue-5). Repositories must be manually cloned using native git and "--mirror". - Added branch graph image servlet based on EGit's branch graph renderer (issue-194) diff --git a/src/main/java/com/gitblit/Constants.java b/src/main/java/com/gitblit/Constants.java index 439a944d..ee6de45d 100644 --- a/src/main/java/com/gitblit/Constants.java +++ b/src/main/java/com/gitblit/Constants.java @@ -52,6 +52,8 @@ public class Constants { public static final String DEFAULT_USER_REPOSITORY_PREFIX = "~"; + public static final String R_PATH = "/r/"; + public static final String GIT_PATH = "/git/"; public static final String ZIP_PATH = "/zip/"; diff --git a/src/main/java/com/gitblit/git/GitServlet.java b/src/main/java/com/gitblit/git/GitServlet.java index c5119424..ff50ad60 100644 --- a/src/main/java/com/gitblit/git/GitServlet.java +++ b/src/main/java/com/gitblit/git/GitServlet.java @@ -16,7 +16,6 @@ package com.gitblit.git; import javax.inject.Inject; -import javax.inject.Singleton; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -30,7 +29,6 @@ import com.gitblit.GitBlit; * @author James Moger * */ -@Singleton public class GitServlet extends org.eclipse.jgit.http.server.GitServlet { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/gitblit/manager/FederationManager.java b/src/main/java/com/gitblit/manager/FederationManager.java index 07d20184..568e87fc 100644 --- a/src/main/java/com/gitblit/manager/FederationManager.java +++ b/src/main/java/com/gitblit/manager/FederationManager.java @@ -357,7 +357,7 @@ public class FederationManager implements IFederationManager { // Determine the Gitblit clone url StringBuilder sb = new StringBuilder(); sb.append(gitblitUrl); - sb.append(Constants.GIT_PATH); + sb.append(Constants.R_PATH); sb.append("{0}"); String cloneUrl = sb.toString(); diff --git a/src/main/java/com/gitblit/manager/GitblitManager.java b/src/main/java/com/gitblit/manager/GitblitManager.java index 9947382a..6395c353 100644 --- a/src/main/java/com/gitblit/manager/GitblitManager.java +++ b/src/main/java/com/gitblit/manager/GitblitManager.java @@ -209,7 +209,7 @@ public class GitblitManager implements IGitblitManager { protected String getRepositoryUrl(HttpServletRequest request, String username, RepositoryModel repository) { StringBuilder sb = new StringBuilder(); sb.append(HttpUtils.getGitblitURL(request)); - sb.append(Constants.GIT_PATH); + sb.append(Constants.R_PATH); sb.append(repository.name); // inject username into repository url if authentication is required diff --git a/src/main/java/com/gitblit/servlet/GitFilter.java b/src/main/java/com/gitblit/servlet/GitFilter.java index c44f7efc..402636ed 100644 --- a/src/main/java/com/gitblit/servlet/GitFilter.java +++ b/src/main/java/com/gitblit/servlet/GitFilter.java @@ -18,18 +18,15 @@ package com.gitblit.servlet; import java.text.MessageFormat; import javax.inject.Inject; -import javax.inject.Singleton; -import com.gitblit.Constants; +import com.gitblit.Constants.AccessRestrictionType; +import com.gitblit.Constants.AuthorizationControl; import com.gitblit.GitBlitException; import com.gitblit.IStoredSettings; import com.gitblit.Keys; -import com.gitblit.Constants.AccessRestrictionType; -import com.gitblit.Constants.AuthorizationControl; -import com.gitblit.Keys.git; +import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IRepositoryManager; import com.gitblit.manager.IRuntimeManager; -import com.gitblit.manager.IAuthenticationManager; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; import com.gitblit.utils.StringUtils; @@ -42,7 +39,6 @@ import com.gitblit.utils.StringUtils; * @author James Moger * */ -@Singleton public class GitFilter extends AccessRestrictionFilter { protected static final String gitReceivePack = "/git-receive-pack"; diff --git a/src/main/java/com/gitblit/servlet/GitblitContext.java b/src/main/java/com/gitblit/servlet/GitblitContext.java index 3e95b4bb..a86ecf68 100644 --- a/src/main/java/com/gitblit/servlet/GitblitContext.java +++ b/src/main/java/com/gitblit/servlet/GitblitContext.java @@ -41,6 +41,7 @@ import com.gitblit.Keys; import com.gitblit.WebXmlSettings; import com.gitblit.dagger.DaggerContextListener; import com.gitblit.git.GitServlet; +import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IFederationManager; import com.gitblit.manager.IGitblitManager; import com.gitblit.manager.IManager; @@ -49,7 +50,6 @@ import com.gitblit.manager.IProjectManager; import com.gitblit.manager.IRepositoryManager; import com.gitblit.manager.IRuntimeManager; import com.gitblit.manager.IServicesManager; -import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IUserManager; import com.gitblit.utils.ContainerUtils; import com.gitblit.utils.StringUtils; @@ -202,6 +202,7 @@ public class GitblitContext extends DaggerContextListener { @Override protected void injectServlets(ServletContext context) { // access restricted servlets + serve(context, Constants.R_PATH, GitServlet.class, GitFilter.class); serve(context, Constants.GIT_PATH, GitServlet.class, GitFilter.class); serve(context, Constants.PAGES, PagesServlet.class, PagesFilter.class); serve(context, Constants.RPC_PATH, RpcServlet.class, RpcFilter.class); diff --git a/src/main/java/com/gitblit/servlet/RpcServlet.java b/src/main/java/com/gitblit/servlet/RpcServlet.java index 3a115b17..a2013b73 100644 --- a/src/main/java/com/gitblit/servlet/RpcServlet.java +++ b/src/main/java/com/gitblit/servlet/RpcServlet.java @@ -32,13 +32,10 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jgit.lib.Repository; import com.gitblit.Constants; +import com.gitblit.Constants.RpcRequest; import com.gitblit.GitBlitException; import com.gitblit.IStoredSettings; import com.gitblit.Keys; -import com.gitblit.Constants.RpcRequest; -import com.gitblit.Keys.federation; -import com.gitblit.Keys.realm; -import com.gitblit.Keys.web; import com.gitblit.manager.IFederationManager; import com.gitblit.manager.IGitblitManager; import com.gitblit.manager.IRepositoryManager; @@ -132,7 +129,7 @@ public class RpcServlet extends JsonServlet { String gitblitUrl = HttpUtils.getGitblitURL(request); StringBuilder sb = new StringBuilder(); sb.append(gitblitUrl); - sb.append(Constants.GIT_PATH); + sb.append(Constants.R_PATH); sb.append("{0}"); String cloneUrl = sb.toString(); diff --git a/src/main/java/com/gitblit/servlet/SparkleShareInviteServlet.java b/src/main/java/com/gitblit/servlet/SparkleShareInviteServlet.java index 3bef51dd..5d2532d4 100644 --- a/src/main/java/com/gitblit/servlet/SparkleShareInviteServlet.java +++ b/src/main/java/com/gitblit/servlet/SparkleShareInviteServlet.java @@ -28,10 +28,9 @@ import javax.servlet.http.HttpServletResponse; import com.gitblit.Constants; import com.gitblit.IStoredSettings; import com.gitblit.Keys; -import com.gitblit.Keys.fanout; +import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IRepositoryManager; import com.gitblit.manager.IRuntimeManager; -import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IUserManager; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; @@ -94,7 +93,7 @@ public class SparkleShareInviteServlet extends HttpServlet { repoUrl = repoUrl.substring(0, repoUrl.length() - 4); } - String servletPath = Constants.GIT_PATH; + String servletPath = Constants.R_PATH; int schemeIndex = repoUrl.indexOf("://") + 3; String host = repoUrl.substring(0, repoUrl.indexOf('/', schemeIndex)); -- 2.39.5