Java Code Examples for org.eclipse.jgit.lib.ObjectId#zeroId()
The following examples show how to use
org.eclipse.jgit.lib.ObjectId#zeroId() .
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: CommitUtil.java From SZZUnleashed with MIT License | 6 votes |
/** * Method to read a file from a specific revision. * * @param tree the revision tree that contains the file. * @param path the path that leads to the file in the tree. * @return a list containing all lines in the file. */ public List<String> getFileLines(RevTree tree, String path) throws IOException, GitAPIException { try (TreeWalk walk = new TreeWalk(this.repo)) { walk.addTree(tree); walk.setRecursive(true); walk.setFilter(PathFilter.create(path)); walk.next(); ObjectId oId = walk.getObjectId(0); if (oId == ObjectId.zeroId()) { return new LinkedList<>(); } ObjectLoader loader = this.repo.open(oId); ByteArrayOutputStream stream = new ByteArrayOutputStream(); loader.copyTo(stream); return IOUtils.readLines(new ByteArrayInputStream(stream.toByteArray()), "UTF-8"); } catch (Exception e) { return new LinkedList<>(); } }
Example 2
Source File: CommitUtil.java From SZZUnleashed with MIT License | 6 votes |
/** * Parse the lines a commit recently made changes to compared to its parent. * * @param revc the current revision. * @return a commit object containing all differences. */ public Commit getCommitDiffingLines(RevCommit revc, RevCommit... revother) throws IOException, GitAPIException { if (revc.getId() == revc.zeroId()) return null; RevCommit parent = null; if (revother.length > 0) parent = revother[0]; else if (revc.getParents().length > 0) parent = revc.getParent(0); else parent = revc; if (parent.getId() == ObjectId.zeroId()) return null; List<DiffEntry> diffEntries = diffRevisions(parent, revc); Commit commit = new Commit(revc); for (DiffEntry entry : diffEntries) { DiffLines changedLines = diffFile(entry); commit.diffWithParent.put(entry.getNewPath(), changedLines); commit.changeTypes.put(entry.getNewPath(), entry.getChangeType()); } return commit; }
Example 3
Source File: RevisionDiffPanel.java From onedev with MIT License | 5 votes |
private ObjectId getOldCommitId() { if (oldRev.equals(ObjectId.zeroId().name().toString())) { return ObjectId.zeroId(); } else { return projectModel.getObject().getRevCommit(oldRev, true); } }
Example 4
Source File: RevisionDiffPanel.java From onedev with MIT License | 5 votes |
private ObjectId getNewCommitId() { if (newRev.equals(ObjectId.zeroId().name().toString())) { return ObjectId.zeroId(); } else { return projectModel.getObject().getRevCommit(newRev, true); } }
Example 5
Source File: TextDiffPanel.java From onedev with MIT License | 5 votes |
private ObjectId getOldCommit() { String oldRev = change.getOldBlobIdent().revision; if (oldRev.equals(ObjectId.zeroId().name().toString())) { return ObjectId.zeroId(); } else { return projectModel.getObject().getRevCommit(oldRev, true); } }
Example 6
Source File: TextDiffPanel.java From onedev with MIT License | 5 votes |
private ObjectId getNewCommit() { String newRev = change.getNewBlobIdent().revision; if (newRev.equals(ObjectId.zeroId().name().toString())) { return ObjectId.zeroId(); } else { return projectModel.getObject().getRevCommit(newRev, true); } }
Example 7
Source File: CommitDetailPage.java From onedev with MIT License | 5 votes |
private ObjectId getCompareWith() { List<RevCommit> parents = getParents(); if (parents.size() == 0) { return ObjectId.zeroId(); } else if (resolvedCompareWith != null) { if (parents.contains(resolvedCompareWith)) return resolvedCompareWith; else return parents.get(0); } else { return parents.get(0); } }