* Adds the repository to the list of cached repositories if Gitblit is\r
* configured to cache the repository list.\r
* \r
- * @param name\r
+ * @param model\r
*/\r
- private void addToCachedRepositoryList(String name, RepositoryModel model) {\r
+ private void addToCachedRepositoryList(RepositoryModel model) {\r
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {\r
- repositoryListCache.put(name, model);\r
+ repositoryListCache.put(model.name, model);\r
\r
// update the fork origin repository with this repository clone\r
if (!StringUtils.isEmpty(model.originRepository)) {\r
if (repositoryListCache.containsKey(model.originRepository)) {\r
RepositoryModel origin = repositoryListCache.get(model.originRepository);\r
- origin.addFork(name);\r
+ origin.addFork(model.name);\r
}\r
}\r
}\r
if (model == null) {\r
return null;\r
}\r
- addToCachedRepositoryList(repositoryName, model);\r
+ addToCachedRepositoryList(model);\r
return model;\r
}\r
\r
logger.info(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));\r
model = loadRepositoryModel(repositoryName);\r
removeFromCachedRepositoryList(repositoryName);\r
- addToCachedRepositoryList(repositoryName, model);\r
+ addToCachedRepositoryList(model);\r
} else {\r
// update a few repository parameters \r
if (!model.hasCommits) {\r
return null;\r
}\r
RepositoryModel model = new RepositoryModel();\r
- model.name = repositoryName;\r
+ model.isBare = r.isBare();\r
+ File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "git");\r
+ if (model.isBare) {\r
+ model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());\r
+ } else {\r
+ model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());\r
+ }\r
model.hasCommits = JGitUtils.hasCommits(r);\r
model.lastChange = JGitUtils.getLastChange(r);\r
- model.isBare = r.isBare();\r
if (repositoryName.indexOf('/') == -1) {\r
model.projectPath = "";\r
} else {\r
// update repository cache\r
removeFromCachedRepositoryList(repositoryName);\r
// model will actually be replaced on next load because config is stale\r
- addToCachedRepositoryList(repository.name, repository);\r
+ addToCachedRepositoryList(repository);\r
}\r
\r
/**\r
}\r
\r
// add this clone to the cached model\r
- addToCachedRepositoryList(cloneModel.name, cloneModel);\r
+ addToCachedRepositoryList(cloneModel);\r
return cloneModel;\r
}\r
}\r