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


Java RepositoryCache类代码示例

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


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

示例1: isValidGitRepository

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
/**
 * Checks if given folder is a git repository
 *
 * @param folder
 *     to check
 *
 * @return true if it is a git repository, false otherwise.
 */
public boolean isValidGitRepository(Path folder) {

    if (Files.exists(folder) && Files.isDirectory(folder)) {

        // If it has been at least initialized
        if (RepositoryCache.FileKey.isGitRepository(folder.toFile(), FS.DETECTED)) {
            // we are assuming that the clone worked at that time, caller should call hasAtLeastOneReference
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:24,代码来源:GitOperations.java

示例2: reposInDefaultRepoDir

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的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: getRepository

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的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: close

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
public static void close(Repository r) {
	RepositoryCache.close(r);

	// assume 2 uses in case reflection fails
	int uses = 2;
	try {
		Field useCnt = Repository.class.getDeclaredField("useCnt");
		useCnt.setAccessible(true);
		uses = ((AtomicInteger) useCnt.get(r)).get();
	} catch (Exception e) {
		e.printStackTrace();
	}
	for (int i = 0; i < uses; i++) {
		r.close();
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:17,代码来源:GitBlitSuite.java

示例5: testCreateRepository

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的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

示例6: GitVersionControl

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
public GitVersionControl(Path path) throws IOException {
    try {
        // Cribbed from Git.open, but with findGitDir rather than setGitDir
        // and extracting the location.
        FS fs = FS.DETECTED;
        RepositoryCache.FileKey key = RepositoryCache.FileKey.lenient(path.toFile(), fs);
        RepositoryBuilder builder = new RepositoryBuilder()
                .setFS(fs)
                .findGitDir(key.getFile())
                .setMustExist(true);
        repositoryRoot = Paths.get(builder.getGitDir().getAbsolutePath()).getParent();
        repo = new Git(builder.build());

        checkMergeDriver(repositoryRoot);
    } catch (RuntimeException ex) {
        throw new IOException(ex);
    }
}
 
开发者ID:fuzzyBSc,项目名称:systemdesign,代码行数:19,代码来源:GitVersionControl.java

示例7: Init

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
/** 초기화 메서드
 * @param creatorName
 * @param repositoryName
 */
public void Init(String creatorName, String repositoryName) {
	try {
		this.path = gitPath + creatorName + "/" + repositoryName
				+ ".git";
		this.localRepo = RepositoryCache.open(RepositoryCache.FileKey
				.lenient(new File(this.path), FS.DETECTED), true);
		this.git = new Git(localRepo);
	} catch (Exception e) {
		System.err.println(e.getMessage());
	}
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:16,代码来源:GitUtil.java

示例8: save

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
@Override
protected void save(PersonIdent ident, String msg) throws IOException, ConfigInvalidException {
  super.save(ident, msg);

  // we need to invalidate the JGit cache if the group list is invalidated in
  // an unattended init step
  RepositoryCache.clear();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:AllProjectsConfig.java

示例9: close

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
@Override
public void close() throws Exception {
  try {
    checkNoteDbState();
  } finally {
    daemon.getLifecycleManager().stop();
    if (daemonService != null) {
      System.out.println("Gerrit Server Shutdown");
      daemonService.shutdownNow();
      daemonService.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
    }
    RepositoryCache.clear();
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:GerritServer.java

示例10: createRepository

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的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

示例11: createRepository

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的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

示例12: GithubRepository

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
public GithubRepository(String remoteUrl, String localDir, boolean needsPassword) {
	this.remoteUrl = remoteUrl;
	this.needsPassword = needsPassword;
	File f = new File(remoteUrl);
	String localPath = localDir + File.separator + f.getName().replace(".git", "");
	rootDirectory = new File(localPath);
	gitDirectory = new File(localPath + File.separator + ".git");
	cloned = false;
	if (RepositoryCache.FileKey.isGitRepository(this.getGitDirectory(), FS.DETECTED)) {
		cloned = true;
	}
}
 
开发者ID:open-power,项目名称:serverwiz,代码行数:13,代码来源:GithubRepository.java

示例13: init_CheckDir_gitClone

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
/**
 * Davide you might notice that I have made functions smaller.
 * It makes code immensely more readable and you quickly are able
 * to resume the code from where you left.
 * Understanding takes lesser time, as number of lines are lesser.
 * @return 
 */
private boolean init_CheckDir_gitClone(){
    //Check if the given directory exists
    boolean gitUpdated = true;
    if (RepositoryCache.FileKey.isGitRepository(new File(gitDirectory.getAbsolutePath(), ".git"), FS.DETECTED)) {
        // Already cloned. Just need to pull a repository here.
        System.out.println("git pull");
        gitUpdated = gitPull(gitDirectory);
    } else {
        // Not present or not a Git repository.
        System.out.println("git clone");
        gitClone(gitDirectory);
    }return gitUpdated;
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:21,代码来源:UpdaterGenerator.java

示例14: openRepoFor

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的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

示例15: getAllRepos

import org.eclipse.jgit.lib.RepositoryCache; //导入依赖的package包/类
public List<RepoRecord> getAllRepos() {
    registerReposInStandardDir();

    List<RepoRecord> allRepos = newArrayList();
    Set<Long> missingReposIds = newHashSet();

    Cursor cursor = database.query(DatabaseHelper.TABLE_REPOS,
            new String[] { DatabaseHelper.COLUMN_ID, DatabaseHelper.COLUMN_GITDIR }, null, null, null, null, null);

    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        RepoRecord repoRecord = cursorToRepo(cursor);
        Log.d(TAG, "Found " + repoRecord);
        File currentGitDir = RepositoryCache.FileKey.resolve(repoRecord.gitdir, FILESYSTEM);
        if (currentGitDir == null) {
            missingReposIds.add(repoRecord.id);
        } else {
            allRepos.add(repoRecord);
        }

        cursor.moveToNext();
    }
    cursor.close();

    Log.d(TAG, "Found " + allRepos.size() + " repos, " + missingReposIds.size() + " missing repos");
    for (Long repoId : missingReposIds) {
        Log.d(TAG, "Deleting missing repo...");
        database.delete(DatabaseHelper.TABLE_REPOS, DatabaseHelper.COLUMN_ID + " = " + repoId, null);
    }

    return allRepos;
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:33,代码来源:ReposDataSource.java


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