Skip to content

Commit 8fc6255

Browse files
committed
feat(diff-simplifier): Include binary or large changes in output
Previously, the DiffSimplifier was not accounting for binary or too large changes when generating the output. This commit introduces a new list to capture such changes and includes them in the final output string. This ensures that all changes, including binary file operations and large modifications, are now properly reflected in the diff summary.
1 parent e27f2f4 commit 8fc6255

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/kotlin/cc/unitmesh/devti/vcs/DiffSimplifier.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ class DiffSimplifier(val project: Project) {
3232
try {
3333
val writer = StringWriter()
3434
val basePath = project.basePath ?: throw RuntimeException("Project base path is null.")
35+
val binaryOrTooLargeChanges: List<String> = changes.stream()
36+
.filter { change -> isBinaryOrTooLarge(change!!) }
37+
.map {
38+
when(it.type) {
39+
Change.Type.NEW -> "new file ${it.afterRevision?.file?.path}"
40+
Change.Type.DELETED -> "delete file ${it.beforeRevision?.file?.path}"
41+
Change.Type.MODIFICATION -> "modify file ${it.beforeRevision?.file?.path}"
42+
Change.Type.MOVED -> "rename file from ${it.beforeRevision?.file?.path} to ${it.afterRevision?.file?.path}"
43+
}
44+
}
45+
.toList()
3546

3647
val filteredChanges = changes.stream()
3748
.filter { change -> !isBinaryOrTooLarge(change!!) }
@@ -71,6 +82,7 @@ class DiffSimplifier(val project: Project) {
7182
)
7283

7384
originChanges = writer.toString()
85+
originChanges += binaryOrTooLargeChanges.joinToString("\n")
7486
return postProcess(originChanges)
7587
} catch (e: Exception) {
7688
if (originChanges.isNotEmpty()) {

0 commit comments

Comments
 (0)