本文整理汇总了Java中org.eclipse.jgit.lib.RepositoryCache.FileKey类的典型用法代码示例。如果您正苦于以下问题:Java FileKey类的具体用法?Java FileKey怎么用?Java FileKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileKey类属于org.eclipse.jgit.lib.RepositoryCache包,在下文中一共展示了FileKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
@Override
public boolean accept(final File folder) {
if (!folder.isDirectory()) {
return false;
}
final String path = folder.getName();
if (path.equals(METADATA_FOLDER)) {
return false;
}
if (!path.equals(Constants.DOT_GIT)) {
return true;
}
return !FileKey.isGitRepository(folder, FS.DETECTED);
}
示例2: reposInDefaultRepoDir
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
public static List<File> reposInDefaultRepoDir() {
File reposDir = new File(getExternalStorageDirectory(), "git-repos");
List<File> repos = newArrayList();
if (!reposDir.exists() && !reposDir.mkdirs()) {
Log.d(TAG, "Could not create default repos dir " + reposDir);
return repos;
}
for (File repoDir : reposDir.listFiles()) {
File gitdir = RepositoryCache.FileKey.resolve(repoDir, FS.detect());
if (gitdir != null) {
repos.add(gitdir);
}
}
Log.d(TAG, "Found " + repos.size() + " repos in " + reposDir);
return repos;
}
示例3: 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);
}
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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;
}
示例8: 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);
}
}
示例9: findRegisteredRepositories
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
private List<Repository> findRegisteredRepositories() {
final RepositoryUtil util = Activator.getDefault().getRepositoryUtil();
final List<String> repositoryFolders = util.getConfiguredRepositories();
final List<Repository> repositories = new ArrayList<Repository>();
for (final String repositoryFolder : repositoryFolders) {
final File folder = new File(repositoryFolder);
if (!folder.exists() || !folder.isDirectory()) {
continue;
}
if (!folder.getName().equals(Constants.DOT_GIT) || !FileKey.isGitRepository(folder, FS.DETECTED)) {
continue;
}
final RepositoryBuilder rb = new RepositoryBuilder().setGitDir(folder).setMustExist(true);
try {
repositories.add(rb.build());
} catch (final Exception e) {
log.error("Error loading Git repository " + repositoryFolder, e); //$NON-NLS-1$
continue;
}
}
return repositories;
}
示例10: loadRegisteredRepositories
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
private void loadRegisteredRepositories() {
repositoryMap = new TreeMap<String, Repository>();
final List<String> repositoryFolders = Activator.getDefault().getRepositoryUtil().getConfiguredRepositories();
for (final String repositoryFolder : repositoryFolders) {
final File folder = new File(repositoryFolder);
if (!folder.exists() || !folder.isDirectory()) {
continue;
}
if (!folder.getName().equals(Constants.DOT_GIT) || !FileKey.isGitRepository(folder, FS.DETECTED)) {
continue;
}
final RepositoryBuilder rb = new RepositoryBuilder().setGitDir(folder).setMustExist(true);
try {
final Repository repo = rb.build();
final StoredConfig repositoryConfig = repo.getConfig();
final Set<String> remotes = repositoryConfig.getSubsections(REMOTES_SECTION_NAME);
for (final String remoteName : remotes) {
final String remoteURL =
repositoryConfig.getString(REMOTES_SECTION_NAME, remoteName, URL_VALUE_NAME);
repositoryMap.put(remoteURL, repo);
}
} catch (final Exception e) {
log.error("Error loading local Git repository " + repositoryFolder, e); //$NON-NLS-1$
continue;
}
}
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
示例14: createRepository
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
private void createRepository(Path directory, Project.NameKey projectName) throws IOException {
String n = projectName.get() + Constants.DOT_GIT_EXT;
FileKey loc = FileKey.exact(directory.resolve(n).toFile(), FS.DETECTED);
try (Repository db = RepositoryCache.open(loc, false)) {
db.create(true /* bare */);
}
}
示例15: createRepository
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
private void createRepository(Path directory, String projectName) throws IOException {
String n = projectName + Constants.DOT_GIT_EXT;
FileKey loc = FileKey.exact(directory.resolve(n).toFile(), FS.DETECTED);
try (Repository db = RepositoryCache.open(loc, false)) {
db.create(true /* bare */);
}
}