当前位置: 首页>>代码示例>>Java>>正文


Java FileKey.resolve方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.RepositoryCache.FileKey.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java FileKey.resolve方法的具体用法?Java FileKey.resolve怎么用?Java FileKey.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.RepositoryCache.FileKey的用法示例。


在下文中一共展示了FileKey.resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteIndex

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Deletes the Lucene index for the specified repository.
 * 
 * @param repositoryName
 * @return true, if successful
 */
public boolean deleteIndex(String repositoryName) {
	try {
		// close any open writer/searcher
		close(repositoryName);

		// delete the index folder
		File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repositoryName), FS.DETECTED);
		File luceneIndex = new File(repositoryFolder, LUCENE_DIR);
		if (luceneIndex.exists()) {
			org.eclipse.jgit.util.FileUtils.delete(luceneIndex, org.eclipse.jgit.util.FileUtils.RECURSIVE);
		}
		// delete the config file
		File luceneConfig = new File(repositoryFolder, CONF_FILE);
		if (luceneConfig.exists()) {
			luceneConfig.delete();
		}
		return true;
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:28,代码来源:LuceneService.java

示例2: getIndexWriter

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Gets an index writer for the repository. The index will be created if it does not already exist or if forceCreate is specified.
 * 
 * @param repository
 * @return an IndexWriter
 * @throws IOException
 */
private IndexWriter getIndexWriter(String repository) throws IOException {
	IndexWriter indexWriter = writers.get(repository);
	File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repository), FS.DETECTED);
	File indexFolder = new File(repositoryFolder, LUCENE_DIR);
	Directory directory = FSDirectory.open(indexFolder.toPath());

	if (indexWriter == null) {
		if (!indexFolder.exists()) {
			indexFolder.mkdirs();
		}
		StandardAnalyzer analyzer = new StandardAnalyzer();
		IndexWriterConfig config = new IndexWriterConfig(analyzer);
		config.setOpenMode(OpenMode.CREATE_OR_APPEND);
		indexWriter = new IndexWriter(directory, config);
		writers.put(repository, indexWriter);
	}
	return indexWriter;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:26,代码来源:LuceneService.java

示例3: getRepository

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Returns the JGit repository for the specified name.
 * 
 * @param repositoryName
 * @param logError
 * @return repository or null
 */
public Repository getRepository(String repositoryName, boolean logError) {
	if (isCollectingGarbage(repositoryName)) {
		logger.warn(MessageFormat.format("Rejecting request for {0}, busy collecting garbage!", repositoryName));
		return null;
	}

	File dir = FileKey.resolve(new File(repositoriesFolder, repositoryName), FS.DETECTED);
	if (dir == null)
		return null;
	
	Repository r = null;
	try {
		FileKey key = FileKey.exact(dir, FS.DETECTED);
		r = RepositoryCache.open(key, true);
	} catch (IOException e) {
		if (logError) {
			logger.error("GitBlit.getRepository(String) failed to find "
					+ new File(repositoriesFolder, repositoryName).getAbsolutePath());
		}
	}
	return r;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:30,代码来源:GitBlit.java

示例4: deleteIndex

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Deletes the Lucene index for the specified repository.
 * 
 * @param repositoryName
 * @return true, if successful
 */
public boolean deleteIndex(String repositoryName) {
	try {
		// close any open writer/searcher
		close(repositoryName);

		// delete the index folder
		File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repositoryName), FS.DETECTED);
		File luceneIndex = new File(repositoryFolder, LUCENE_DIR);
		if (luceneIndex.exists()) {
			org.eclipse.jgit.util.FileUtils.delete(luceneIndex,
					org.eclipse.jgit.util.FileUtils.RECURSIVE);
		}
		// delete the config file
		File luceneConfig = new File(repositoryFolder, CONF_FILE);
		if (luceneConfig.exists()) {
			luceneConfig.delete();
		}
		return true;
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:29,代码来源:LuceneExecutor.java

示例5: getIndexWriter

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Gets an index writer for the repository. The index will be created if it
 * does not already exist or if forceCreate is specified.
 * 
 * @param repository
 * @return an IndexWriter
 * @throws IOException
 */
private IndexWriter getIndexWriter(String repository) throws IOException {
	IndexWriter indexWriter = writers.get(repository);				
	File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repository), FS.DETECTED);
	File indexFolder = new File(repositoryFolder, LUCENE_DIR);
	Directory directory = FSDirectory.open(indexFolder);		

	if (indexWriter == null) {
		if (!indexFolder.exists()) {
			indexFolder.mkdirs();
		}
		StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
		IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, analyzer);
		config.setOpenMode(OpenMode.CREATE_OR_APPEND);
		indexWriter = new IndexWriter(directory, config);
		writers.put(repository, indexWriter);
	}
	return indexWriter;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:27,代码来源:LuceneExecutor.java

示例6: testCreateRepository

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
@Test
public void testCreateRepository() throws Exception {
	String[] repositories = { "NewTestRepository.git", "NewTestRepository" };
	for (String repositoryName : repositories) {
		Repository repository = JGitUtils.createRepository(GitBlitSuite.REPOSITORIES,
				repositoryName);
		File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName),
				FS.DETECTED);
		assertNotNull(repository);
		assertFalse(JGitUtils.hasCommits(repository));
		assertNull(JGitUtils.getFirstCommit(repository, null));
		assertEquals(folder.lastModified(), JGitUtils.getFirstChange(repository, null)
				.getTime());
		assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());
		assertNull(JGitUtils.getCommit(repository, null));
		repository.close();
		RepositoryCache.close(repository);
		FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE);
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:21,代码来源:JGitUtilsTest.java

示例7: getPath

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
private File getPath(Project.NameKey name) {
  Path basePath = site.resolve(flags.cfg.getString("gerrit", null, "basePath"));
  if (basePath == null) {
    throw new IllegalStateException("gerrit.basePath must be configured");
  }
  return FileKey.resolve(basePath.resolve(name.get()).toFile(), FS.DETECTED);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:GitRepositoryManagerOnInit.java

示例8: getPath

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
private File getPath() {
  Path basePath = site.resolve(flags.cfg.getString("gerrit", null, "basePath"));
  if (basePath == null) {
    throw new IllegalStateException("gerrit.basePath must be configured");
  }
  return FileKey.resolve(basePath.resolve(project).toFile(), FS.DETECTED);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:VersionedMetaDataOnInit.java

示例9: getPath

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
private File getPath() {
  Path basePath = site.resolve(flags.cfg.getString("gerrit", null, "basePath"));
  if (basePath == null) {
    throw new IllegalStateException("gerrit.basePath must be configured");
  }
  return FileKey.resolve(basePath.resolve(allUsers).toFile(), FS.DETECTED);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:ExternalIdsOnInit.java

示例10: calculateSize

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Returns the size in bytes of the repository. Gitblit caches the
 * repository sizes to reduce the performance penalty of recursive
 * calculation. The cache is updated if the repository has been changed
 * since the last calculation.
 * 
 * @param model
 * @return size in bytes
 */
public long calculateSize(RepositoryModel model) {
	if (repositorySizeCache.hasCurrent(model.name, model.lastChange)) {
		return repositorySizeCache.getObject(model.name);
	}
	File gitDir = FileKey.resolve(new File(repositoriesFolder, model.name), FS.DETECTED);
	long size = com.gitblit.utils.FileUtils.folderSize(gitDir);
	repositorySizeCache.updateObject(model.name, model.lastChange, size);
	return size;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:19,代码来源:GitBlit.java

示例11: close

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
public static void close(File repository) {
	try {
		File gitDir = FileKey.resolve(repository, FS.detect());
		if (gitDir != null && gitDir.exists()) {
			close(RepositoryCache.open(FileKey.exact(gitDir, FS.detect())));
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:11,代码来源:GitBlitSuite.java

示例12: testPushLog

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
@Test
public void testPushLog() throws IOException {
	String name = "~james/helloworld.git";
	File gitDir = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, name), FS.DETECTED);
	Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
	List<PushLogEntry> pushes = PushLogUtils.getPushLog(name, repository);
	GitBlitSuite.close(repository);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:9,代码来源:PushLogTest.java

示例13: getPath

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
private File getPath() {
  Path basePath = site.resolve(flags.cfg.getString("gerrit", null, "basePath"));
  checkArgument(basePath != null, "gerrit.basePath must be configured");
  return FileKey.resolve(basePath.resolve(allUsers).toFile(), FS.DETECTED);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:AccountsOnInit.java

示例14: getRepositoryList

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Recursive function to find git repositories.
 * 
 * @param basePath
 *            basePath is stripped from the repository name as repositories are relative to this path
 * @param searchFolder
 * @param onlyBare
 *            if true only bare repositories will be listed. if false all repositories are included.
 * @param searchSubfolders
 *            recurse into subfolders to find grouped repositories
 * @param depth
 *            recursion depth, -1 = infinite recursion
 * @param patterns
 *            list of regex patterns for matching to folder names
 * @return
 */
private static List<String> getRepositoryList(String basePath, File searchFolder, boolean onlyBare, boolean searchSubfolders, int depth,
		List<Pattern> patterns) {
	File baseFile = new File(basePath);
	List<String> list = new ArrayList<String>();
	if (depth == 0) {
		return list;
	}

	int nextDepth = (depth == -1) ? -1 : depth - 1;
	for (File file : searchFolder.listFiles()) {
		if (file.isDirectory()) {
			boolean exclude = false;
			for (Pattern pattern : patterns) {
				String path = FileUtils.getRelativePath(baseFile, file).replace('\\', '/');
				if (pattern.matcher(path).matches()) {
					LOGGER.debug(MessageFormat.format("excluding {0} because of rule {1}", path, pattern.pattern()));
					exclude = true;
					break;
				}
			}
			if (exclude) {
				// skip to next file
				continue;
			}

			File gitDir = FileKey.resolve(new File(searchFolder, file.getName()), FS.DETECTED);
			if (gitDir != null) {
				if (onlyBare && gitDir.getName().equals(".git")) {
					continue;
				}
				if (gitDir.equals(file) || gitDir.getParentFile().equals(file)) {
					// determine repository name relative to base path
					String repository = FileUtils.getRelativePath(baseFile, file);
					list.add(repository);
				} else if (searchSubfolders && file.canRead()) {
					// look for repositories in subfolders
					list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders, nextDepth, patterns));
				}
			} else if (searchSubfolders && file.canRead()) {
				// look for repositories in subfolders
				list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders, nextDepth, patterns));
			}
		}
	}
	return list;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:63,代码来源:JGitUtils.java

示例15: getRepositoryList

import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入方法依赖的package包/类
/**
 * Recursive function to find git repositories.
 * 
 * @param basePath
 *            basePath is stripped from the repository name as repositories
 *            are relative to this path
 * @param searchFolder
 * @param onlyBare
 *            if true only bare repositories will be listed. if false all
 *            repositories are included.
 * @param searchSubfolders
 *            recurse into subfolders to find grouped repositories
 * @param depth
 *            recursion depth, -1 = infinite recursion
 * @param patterns
 *            list of regex patterns for matching to folder names
 * @return
 */
private static List<String> getRepositoryList(String basePath, File searchFolder,
		boolean onlyBare, boolean searchSubfolders, int depth, List<Pattern> patterns) {
	File baseFile = new File(basePath);
	List<String> list = new ArrayList<String>();
	if (depth == 0) {
		return list;
	}
	
	int nextDepth = (depth == -1) ? -1 : depth - 1;
	for (File file : searchFolder.listFiles()) {
		if (file.isDirectory()) {
			boolean exclude = false;
			for (Pattern pattern : patterns) {
				String path = FileUtils.getRelativePath(baseFile, file).replace('\\',  '/');
				if (pattern.matcher(path).matches()) {
					LOGGER.debug(MessageFormat.format("excluding {0} because of rule {1}", path, pattern.pattern()));
					exclude = true;
					break;
				}
			}
			if (exclude) {
				// skip to next file
				continue;
			}

			File gitDir = FileKey.resolve(new File(searchFolder, file.getName()), FS.DETECTED);
			if (gitDir != null) {
				if (onlyBare && gitDir.getName().equals(".git")) {
					continue;
				}
				if (gitDir.equals(file) || gitDir.getParentFile().equals(file)) {
					// determine repository name relative to base path
					String repository = FileUtils.getRelativePath(baseFile, file);
					list.add(repository);
				} else if (searchSubfolders && file.canRead()) {
					// look for repositories in subfolders
					list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders,
							nextDepth, patterns));
				}
			} else if (searchSubfolders && file.canRead()) {
				// look for repositories in subfolders
				list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders,
						nextDepth, patterns));
			}
		}
	}
	return list;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:67,代码来源:JGitUtils.java


注:本文中的org.eclipse.jgit.lib.RepositoryCache.FileKey.resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。