fix: application diff 接口调整,action 支持 rename,copy

This commit is contained in:
shizhendong
2024-11-08 15:27:59 +08:00
parent e5ed7cf47b
commit c7c971d508
2 changed files with 17 additions and 11 deletions

View File

@@ -126,9 +126,13 @@ public class ApplicationMergeServiceImpl extends ServiceImpl<ApplicationMergeDao
T.MapUtil.renameKey(m, "oldContent", "sourceContent");
T.MapUtil.renameKey(m, "newContent", "targetContent");
String path = T.MapUtil.getStr(m, "path");
T.MapUtil.renameKey(m, "oldPath", "sourcePath");
T.MapUtil.renameKey(m, "newPath", "targetPath");
String sourcePath = T.MapUtil.getStr(m, "sourcePath");
String targetPath = T.MapUtil.getStr(m, "targetPath");
m.put("conflict", false);
if (conflictFileList.contains(path)) {
if (conflictFileList.contains(sourcePath) || conflictFileList.contains(targetPath)) {
m.put("conflict", true);
}
});

View File

@@ -385,38 +385,40 @@ public class GitServiceImpl implements IGitService {
}
}
String path = null, encoding = null, oldContent = null, newContent = null;
String oldPath = diff.getOldPath(), newPath = diff.getNewPath(), encoding = null, oldContent = null, newContent = null;
switch (diff.getChangeType()) {
case COPY:
case ADD: {
path = diff.getNewPath();
Map<Object, Object> fileContent = this.getFileContent(repository, path, diff.getNewId().toObjectId());
Map<Object, Object> fileContent = this.getFileContent(repository, newPath, diff.getNewId().toObjectId());
encoding = T.MapUtil.getStr(fileContent, "encoding", "");
newContent = T.MapUtil.getStr(fileContent, "content", "");
break;
}
case DELETE: {
path = diff.getOldPath();
Map<Object, Object> fileContent = this.getFileContent(repository, path, diff.getOldId().toObjectId());
Map<Object, Object> fileContent = this.getFileContent(repository, oldPath, diff.getOldId().toObjectId());
encoding = T.MapUtil.getStr(fileContent, "encoding", "");
oldContent = T.MapUtil.getStr(fileContent, "content", "");
break;
}
case MODIFY: {
path = diff.getOldPath();
Map<Object, Object> fileContent = this.getFileContent(repository, path, diff.getOldId().toObjectId());
Map<Object, Object> fileContent = this.getFileContent(repository, oldPath, diff.getOldId().toObjectId());
oldContent = T.MapUtil.getStr(fileContent, "content", "");
Map<Object, Object> fileContent1 = this.getFileContent(repository, path, diff.getNewId().toObjectId());
Map<Object, Object> fileContent1 = this.getFileContent(repository, newPath, diff.getNewId().toObjectId());
encoding = T.MapUtil.getStr(fileContent1, "encoding", "");
newContent = T.MapUtil.getStr(fileContent1, "content", "");
break;
}
case RENAME: {
break;
}
default:
break;
}
files.add(
T.MapUtil.builder()
.put("path", path)
.put("oldPath", oldPath)
.put("newPath", newPath)
.put("addedLines", addedLines)
.put("removedLines", deletedLines)
.put("encoding", encoding)