本文整理汇总了Java中org.eclipse.jgit.lib.RepositoryCache.FileKey类的典型用法代码示例。如果您正苦于以下问题:Java FileKey类的具体用法?Java FileKey怎么用?Java FileKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileKey类属于org.eclipse.jgit.lib.RepositoryCache包,在下文中一共展示了FileKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:19,代码来源:FindEclipseProjectsCommand.java
示例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;
}
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:18,代码来源:Repos.java
示例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);
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:28,代码来源:LuceneService.java
示例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;
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:26,代码来源:LuceneService.java
示例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;
}
开发者ID:warpfork,项目名称:gitblit,代码行数:30,代码来源:GitBlit.java
示例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);
}
}
开发者ID:warpfork,项目名称:gitblit,代码行数:29,代码来源:LuceneExecutor.java
示例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;
}
开发者ID:warpfork,项目名称:gitblit,代码行数:27,代码来源:LuceneExecutor.java
示例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);
}
}
开发者ID:warpfork,项目名称:gitblit,代码行数:21,代码来源:JGitUtilsTest.java
示例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;
}
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:29,代码来源:GitRepositoriesMap.java
示例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;
}
}
}
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:33,代码来源:TeamExplorerGitRepositoriesSection.java
示例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);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:GitRepositoryManagerOnInit.java
示例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);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:VersionedMetaDataOnInit.java
示例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);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:ExternalIdsOnInit.java
示例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 */);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:MultiBaseLocalDiskRepositoryManagerTest.java
示例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 */);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:LocalDiskRepositoryManagerTest.java
示例16: openRepoFor
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
public static Repository openRepoFor(File gitdir) {
try {
Repository repo = RepositoryCache.open(FileKey.lenient(gitdir, FS.DETECTED), false);
Log.d("REPO", "Opened " + describe(repo));
return repo;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:10,代码来源:Repos.java
示例17: prepareBareRemote
import org.eclipse.jgit.lib.RepositoryCache.FileKey; //导入依赖的package包/类
public static Repository prepareBareRemote() throws IOException {
// Create a folder in the temp folder that will act as the remote repository
File remoteDir = File.createTempFile("remote", "");
remoteDir.delete();
remoteDir.mkdirs();
// Create a bare repository
FileKey fileKey = FileKey.exact(remoteDir, FS.DETECTED);
Repository remoteRepo = fileKey.open(false);
remoteRepo.create(true);
return remoteRepo;
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:14,代码来源:ConfigServerTestUtils.java
示例18: 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
示例19: 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
示例20: 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
注:本文中的org.eclipse.jgit.lib.RepositoryCache.FileKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论