\r
- Do not index blobs in submodules (issue 119)\r
- Restore original user or team object on failure to update (issue 118)\r
+- Fixes to relative path determination in repository search algorithm for symlinks (issue 116)\r
+- Fix to GitServlet to allow pushing to symlinked repositories (issue 116)\r
- Repository URL uses `X-Forwarded-Proto` and `X-Forwarded-Port`, if available, for reverse proxy configurations (issue 115)\r
-- Fixes to relative path determination in repository searh algorithm for symlinks (issue 116)\r
- Output real RAW content, not simulated RAW content (issue 114)\r
- Fixed Lucene charset encoding bug when reindexing a repository (issue 112)\r
- Fixed null pointer in LdapUserSerivce if account has a null email address (issue 110)\r
*/\r
public class GitFilter extends AccessRestrictionFilter {\r
\r
- protected final String gitReceivePack = "/git-receive-pack";\r
+ protected static final String gitReceivePack = "/git-receive-pack";\r
\r
- protected final String gitUploadPack = "/git-upload-pack";\r
+ protected static final String gitUploadPack = "/git-upload-pack";\r
\r
- protected final String[] suffixes = { gitReceivePack, gitUploadPack, "/info/refs", "/HEAD",\r
+ protected static final String[] suffixes = { gitReceivePack, gitUploadPack, "/info/refs", "/HEAD",\r
"/objects" };\r
\r
/**\r
* @param url\r
* @return repository name\r
*/\r
- @Override\r
- protected String extractRepositoryName(String url) {\r
- String repository = url;\r
+ public static String getRepositoryName(String value) {\r
+ String repository = value;\r
// get the repository name from the url by finding a known url suffix\r
for (String urlSuffix : suffixes) {\r
if (repository.indexOf(urlSuffix) > -1) {\r
return repository;\r
}\r
\r
+ /**\r
+ * Extract the repository name from the url.\r
+ * \r
+ * @param url\r
+ * @return repository name\r
+ */\r
+ @Override\r
+ protected String extractRepositoryName(String url) {\r
+ return GitFilter.getRepositoryName(url);\r
+ }\r
+\r
/**\r
* Analyze the url and returns the action of the request. Return values are\r
* either "/git-receive-pack" or "/git-upload-pack".\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.ClientLogger;\r
-import com.gitblit.utils.FileUtils;\r
import com.gitblit.utils.HttpUtils;\r
import com.gitblit.utils.StringUtils;\r
\r
@Override\r
public ReceivePack create(HttpServletRequest req, Repository db)\r
throws ServiceNotEnabledException, ServiceNotAuthorizedException {\r
- ReceivePack rp = super.create(req, db);\r
+ \r
+ // determine repository name from request\r
+ String repositoryName = req.getPathInfo().substring(1);\r
+ repositoryName = GitFilter.getRepositoryName(repositoryName);\r
+ \r
GitblitReceiveHook hook = new GitblitReceiveHook();\r
+ hook.repositoryName = repositoryName;\r
hook.gitblitUrl = HttpUtils.getGitblitURL(req);\r
+\r
+ ReceivePack rp = super.create(req, db);\r
rp.setPreReceiveHook(hook);\r
rp.setPostReceiveHook(hook);\r
return rp;\r
\r
protected final Logger logger = LoggerFactory.getLogger(GitblitReceiveHook.class);\r
\r
+ protected String repositoryName;\r
+ \r
protected String gitblitUrl;\r
\r
/**\r
*/\r
@Override\r
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {\r
- RepositoryModel repository = getRepositoryModel(rp);\r
+ RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName);\r
Set<String> scripts = new LinkedHashSet<String>();\r
scripts.addAll(GitBlit.self().getPreReceiveScriptsInherited(repository));\r
scripts.addAll(repository.preReceiveScripts);\r
logger.info("skipping post-receive hooks, no refs created, updated, or removed");\r
return;\r
}\r
- RepositoryModel repository = getRepositoryModel(rp);\r
+ RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName);\r
Set<String> scripts = new LinkedHashSet<String>();\r
scripts.addAll(GitBlit.self().getPostReceiveScriptsInherited(repository));\r
scripts.addAll(repository.postReceiveScripts);\r
// runNativeScript(rp, "hooks/post-receive", commands);\r
}\r
\r
- /**\r
- * Returns the RepositoryModel for the repository we are pushing into.\r
- * \r
- * @param rp\r
- * @return a RepositoryModel\r
- */\r
- protected RepositoryModel getRepositoryModel(ReceivePack rp) {\r
- Repository repository = rp.getRepository();\r
- String repositoryName = FileUtils.getRelativePath(GitBlit.getRepositoriesFolder(), repository.getDirectory());\r
- RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
- return model;\r
- }\r
-\r
/**\r
* Returns the UserModel for the user pushing the changes.\r
* \r