Skip to content

Commit 7d4727c

Browse files
committed
Support diffing uses-permission counts
There might be significant differences in blame attribution for AndroidManifest.xml. We usually pay close attention to changes in versionCode, targetSdk, and the count of uses-permissions. Adding an extra line to display the result.
1 parent 5e00c4b commit 7d4727c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

formats/src/main/kotlin/com/jakewharton/diffuse/format/AndroidManifest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class AndroidManifest private constructor(
3636
val packageName: String,
3737
val versionName: String?,
3838
val versionCode: Long?,
39+
val usesPermissionCount: Int?,
3940
) {
4041
companion object {
4142
const val NAME = "AndroidManifest.xml"
@@ -167,8 +168,9 @@ class AndroidManifest private constructor(
167168
} else {
168169
null
169170
}
171+
val usesPermissionCount = manifestElement.getElementsByTagName("uses-permission").length
170172

171-
return AndroidManifest(toFormattedXml(), packageName, versionName, versionCode)
173+
return AndroidManifest(toFormattedXml(), packageName, versionName, versionCode, usesPermissionCount)
172174
}
173175

174176
private fun Document.toFormattedXml() = buildString {

reports/src/main/kotlin/com/jakewharton/diffuse/diff/ManifestDiff.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ internal class ManifestDiff(
1111
) {
1212
internal val parsedPropertiesChanged = oldManifest.packageName != newManifest.packageName ||
1313
oldManifest.versionName != newManifest.versionName ||
14-
oldManifest.versionCode != newManifest.versionCode
14+
oldManifest.versionCode != newManifest.versionCode ||
15+
oldManifest.usesPermissionCount != newManifest.usesPermissionCount
1516

1617
val diff: List<String> = run {
1718
val oldLines = oldManifest.xml.lines()
@@ -34,6 +35,7 @@ internal fun ManifestDiff.toDetailReport() = buildString {
3435
row("package", oldManifest.packageName, newManifest.packageName)
3536
row("version code", oldManifest.versionCode, newManifest.versionCode)
3637
row("version name", oldManifest.versionName, newManifest.versionName)
38+
row("uses-permission count", oldManifest.usesPermissionCount, newManifest.usesPermissionCount)
3739
},
3840
)
3941
}

0 commit comments

Comments
 (0)