本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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());
}
}
示例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();
}
示例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();
}
}
示例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 */);
}
}
示例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 */);
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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;
}