jg.writeStartObject(); String namePath = entry.getOldPath(); if (entry.getChangeType().equals(DiffEntry.ChangeType.ADD)) { namePath = entry.getNewPath(); jg.writeStringField("type", entry.getChangeType().name()); jg.writeStringField("path", namePath); jg.writeStringField("diffs", entryList.get(entry));
/** * Creates a change for a modified file. * * @param git - GitUtil * @param entry - DiffEntry for the change * @return - Change */ @SuppressWarnings("DefaultCharset") @SneakyThrows public static Change createModifyChange(final GitUtil git, final DiffEntry entry) { val file = git.repoPath() + '/' + entry.getNewPath(); val json = new String(Files.readAllBytes(Paths.get(file))); val svc = CasManagementUtils.fromJson(json); return new Change(String.valueOf(svc.getId()), entry.getNewPath(), entry.getChangeType().toString(), svc.getName(), ObjectId.toString(entry.getOldId().toObjectId()), ObjectId.toString(entry.getNewId().toObjectId())); }
@Override public WatchEvent.Kind kind() { DiffEntry.ChangeType changeType = DiffEntry.ChangeType.valueOf(this.changeType); switch (changeType) { case ADD: case COPY: return StandardWatchEventKind.ENTRY_CREATE; case DELETE: return StandardWatchEventKind.ENTRY_DELETE; case MODIFY: return StandardWatchEventKind.ENTRY_MODIFY; case RENAME: return StandardWatchEventKind.ENTRY_RENAME; default: throw new RuntimeException("Unsupported change type: " + changeType); } }
diffSolrDoc.addField("type", "diff"); DiffEntry.ChangeType diffType = diffEntry.getChangeType(); diffSolrDoc.addField("diffType", diffType.name());
String changeType = diffEntry.getChangeType().name().toUpperCase();
for (DiffEntry diff : diffs) { String objectId = diff.getNewId().name(); if (diff.getChangeType().equals(ChangeType.DELETE)) { list.add(new CommitTreeInfo(diff.getOldPath(), diff.getOldPath(), 0, diff .getNewMode().getBits(), objectId, commit.getId().getName(), diff .getChangeType())); } else if (diff.getChangeType().equals(ChangeType.RENAME)) { list.add(new CommitTreeInfo(diff.getOldPath(), diff.getNewPath(), 0, diff .getNewMode().getBits(), objectId, commit.getId().getName(), diff
userName, message, diffEntry.getChangeType().name(), oldPath, newPath);
for (DiffEntry diff : diffs) { String objectId = diff.getNewId().name(); if (diff.getChangeType().equals(DiffEntry.ChangeType.DELETE)) { list.add(new CommitTreeInfo(diff.getOldPath(), diff.getOldPath(), 0, diff .getNewMode().getBits(), objectId, commit.getId().getName(), diff .getChangeType())); } else if (diff.getChangeType().equals(DiffEntry.ChangeType.RENAME)) { list.add(new CommitTreeInfo(diff.getOldPath(), diff.getNewPath(), 0, diff .getNewMode().getBits(), objectId, commit.getId().getName(), diff
setAttributeValue(diffTypeAttribute, diffEntry.getChangeType().name());
final List<DiffEntry> diffs = getDiffEntries(commit, parent); for (final DiffEntry diff : diffs) { final String changePath = diff.getChangeType().equals(ChangeType.DELETE) ? diff.getOldPath() : diff.getNewPath(); final Matcher testNameMatcher = testNamePattern.matcher(changePath);
final List<DiffEntry> diffs = getDiffEntries(commit, parent); for (final DiffEntry diff : diffs) { final String changePath = diff.getChangeType().equals(ChangeType.DELETE) ? diff.getOldPath() : diff.getNewPath(); final Matcher testNameMatcher = testNamePattern.matcher(changePath);
final Edit edit) { try { final String changeType = header.getChangeType().toString(); final int startA = edit.getBeginA(); final int endA = edit.getEndA();
.getActiveWorkbenchWindow(); IWorkbenchPage page = window.getActivePage(); RevCommit commit = d.getChange().equals(ChangeType.DELETE) ? d .getCommit().getParent(0) : d.getCommit(); String path = d.getPath(); IFileRevision rev = CompareUtils.getFileRevision(path, commit, getRepository(), d.getChange().equals(ChangeType.DELETE) ? d.getBlobs()[0] : d.getBlobs()[d.getBlobs().length - 1]); if (rev != null) {
private void openFileInEditor(FileDiff d) { try { IWorkbenchWindow window = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); IWorkbenchPage page = window.getActivePage(); IFileRevision rev = CompareUtils.getFileRevision(d.getNewPath(), d .getChange().equals(ChangeType.DELETE) ? d.getCommit() .getParent(0) : d.getCommit(), getRepository(), d .getChange().equals(ChangeType.DELETE) ? d.getBlobs()[0] : d.getBlobs()[d.getBlobs().length - 1]); if (rev != null) EgitUiEditorUtils.openEditor(page, rev, new NullProgressMonitor()); else { String message = NLS.bind( UIText.CommitFileDiffViewer_notContainedInCommit, d .getNewPath(), d.getCommit().getId().getName()); Activator.showError(message, null); } } catch (IOException e) { Activator.logError(UIText.GitHistoryPage_openFailed, e); Activator.showError(UIText.GitHistoryPage_openFailed, null); } catch (CoreException e) { Activator.logError(UIText.GitHistoryPage_openFailed, e); Activator.showError(UIText.GitHistoryPage_openFailed, null); } }
/** * Method creates a diff object to be returned to the client. * * @param diff - DiffEntry * @param git - GitUtil * @return - Diff */ public static Diff createDiff(final DiffEntry diff, final GitUtil git) { try { val id = diff.getChangeType() == DiffEntry.ChangeType.ADD ? diff.getNewId().toObjectId() : diff.getOldId().toObjectId(); val service = CasManagementUtils.fromJson(git.readObject(id)); return new Diff(diff.getNewPath(), diff.getOldId().toObjectId(), diff.getNewId().toObjectId(), diff.getChangeType().toString(), service.getName()); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); return null; } } }
/** * Creates a change for a delete file. * * @param git - GitUtil * @param entry - DiffEntry for the change. * @return - Change */ @SneakyThrows public static Change createDeleteChange(final GitUtil git, final DiffEntry entry) { val json = git.readObject(entry.getOldId().toObjectId()); val svc = CasManagementUtils.fromJson(json); return new Change(String.valueOf(svc.getId()), entry.getOldPath(), DiffEntry.ChangeType.DELETE.toString(), svc.getName(), ObjectId.toString(entry.getOldId().toObjectId()), null); }
private Modification diffToModification(Repository repo, DiffEntry diff) throws IOException { ModificationType change = Enum.valueOf(ModificationType.class, diff.getChangeType().toString()); String oldPath = diff.getOldPath(); String newPath = diff.getNewPath(); String diffText = ""; String sc = ""; if (diff.getChangeType() != ChangeType.DELETE) { diffText = getDiffText(repo, diff); sc = getSourceCode(repo, diff); } if (diffText.length() > maxSizeOfDiff) { log.error("diff for " + newPath + " too big"); diffText = "-- TOO BIG --"; } return new Modification(oldPath, newPath, change, diffText, sc); }
/** * @return the old path in case of a delete, the new path otherwise, but * never null or <code>/dev/null</code> * @see #getNewPath() * @see #getOldPath() */ public String getPath() { if (ChangeType.DELETE.equals(diffEntry.getChangeType())) return diffEntry.getOldPath(); return diffEntry.getNewPath(); }