List of usage examples for org.eclipse.jgit.lib Repository getDirectory
public File getDirectory()
From source file:com.google.gerrit.server.project.CreateBranch.java
License:Apache License
private RevWalk verifyConnected(final Repository repo, final ObjectId revid) throws InvalidRevisionException { try {/*from w ww .java 2 s. co m*/ final ObjectWalk rw = new ObjectWalk(repo); try { rw.markStart(rw.parseCommit(revid)); } catch (IncorrectObjectTypeException err) { throw new InvalidRevisionException(); } RefDatabase refDb = repo.getRefDatabase(); Iterable<Ref> refs = Iterables.concat(refDb.getRefs(Constants.R_HEADS).values(), refDb.getRefs(Constants.R_TAGS).values()); Ref rc = refDb.exactRef(RefNames.REFS_CONFIG); if (rc != null) { refs = Iterables.concat(refs, Collections.singleton(rc)); } for (Ref r : refs) { try { rw.markUninteresting(rw.parseAny(r.getObjectId())); } catch (MissingObjectException err) { continue; } } rw.checkConnectivity(); return rw; } catch (IncorrectObjectTypeException | MissingObjectException err) { throw new InvalidRevisionException(); } catch (IOException err) { log.error("Repository \"" + repo.getDirectory() + "\" may be corrupt; suggest running git fsck", err); throw new InvalidRevisionException(); } }
From source file:com.google.gerrit.server.project.RefUtil.java
License:Apache License
public static RevWalk verifyConnected(Repository repo, ObjectId revid) throws InvalidRevisionException { try {/*ww w . j a v a2 s .co m*/ ObjectWalk rw = new ObjectWalk(repo); try { rw.markStart(rw.parseCommit(revid)); } catch (IncorrectObjectTypeException err) { throw new InvalidRevisionException(); } RefDatabase refDb = repo.getRefDatabase(); Iterable<Ref> refs = Iterables.concat(refDb.getRefs(Constants.R_HEADS).values(), refDb.getRefs(Constants.R_TAGS).values()); Ref rc = refDb.exactRef(RefNames.REFS_CONFIG); if (rc != null) { refs = Iterables.concat(refs, Collections.singleton(rc)); } for (Ref r : refs) { try { rw.markUninteresting(rw.parseAny(r.getObjectId())); } catch (MissingObjectException err) { continue; } } rw.checkConnectivity(); return rw; } catch (IncorrectObjectTypeException | MissingObjectException err) { throw new InvalidRevisionException(); } catch (IOException err) { log.error("Repository \"" + repo.getDirectory() + "\" may be corrupt; suggest running git fsck", err); throw new InvalidRevisionException(); } }
From source file:com.google.gitiles.DefaultAccess.java
License:Open Source License
private String getRelativePath(Repository repo) { String path = repo.isBare() ? repo.getDirectory().getPath() : repo.getDirectory().getParent(); if (repo.isBare()) { path = repo.getDirectory().getPath(); if (path.endsWith(".git")) { path = path.substring(0, path.length() - 4); }//from w ww .ja v a2 s .c o m } else { path = repo.getDirectory().getParent(); } return getRelativePath(path); }
From source file:com.google.gitiles.DefaultAccess.java
License:Open Source License
private String loadDescriptionText(Repository repo) throws IOException { String desc = null;// ww w . j a v a 2s . c o m StoredConfig config = repo.getConfig(); IOException configError = null; try { config.load(); desc = config.getString("gitweb", null, "description"); } catch (ConfigInvalidException e) { configError = new IOException(e); } if (desc == null) { File descFile = new File(repo.getDirectory(), "description"); if (descFile.exists()) { desc = new String(IO.readFully(descFile)); } else if (configError != null) { throw configError; } } return desc; }
From source file:com.googlesource.gerrit.plugins.gitiles.FilteredRepository.java
License:Apache License
private static RepositoryBuilder toBuilder(Repository repo) { RepositoryBuilder b = new RepositoryBuilder().setGitDir(repo.getDirectory()).setFS(repo.getFS()); if (!repo.isBare()) { b.setWorkTree(repo.getWorkTree()).setIndexFile(repo.getIndexFile()); }/*from w ww . java 2s.co m*/ return b; }
From source file:com.googlesource.gerrit.plugins.quota.ProjectNameResolver.java
License:Apache License
Project.NameKey projectName(Repository repo) { Path gitDir = repo.getDirectory().toPath(); if (gitDir.startsWith(basePath)) { String p = basePath.relativize(gitDir).toString(); String n = p.substring(0, p.length() - ".git".length()); return new Project.NameKey(n); }// w ww . j a va 2 s . co m log.warn("Couldn't determine the project name from " + gitDir); return null; }
From source file:com.googlesource.gerrit.plugins.uploadvalidator.TestUtils.java
License:Apache License
public static File createEmptyFile(String name, Repository repo) { return new File(repo.getDirectory().getParent(), name); }
From source file:com.madgag.agit.git.Repos.java
License:Open Source License
public static File topDirectoryFor(Repository repo) { return repo.isBare() ? repo.getDirectory() : repo.getWorkTree(); }
From source file:com.madgag.agit.GitIntentBuilder.java
License:Open Source License
public GitIntentBuilder repository(Repository repository) { return gitdir(repository.getDirectory()); }
From source file:com.madgag.agit.operations.Pull.java
License:Open Source License
public Pull(Repository repository) { super(repository.getDirectory()); this.repo = repository; }