mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-24 07:20:49 +01:00
Add table to diff view
Pushed-by: Florian Scholdei<florian.scholdei@cloudogu.com> Pushed-by: Viktor Egorov<viktor.egorov-extern@cloudogu.com> Pushed-by: k8s-git-ops<admin@cloudogu.com> Committed-by: Thomas Zerr<thomas.zerr@cloudogu.com> Co-authored-by: Viktor<viktor.egorov@triology.de> Co-authored-by: Thomas Zerr<thomas.zerr@cloudogu.com> Pushed-by: Thomas Zerr<thomas.zerr@cloudogu.com>
This commit is contained in:
@@ -57,6 +57,8 @@ public class GitDiffResult implements DiffResult {
|
||||
private final int offset;
|
||||
private final Integer limit;
|
||||
|
||||
private DiffTreeNode tree;
|
||||
|
||||
public GitDiffResult(Repository scmRepository,
|
||||
org.eclipse.jgit.lib.Repository repository,
|
||||
Differ.Diff diff,
|
||||
@@ -210,4 +212,32 @@ public class GitDiffResult implements DiffResult {
|
||||
DiffStatistics stats = new DiffStatistics(addCounter, modifiedCounter, deletedCounter);
|
||||
return Optional.of(stats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DiffTreeNode> getDiffTree() {
|
||||
if (this.tree == null) {
|
||||
tree = DiffTreeNode.createRootNode();
|
||||
|
||||
for (DiffEntry diffEntry : diffEntries) {
|
||||
DiffEntry.Side side = DiffEntry.Side.NEW;
|
||||
if (diffEntry.getChangeType() == DiffEntry.ChangeType.DELETE) {
|
||||
side = DiffEntry.Side.OLD;
|
||||
}
|
||||
DiffEntry.ChangeType type = diffEntry.getChangeType();
|
||||
String path = diffEntry.getPath(side);
|
||||
tree.addChild(path, mapChangeType(type));
|
||||
}
|
||||
}
|
||||
return Optional.of(tree);
|
||||
}
|
||||
|
||||
private DiffFile.ChangeType mapChangeType(DiffEntry.ChangeType changeType) {
|
||||
return switch (changeType) {
|
||||
case ADD -> DiffFile.ChangeType.ADD;
|
||||
case MODIFY -> DiffFile.ChangeType.MODIFY;
|
||||
case DELETE -> DiffFile.ChangeType.DELETE;
|
||||
case COPY -> DiffFile.ChangeType.COPY;
|
||||
case RENAME -> DiffFile.ChangeType.RENAME;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user