| | |
| | | import com.gitblit.models.GitClientApplication; |
| | | import com.gitblit.models.Metric; |
| | | import com.gitblit.models.ProjectModel; |
| | | import com.gitblit.models.RefModel; |
| | | import com.gitblit.models.RegistrantAccessPermission; |
| | | import com.gitblit.models.RepositoryModel; |
| | | import com.gitblit.models.RepositoryUrl; |
| | |
| | | } |
| | | |
| | | // return sorted copy of cached list |
| | | List<String> list = new ArrayList<String>(repositoryListCache.keySet()); |
| | | List<String> list = new ArrayList<String>(); |
| | | for (RepositoryModel model : repositoryListCache.values()) { |
| | | list.add(model.name); |
| | | } |
| | | StringUtils.sortRepositorynames(list); |
| | | return list; |
| | | } |
| | |
| | | |
| | | if (config != null) { |
| | | model.description = getConfig(config, "description", ""); |
| | | model.originRepository = getConfig(config, "originRepository", null); |
| | | model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", ""))); |
| | | model.useTickets = getConfig(config, "useTickets", false); |
| | | model.useDocs = getConfig(config, "useDocs", false); |
| | |
| | | model.sparkleshareId = JGitUtils.getSparkleshareId(r); |
| | | r.close(); |
| | | |
| | | if (model.origin != null && model.origin.startsWith("file://")) { |
| | | if (StringUtils.isEmpty(model.originRepository) && model.origin != null && model.origin.startsWith("file://")) { |
| | | // repository was cloned locally... perhaps as a fork |
| | | try { |
| | | File folder = new File(new URI(model.origin)); |
| | |
| | | String origin = config.getString("remote", "origin", "url"); |
| | | origin = origin.replace(repositoryName, repository.name); |
| | | config.setString("remote", "origin", "url", origin); |
| | | config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.name); |
| | | config.save(); |
| | | } catch (Exception e) { |
| | | logger.error("Failed to update repository fork config for " + fork, e); |
| | |
| | | } |
| | | } |
| | | |
| | | // remove this repository from any origin model's fork list |
| | | // update this repository's origin's fork list |
| | | if (!StringUtils.isEmpty(repository.originRepository)) { |
| | | RepositoryModel origin = repositoryListCache.get(repository.originRepository); |
| | | if (origin != null && !ArrayUtils.isEmpty(origin.forks)) { |
| | | origin.forks.remove(repositoryName); |
| | | origin.forks.add(repository.name); |
| | | } |
| | | } |
| | | |
| | |
| | | public void updateConfiguration(Repository r, RepositoryModel repository) { |
| | | StoredConfig config = r.getConfig(); |
| | | config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description); |
| | | config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.originRepository); |
| | | config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners)); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs); |
| | |
| | | configureJGit(); |
| | | configureFanout(); |
| | | configureGitDaemon(); |
| | | |
| | | CommitCache.instance().setCacheDays(settings.getInteger(Keys.web.activityCacheDays, 14)); |
| | | |
| | | configureCommitCache(); |
| | | |
| | | ContainerUtils.CVE_2007_0450.test(); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | protected void configureCommitCache() { |
| | | int daysToCache = settings.getInteger(Keys.web.activityCacheDays, 14); |
| | | if (daysToCache <= 0) { |
| | | logger.info("commit cache disabled"); |
| | | } else { |
| | | long start = System.nanoTime(); |
| | | long repoCount = 0; |
| | | long commitCount = 0; |
| | | logger.info(MessageFormat.format("preparing {0} day commit cache. please wait...", daysToCache)); |
| | | CommitCache.instance().setCacheDays(daysToCache); |
| | | Date cutoff = CommitCache.instance().getCutoffDate(); |
| | | for (String repositoryName : getRepositoryList()) { |
| | | RepositoryModel model = getRepositoryModel(repositoryName); |
| | | if (model.hasCommits && model.lastChange.after(cutoff)) { |
| | | repoCount++; |
| | | Repository repository = getRepository(repositoryName); |
| | | for (RefModel ref : JGitUtils.getLocalBranches(repository, true, -1)) { |
| | | if (!ref.getDate().after(cutoff)) { |
| | | // branch not recently updated |
| | | continue; |
| | | } |
| | | List<?> commits = CommitCache.instance().getCommits(repositoryName, repository, ref.getName()); |
| | | if (commits.size() > 0) { |
| | | logger.info(MessageFormat.format(" cached {0} commits for {1}:{2}", |
| | | commits.size(), repositoryName, ref.getName())); |
| | | commitCount += commits.size(); |
| | | } |
| | | } |
| | | repository.close(); |
| | | } |
| | | } |
| | | logger.info(MessageFormat.format("built {0} day commit cache of {1} commits across {2} repositories in {3} msecs", |
| | | daysToCache, commitCount, repoCount, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start))); |
| | | } |
| | | } |
| | | |
| | | protected final Logger getLogger() { |
| | | return logger; |
| | | } |