List of usage examples for org.eclipse.jgit.patch FileHeader getNewMode
public FileMode getNewMode()
From source file:com.google.gerrit.server.patch.PatchListEntry.java
License:Apache License
PatchListEntry(final FileHeader hdr, List<Edit> editList) { changeType = toChangeType(hdr);/* w w w . j a va2s .c o m*/ patchType = toPatchType(hdr); switch (changeType) { case DELETED: oldName = null; newName = hdr.getOldPath(); break; case ADDED: case MODIFIED: oldName = null; newName = hdr.getNewPath(); break; case COPIED: case RENAMED: oldName = hdr.getOldPath(); newName = hdr.getNewPath(); break; default: throw new IllegalArgumentException("Unsupported type " + changeType); } header = compact(hdr); if (hdr instanceof CombinedFileHeader || hdr.getHunks().isEmpty() // || hdr.getOldMode() == FileMode.GITLINK || hdr.getNewMode() == FileMode.GITLINK) { edits = Collections.emptyList(); } else { edits = Collections.unmodifiableList(editList); } int ins = 0; int del = 0; for (Edit e : editList) { del += e.getEndA() - e.getBeginA(); ins += e.getEndB() - e.getBeginB(); } insertions = ins; deletions = del; }
From source file:com.google.gerrit.server.patch.PatchListLoader.java
License:Apache License
private PatchListEntry newEntry(RevTree aTree, FileHeader fileHeader) { final FileMode oldMode = fileHeader.getOldMode(); final FileMode newMode = fileHeader.getNewMode(); if (oldMode == FileMode.GITLINK || newMode == FileMode.GITLINK) { return new PatchListEntry(fileHeader, Collections.<Edit>emptyList()); }//from w ww . j av a 2 s . com if (aTree == null // want combined diff || fileHeader.getPatchType() != PatchType.UNIFIED || fileHeader.getHunks().isEmpty()) { return new PatchListEntry(fileHeader, Collections.<Edit>emptyList()); } List<Edit> edits = fileHeader.toEditList(); if (edits.isEmpty()) { return new PatchListEntry(fileHeader, Collections.<Edit>emptyList()); } else { return new PatchListEntry(fileHeader, edits); } }