mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 03:25:56 +01:00
Make change types explicit
Without explicit change types, we cannot tell copy and rename apart.
This commit is contained in:
@@ -57,7 +57,7 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand {
|
||||
formatter.setRepository(repository);
|
||||
|
||||
for (DiffEntry e : diff.getEntries()) {
|
||||
if (!e.getOldId().equals(e.getNewId()) || !e.getNewPath().equals(e.getOldPath())) {
|
||||
if (idOrPathChanged(e)) {
|
||||
formatter.format(e);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,10 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand {
|
||||
};
|
||||
}
|
||||
|
||||
private boolean idOrPathChanged(DiffEntry e) {
|
||||
return !e.getOldId().equals(e.getNewId()) || !e.getNewPath().equals(e.getOldPath());
|
||||
}
|
||||
|
||||
static class DequoteOutputStream extends OutputStream {
|
||||
|
||||
private static final String[] DEQUOTE_STARTS = {
|
||||
|
||||
@@ -108,6 +108,24 @@ public class GitDiffResultCommand extends AbstractGitCommand implements DiffResu
|
||||
return diffEntry.getNewPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeType getChangeType() {
|
||||
switch (diffEntry.getChangeType()) {
|
||||
case ADD:
|
||||
return ChangeType.ADD;
|
||||
case MODIFY:
|
||||
return ChangeType.MODIFY;
|
||||
case RENAME:
|
||||
return ChangeType.RENAME;
|
||||
case DELETE:
|
||||
return ChangeType.DELETE;
|
||||
case COPY:
|
||||
return ChangeType.COPY;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown change type: " + diffEntry.getChangeType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Hunk> iterator() {
|
||||
String content = format(repository, diffEntry);
|
||||
|
||||
Reference in New Issue
Block a user