| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the list of all repository models. |
| | | * |
| | | * @return list of all repository models |
| | | */ |
| | | @Override |
| | | public List<RepositoryModel> getRepositoryModels() { |
| | | long methodStart = System.currentTimeMillis(); |
| | | List<String> list = getRepositoryList(); |
| | | List<RepositoryModel> repositories = new ArrayList<RepositoryModel>(); |
| | | for (String repo : list) { |
| | | RepositoryModel model = getRepositoryModel(repo); |
| | | if (model != null) { |
| | | repositories.add(model); |
| | | } |
| | | } |
| | | long duration = System.currentTimeMillis() - methodStart; |
| | | logger.info(MessageFormat.format("{0} repository models loaded in {1} msecs", duration)); |
| | | return repositories; |
| | | } |
| | | |
| | | /** |
| | | * Returns the list of repository models that are accessible to the user. |
| | | * |
| | | * @param user |
| | |
| | | // find the root, cached |
| | | String key = getRepositoryKey(repository); |
| | | RepositoryModel model = repositoryListCache.get(key); |
| | | if (model == null) { |
| | | return null; |
| | | } |
| | | |
| | | while (model.originRepository != null) { |
| | | String originKey = getRepositoryKey(model.originRepository); |
| | | model = repositoryListCache.get(originKey); |
| | | if (model == null) { |
| | | return null; |
| | | } |
| | | } |
| | | ForkModel root = getForkModelFromCache(model.name); |
| | | return root; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates/updates the repository model keyed by reopsitoryName. Saves all |
| | | * Creates/updates the repository model keyed by repositoryName. Saves all |
| | | * repository settings in .git/config. This method allows for renaming |
| | | * repositories and will update user access permissions accordingly. |
| | | * |
| | |
| | | repository.name = repository.name.substring(projectPath.length() + 1); |
| | | } |
| | | } |
| | | boolean isRename = false; |
| | | if (isCreate) { |
| | | // ensure created repository name ends with .git |
| | | if (!repository.name.toLowerCase().endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) { |
| | |
| | | r = JGitUtils.createRepository(repositoriesFolder, repository.name, shared); |
| | | } else { |
| | | // rename repository |
| | | if (!repositoryName.equalsIgnoreCase(repository.name)) { |
| | | isRename = !repositoryName.equalsIgnoreCase(repository.name); |
| | | if (isRename) { |
| | | if (!repository.name.toLowerCase().endsWith( |
| | | org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) { |
| | | repository.name += org.eclipse.jgit.lib.Constants.DOT_GIT_EXT; |
| | |
| | | listener.onCreation(repository); |
| | | } catch (Throwable t) { |
| | | logger.error(String.format("failed to call plugin onCreation %s", repositoryName), t); |
| | | } |
| | | } |
| | | } else if (isRename && pluginManager != null) { |
| | | for (RepositoryLifeCycleListener listener : pluginManager.getExtensions(RepositoryLifeCycleListener.class)) { |
| | | try { |
| | | listener.onRename(repositoryName, repository); |
| | | } catch (Throwable t) { |
| | | logger.error(String.format("failed to call plugin onRename %s", repositoryName), t); |
| | | } |
| | | } |
| | | } |
| | |
| | | cfg.setPackedGitLimit(settings.getFilesize(Keys.git.packedGitLimit, cfg.getPackedGitLimit())); |
| | | cfg.setDeltaBaseCacheLimit(settings.getFilesize(Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit())); |
| | | cfg.setPackedGitOpenFiles(settings.getFilesize(Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles())); |
| | | cfg.setStreamFileThreshold(settings.getFilesize(Keys.git.streamFileThreshold, cfg.getStreamFileThreshold())); |
| | | cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP())); |
| | | |
| | | try { |
| | |
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit())); |
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit())); |
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles())); |
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.streamFileThreshold, cfg.getStreamFileThreshold())); |
| | | logger.debug(MessageFormat.format("{0} = {1}", Keys.git.packedGitMmap, cfg.isPackedGitMMAP())); |
| | | } catch (IllegalArgumentException e) { |
| | | logger.error("Failed to configure JGit parameters!", e); |
| | |
| | | |
| | | try { |
| | | // issue-486/ticket-151: UTF-9 & UTF-18 |
| | | // issue-560/ticket-237: 'UTF8' |
| | | Field field = RawParseUtils.class.getDeclaredField("encodingAliases"); |
| | | field.setAccessible(true); |
| | | Map<String, Charset> encodingAliases = (Map<String, Charset>) field.get(null); |
| | | encodingAliases.put("'utf8'", RawParseUtils.UTF8_CHARSET); |
| | | encodingAliases.put("utf-9", RawParseUtils.UTF8_CHARSET); |
| | | encodingAliases.put("utf-18", RawParseUtils.UTF8_CHARSET); |
| | | logger.info("Alias UTF-9 & UTF-18 encodings as UTF-8 in JGit"); |
| | | logger.info("Alias 'UTF8', UTF-9 & UTF-18 encodings as UTF-8 in JGit"); |
| | | } catch (Throwable t) { |
| | | logger.error("Failed to inject UTF-9 & UTF-18 encoding aliases into JGit", t); |
| | | } |