| | |
| | | }
|
| | |
|
| | | // check for updates
|
| | | Repository r = getRepository(repositoryName);
|
| | | Repository r = getRepository(model.name);
|
| | | if (r == null) {
|
| | | // repository is missing
|
| | | removeFromCachedRepositoryList(repositoryName);
|
| | |
| | | * @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());
|
| | |
| | | ProjectModel project = getProjectModel(userProject);
|
| | | for (String repository : project.repositories) {
|
| | | if (repository.startsWith(userProject)) {
|
| | | RepositoryModel model = repositoryListCache.get(repository);
|
| | | RepositoryModel model = getRepositoryModel(repository);
|
| | | if (model.originRepository.equalsIgnoreCase(origin)) {
|
| | | // user has a fork
|
| | | return model.name;
|
| | |
| | | */
|
| | | public ForkModel getForkNetwork(String repository) {
|
| | | if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
|
| | | // find the root
|
| | | // find the root, cached
|
| | | RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
|
| | | while (model.originRepository != null) {
|
| | | model = repositoryListCache.get(model.originRepository);
|
| | | }
|
| | | ForkModel root = getForkModelFromCache(model.name);
|
| | | return root;
|
| | | } else {
|
| | | // find the root, non-cached
|
| | | RepositoryModel model = getRepositoryModel(repository.toLowerCase());
|
| | | while (model.originRepository != null) {
|
| | | model = getRepositoryModel(model.originRepository);
|
| | | }
|
| | | ForkModel root = getForkModel(model.name);
|
| | | return root;
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | private ForkModel getForkModelFromCache(String repository) {
|
| | | RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
|
| | | ForkModel fork = new ForkModel(model);
|
| | | if (!ArrayUtils.isEmpty(model.forks)) {
|
| | | for (String aFork : model.forks) {
|
| | | ForkModel fm = getForkModelFromCache(aFork);
|
| | | fork.forks.add(fm);
|
| | | }
|
| | | }
|
| | | return fork;
|
| | | }
|
| | |
|
| | | private ForkModel getForkModel(String repository) {
|
| | | RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
|
| | | RepositoryModel model = getRepositoryModel(repository.toLowerCase());
|
| | | ForkModel fork = new ForkModel(model);
|
| | | if (!ArrayUtils.isEmpty(model.forks)) {
|
| | | for (String aFork : model.forks) {
|
| | |
| | | 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));
|