From b2d0287b3f424c7f9ada44834365bf909db62a50 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 21 Dec 2012 17:35:18 -0500 Subject: [PATCH] Fixed regression in isFrozen (issue 181) --- src/com/gitblit/GitBlit.java | 43 ++++++++++++++++++++++++++++++++----------- 1 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 02906ee..076bb76 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -1339,7 +1339,7 @@ } // check for updates - Repository r = getRepository(repositoryName); + Repository r = getRepository(model.name); if (r == null) { // repository is missing removeFromCachedRepositoryList(repositoryName); @@ -1602,6 +1602,7 @@ } catch (Exception e) { model.lastGC = new Date(0); } + model.maxActivityCommits = getConfig(config, "maxActivityCommits", settings.getInteger(Keys.web.maxActivityCommits, 0)); model.origin = config.getString("remote", "origin", "url"); if (model.origin != null) { model.origin = model.origin.replace('\\', '/'); @@ -1651,7 +1652,18 @@ * @return true if the repository exists */ public boolean hasRepository(String repositoryName) { - if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) { + return hasRepository(repositoryName, false); + } + + /** + * Determines if this server has the requested repository. + * + * @param name + * @param caseInsensitive + * @return true if the repository exists + */ + public boolean hasRepository(String repositoryName, boolean caseSensitiveCheck) { + if (!caseSensitiveCheck && settings.getBoolean(Keys.git.cacheRepositoryList, true)) { // if we are caching use the cache to determine availability // otherwise we end up adding a phantom repository to the cache return repositoryListCache.containsKey(repositoryName.toLowerCase()); @@ -1936,7 +1948,7 @@ if (!repository.name.toLowerCase().endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) { repository.name += org.eclipse.jgit.lib.Constants.DOT_GIT_EXT; } - if (new File(repositoriesFolder, repository.name).exists()) { + if (hasRepository(repository.name)) { throw new GitBlitException(MessageFormat.format( "Can not create repository ''{0}'' because it already exists.", repository.name)); @@ -2068,9 +2080,20 @@ repository.federationStrategy.name()); config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFederated", repository.isFederated); config.setString(Constants.CONFIG_GITBLIT, null, "gcThreshold", repository.gcThreshold); - config.setInt(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod); + if (repository.gcPeriod == settings.getInteger(Keys.git.defaultGarbageCollectionPeriod, 7)) { + // use default from config + config.unset(Constants.CONFIG_GITBLIT, null, "gcPeriod"); + } else { + config.setInt(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod); + } if (repository.lastGC != null) { config.setString(Constants.CONFIG_GITBLIT, null, "lastGC", new SimpleDateFormat(Constants.ISO8601).format(repository.lastGC)); + } + if (repository.maxActivityCommits == settings.getInteger(Keys.web.maxActivityCommits, 0)) { + // use default from config + config.unset(Constants.CONFIG_GITBLIT, null, "maxActivityCommits"); + } else { + config.setInt(Constants.CONFIG_GITBLIT, null, "maxActivityCommits", repository.maxActivityCommits); } updateList(config, "federationSets", repository.federationSets); @@ -3032,22 +3055,20 @@ ServletContext context = contextEvent.getServletContext(); WebXmlSettings webxmlSettings = new WebXmlSettings(context); - // 0.7.0 web.properties in the deployed war folder - String webProps = context.getRealPath("/WEB-INF/web.properties"); + // gitblit.properties file located within the webapp + String webProps = context.getRealPath("/WEB-INF/gitblit.properties"); if (!StringUtils.isEmpty(webProps)) { File overrideFile = new File(webProps); - if (overrideFile.exists()) { - webxmlSettings.applyOverrides(overrideFile); - } + webxmlSettings.applyOverrides(overrideFile); } - - // 0.8.0 gitblit.properties file located outside the deployed war + // gitblit.properties file located outside the deployed war // folder lie, for example, on RedHat OpenShift. File overrideFile = getFileOrFolder("gitblit.properties"); if (!overrideFile.getPath().equals("gitblit.properties")) { webxmlSettings.applyOverrides(overrideFile); } + configureContext(webxmlSettings, true); // Copy the included scripts to the configured groovy folder -- Gitblit v1.9.1