Java Code Examples for org.eclipse.jgit.revwalk.RevWalk#close()
The following examples show how to use
org.eclipse.jgit.revwalk.RevWalk#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitCommit.java From Getaviz with Apache License 2.0 | 6 votes |
private void addDiff(DiffImplementation returnable, RevCommit parent) throws IOException { RevWalk revWalk = new RevWalk(repository); parent = revWalk.parseCommit(parent.getId()); revWalk.close(); ByteArrayOutputStream put = new ByteArrayOutputStream(BUFFER_SIZE); DiffFormatter df = new DiffFormatter(put); df.setRepository(repository); df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); List<DiffEntry> diffs = df.scan(parent.getTree(), commit.getTree()); for(DiffEntry e : diffs){ df.format(e); String diffText = put.toString(DEFAULT_ENCODING); //TODO make encoding insertable returnable.addOperation(e.getOldPath(), new GitOperation(diffText, e.getOldPath(), e.getNewPath(), e.getChangeType())); put.reset(); } df.close(); }
Example 2
Source File: GitRepository.java From Getaviz with Apache License 2.0 | 6 votes |
@Override public Collection<Tag> getTags() throws TagsNotAvailableException { List<Tag> result = new ArrayList<Tag>(); try { Git del = new Git(delegateRepository); List<Ref> tags = del.tagList().call(); del.close(); RevWalk walk = new RevWalk(delegateRepository); for (Ref tag : tags){ GitCommit commit = new GitCommit(delegateRepository, walk.parseCommit(tag.getObjectId())); GitTag wrapperTag = new GitTag(commit, createTagName(tag)); result.add(wrapperTag); walk.close(); } return result; } catch (Exception e) { throw new TagsNotAvailableException(e); } }
Example 3
Source File: GitHistoryRefactoringMinerImpl.java From RefactoringMiner with MIT License | 6 votes |
@Override public Churn churnAtCommit(Repository repository, String commitId, RefactoringHandler handler) { GitService gitService = new GitServiceImpl(); RevWalk walk = new RevWalk(repository); try { RevCommit commit = walk.parseCommit(repository.resolve(commitId)); if (commit.getParentCount() > 0) { walk.parseCommit(commit.getParent(0)); return gitService.churn(repository, commit); } else { logger.warn(String.format("Ignored revision %s because it has no parent", commitId)); } } catch (MissingObjectException moe) { logger.warn(String.format("Ignored revision %s due to missing commit", commitId), moe); } catch (Exception e) { logger.warn(String.format("Ignored revision %s due to error", commitId), e); handler.handleException(commitId, e); } finally { walk.close(); walk.dispose(); } return null; }
Example 4
Source File: GitConnector.java From compiler with Apache License 2.0 | 6 votes |
public void countChangedFiles(List<String> commits, Map<String, Integer> counts) { RevWalk temprevwalk = new RevWalk(repository); try { revwalk.reset(); Set<RevCommit> heads = getHeads(); revwalk.markStart(heads); revwalk.sort(RevSort.TOPO, true); revwalk.sort(RevSort.COMMIT_TIME_DESC, true); revwalk.sort(RevSort.REVERSE, true); for (final RevCommit rc: revwalk) { final GitCommit gc = new GitCommit(this, repository, temprevwalk, projectName); System.out.println(rc.getName()); commits.add(rc.getName()); int count = gc.countChangedFiles(rc); counts.put(rc.getName(), count); } } catch (final IOException e) { if (debug) System.err.println("Git Error getting parsing HEAD commit for " + path + ". " + e.getMessage()); } finally { temprevwalk.dispose(); temprevwalk.close(); } }
Example 5
Source File: GitConnector.java From compiler with Apache License 2.0 | 6 votes |
public List<String> logCommitIds() { List<String> commits = new ArrayList<String>(); RevWalk temprevwalk = new RevWalk(repository); try { revwalk.reset(); Set<RevCommit> heads = getHeads(); revwalk.markStart(heads); revwalk.sort(RevSort.TOPO, true); revwalk.sort(RevSort.COMMIT_TIME_DESC, true); revwalk.sort(RevSort.REVERSE, true); for (final RevCommit rc : revwalk) commits.add(rc.getName()); } catch (final IOException e) { e.printStackTrace(); } finally { temprevwalk.dispose(); temprevwalk.close(); } return commits; }
Example 6
Source File: GitCommitHandlerV1.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private ObjectId getCommitObjectId(Repository db, ObjectId oid) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevWalk walk = new RevWalk(db); try { return walk.parseCommit(oid); } finally { walk.close(); } }
Example 7
Source File: Branch.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private RevCommit parseCommit() { ObjectId oid = ref.getObjectId(); if (oid == null) return null; RevWalk walk = new RevWalk(db); try { return walk.parseCommit(oid); } catch (IOException e) { // ignore and return null } finally { walk.close(); } return null; }
Example 8
Source File: RemoteDetailsJob.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private ObjectId getCommitObjectId(Repository db, ObjectId oid) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevWalk walk = new RevWalk(db); try { return walk.parseCommit(oid); } finally { walk.close(); } }
Example 9
Source File: ListBranchesJob.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private ObjectId getCommitObjectId(Repository db, ObjectId oid) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevWalk walk = new RevWalk(db); try { return walk.parseCommit(oid); } finally { walk.close(); } }
Example 10
Source File: ListTagsJob.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private ObjectId getCommitObjectId(Repository db, ObjectId oid) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevWalk walk = new RevWalk(db); try { return walk.parseCommit(oid); } finally { walk.close(); } }
Example 11
Source File: DocumentationGitBasedManager.java From scava with Eclipse Public License 2.0 | 5 votes |
private String getLastRevisionBeforeDate(VcsRepository repository, Date date) throws Exception { Git git = getGit((GitRepository)repository); Repository repo = git.getRepository(); RevWalk walk = new RevWalk(repo); Iterator<RevCommit> iterator = git.log().call().iterator(); String revision=""; // The commits are ordered latest first, so we want to find the fist that it is before the date int dateComparison; while(iterator.hasNext()) { RevCommit commit = walk.parseCommit(iterator.next()); dateComparison=new Date(Long.valueOf(commit.getCommitTime())*1000).compareTo(date); if (dateComparison < 0) { revision=commit.getId().getName(); break; } } walk.close(); repo.close(); git.close(); if(revision.isEmpty()) return ""; return revision; }
Example 12
Source File: DifferentFiles.java From gitflow-incremental-builder with MIT License | 5 votes |
private RevCommit getMergeBase(RevCommit baseCommit, RevCommit referenceHeadCommit) throws IOException { RevWalk walk = new RevWalk(git.getRepository()); walk.setRevFilter(RevFilter.MERGE_BASE); walk.markStart(walk.lookupCommit(baseCommit)); walk.markStart(walk.lookupCommit(referenceHeadCommit)); RevCommit commit = walk.next(); walk.close(); logger.info("Using merge base of id: " + commit.getId()); return commit; }
Example 13
Source File: DifferentFiles.java From gitflow-incremental-builder with MIT License | 5 votes |
private RevCommit getBranchCommit(String branchName) throws IOException { ObjectId objectId = git.getRepository().resolve(branchName); if (objectId == null) { throw new IllegalArgumentException("Git branch of name '" + branchName + "' not found."); } final RevWalk walk = new RevWalk(git.getRepository()); RevCommit commit = walk.parseCommit(objectId); walk.close(); logger.info("Reference commit of branch " + branchName + " is commit of id: " + commit.getId()); return commit; }
Example 14
Source File: GitSCM.java From repositoryminer with Apache License 2.0 | 5 votes |
private List<Change> getChangesForCommitedFiles(String hash) throws IOException { RevWalk revWalk = new RevWalk(git.getRepository()); RevCommit commit = revWalk.parseCommit(ObjectId.fromString(hash)); if (commit.getParentCount() > 1) { revWalk.close(); return new ArrayList<Change>(); } RevCommit parentCommit = commit.getParentCount() > 0 ? revWalk.parseCommit(ObjectId.fromString(commit.getParent(0).getName())) : null; DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); df.setBinaryFileThreshold(2048); df.setRepository(git.getRepository()); df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); List<DiffEntry> diffEntries = df.scan(parentCommit, commit); df.close(); revWalk.close(); List<Change> changes = new ArrayList<Change>(); for (DiffEntry entry : diffEntries) { Change change = new Change(entry.getNewPath(), entry.getOldPath(), 0, 0, ChangeType.valueOf(entry.getChangeType().name())); analyzeDiff(change, entry); changes.add(change); } return changes; }