android: retain aggregated file patches
This commit is contained in:
@@ -98,6 +98,16 @@ internal fun parseUnifiedPatch(patch: String?): FileDiff {
|
||||
current?.let { hunks += it.build() }
|
||||
current = HunkBuilder(line, hunkStart.oldStart, hunkStart.oldCount, hunkStart.newStart, hunkStart.newCount)
|
||||
}
|
||||
// An aggregated entry can contain one complete patch from each
|
||||
// contributing stage. A new file header closes the preceding hunk
|
||||
// instead of being rendered as an unnumbered context line in it.
|
||||
line.startsWith("--- ") || line.startsWith("+++ ") -> {
|
||||
current?.let {
|
||||
hunks += it.build()
|
||||
current = null
|
||||
}
|
||||
headers += line
|
||||
}
|
||||
current == null -> headers += line
|
||||
else -> current.lines += parseBodyLine(line, current)
|
||||
}
|
||||
@@ -305,7 +315,12 @@ internal fun runChanges(steps: List<RunStep>): RunChanges {
|
||||
(file.beforeMode != null && file.afterMode != null &&
|
||||
file.beforeMode != file.afterMode && !file.binary && parsed.added == 0 && parsed.removed == 0),
|
||||
steps = mergedSteps,
|
||||
patch = file.patch?.takeIf { it.isNotBlank() } ?: existing?.patch,
|
||||
// Preserve every recorded textual patch for a path. A file may be
|
||||
// changed by several stages, and retaining only the first one
|
||||
// would make the displayed hunks disagree with the aggregate stat.
|
||||
patch = listOfNotNull(existing?.patch, file.patch?.takeIf { it.isNotBlank() })
|
||||
.joinToString("\n")
|
||||
.takeIf { it.isNotBlank() },
|
||||
)
|
||||
entries[file.path] = entry
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user