| | |
| | | * Adds the repository to the list of cached repositories if Gitblit is
|
| | | * configured to cache the repository list.
|
| | | *
|
| | | * @param name
|
| | | * @param model
|
| | | */
|
| | | private void addToCachedRepositoryList(String name, RepositoryModel model) {
|
| | | private void addToCachedRepositoryList(RepositoryModel model) {
|
| | | if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
|
| | | repositoryListCache.put(name, model);
|
| | | repositoryListCache.put(model.name, model);
|
| | |
|
| | | // update the fork origin repository with this repository clone
|
| | | if (!StringUtils.isEmpty(model.originRepository)) {
|
| | | if (repositoryListCache.containsKey(model.originRepository)) {
|
| | | RepositoryModel origin = repositoryListCache.get(model.originRepository);
|
| | | origin.addFork(name);
|
| | | origin.addFork(model.name);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (model == null) {
|
| | | return null;
|
| | | }
|
| | | addToCachedRepositoryList(repositoryName, model);
|
| | | addToCachedRepositoryList(model);
|
| | | return model;
|
| | | }
|
| | |
|
| | |
| | | logger.info(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
|
| | | model = loadRepositoryModel(repositoryName);
|
| | | removeFromCachedRepositoryList(repositoryName);
|
| | | addToCachedRepositoryList(repositoryName, model);
|
| | | addToCachedRepositoryList(model);
|
| | | } else {
|
| | | // update a few repository parameters
|
| | | if (!model.hasCommits) {
|
| | |
| | | return null;
|
| | | }
|
| | | RepositoryModel model = new RepositoryModel();
|
| | | model.name = repositoryName;
|
| | | model.isBare = r.isBare();
|
| | | File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "git");
|
| | | if (model.isBare) {
|
| | | model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());
|
| | | } else {
|
| | | model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());
|
| | | }
|
| | | model.hasCommits = JGitUtils.hasCommits(r);
|
| | | model.lastChange = JGitUtils.getLastChange(r);
|
| | | model.isBare = r.isBare();
|
| | | if (repositoryName.indexOf('/') == -1) {
|
| | | model.projectPath = "";
|
| | | } else {
|
| | |
| | | Constants.CONFIG_GITBLIT, null, "federationSets")));
|
| | | model.isFederated = getConfig(config, "isFederated", false);
|
| | | model.origin = config.getString("remote", "origin", "url");
|
| | | if (model.origin != null) {
|
| | | model.origin = model.origin.replace('\\', '/');
|
| | | }
|
| | | model.preReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(
|
| | | Constants.CONFIG_GITBLIT, null, "preReceiveScript")));
|
| | | model.postReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(
|
| | |
| | |
|
| | | private ForkModel getForkModel(String repository) {
|
| | | RepositoryModel model = repositoryListCache.get(repository);
|
| | | ForkModel fork = new ForkModel(model.originRepository, model.name);
|
| | | ForkModel fork = new ForkModel(model);
|
| | | if (!ArrayUtils.isEmpty(model.forks)) {
|
| | | for (String aFork : model.forks) {
|
| | | ForkModel fm = getForkModel(aFork);
|
| | |
| | | // update repository cache
|
| | | removeFromCachedRepositoryList(repositoryName);
|
| | | // model will actually be replaced on next load because config is stale
|
| | | addToCachedRepositoryList(repository.name, repository);
|
| | | addToCachedRepositoryList(repository);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | // add this clone to the cached model
|
| | | addToCachedRepositoryList(cloneModel.name, cloneModel);
|
| | | addToCachedRepositoryList(cloneModel);
|
| | | return cloneModel;
|
| | | }
|
| | | }
|