本文整理匯總了Java中org.eclipse.jgit.diff.DiffFormatter.release方法的典型用法代碼示例。如果您正苦於以下問題:Java DiffFormatter.release方法的具體用法?Java DiffFormatter.release怎麽用?Java DiffFormatter.release使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.diff.DiffFormatter
的用法示例。
在下文中一共展示了DiffFormatter.release方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: formatHtmlDiff
import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private void formatHtmlDiff(OutputStream out,
Repository repo, RevWalk walk,
AbstractTreeIterator oldTree, AbstractTreeIterator newTree,
String path)
throws IOException {
DiffFormatter diff = new HtmlDiffFormatter(renderer, out);
try {
if (!path.equals("")) {
diff.setPathFilter(PathFilter.create(path));
}
diff.setRepository(repo);
diff.setDetectRenames(true);
diff.format(oldTree, newTree);
} finally {
diff.release();
}
}
示例2: testDiffRenameDetectionProblem
import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
public void testDiffRenameDetectionProblem () throws Exception {
File file = new File(workDir, "file");
File renamed = new File(workDir, "renamed");
File patchFile = new File(workDir.getParentFile(), "diff.patch");
write(file, "hey, i will be renamed\n");
add(file);
commit(file);
file.renameTo(renamed);
write(renamed, "hey, i will be renamed\nand now i am\n");
OutputStream out = new BufferedOutputStream(new FileOutputStream(patchFile));
DiffFormatter formatter = new DiffFormatter(out);
formatter.setRepository(repository);
ObjectReader or = null;
try {
formatter.setDetectRenames(true);
AbstractTreeIterator firstTree = new DirCacheIterator(repository.readDirCache());;
AbstractTreeIterator secondTree = new FileTreeIterator(repository);
formatter.format(firstTree, secondTree);
formatter.flush();
fail("Fixed in JGit, modify and simplify the sources in ExportDiff command");
} catch (IOException ex) {
assertEquals("Missing blob 7b34a309b8dbae2686c9e597efef28a612e48aff", ex.getMessage());
} finally {
if (or != null) {
or.release();
}
formatter.release();
}
}
示例3: run
import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
@Override
protected void run() throws GitException {
Repository repository = getRepository();
DiffFormatter formatter = new DiffFormatter(out);
formatter.setRepository(repository);
ObjectReader or = null;
String workTreePath = repository.getWorkTree().getAbsolutePath();
try {
Collection<PathFilter> pathFilters = Utils.getPathFilters(repository.getWorkTree(), roots);
if (!pathFilters.isEmpty()) {
formatter.setPathFilter(PathFilterGroup.create(pathFilters));
}
if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) {
// work-around for autocrlf
formatter.setDiffComparator(new AutoCRLFComparator());
}
or = repository.newObjectReader();
AbstractTreeIterator firstTree = getIterator(firstCommit, or);
AbstractTreeIterator secondTree = getIterator(secondCommit, or);
List<DiffEntry> diffEntries;
if (secondTree instanceof WorkingTreeIterator) {
// remote when fixed in JGit, see ExportDiffTest.testDiffRenameDetectionProblem
formatter.setDetectRenames(false);
diffEntries = formatter.scan(firstTree, secondTree);
formatter.setDetectRenames(true);
RenameDetector detector = formatter.getRenameDetector();
detector.reset();
detector.addAll(diffEntries);
diffEntries = detector.compute(new ContentSource.Pair(ContentSource.create(or), ContentSource.create((WorkingTreeIterator) secondTree)), NullProgressMonitor.INSTANCE);
} else {
formatter.setDetectRenames(true);
diffEntries = formatter.scan(firstTree, secondTree);
}
for (DiffEntry ent : diffEntries) {
if (monitor.isCanceled()) {
break;
}
listener.notifyFile(new File(workTreePath + File.separator + ent.getNewPath()), ent.getNewPath());
formatter.format(ent);
}
formatter.flush();
} catch (IOException ex) {
throw new GitException(ex);
} finally {
if (or != null) {
or.release();
}
formatter.release();
}
}