Skip to content

Commit

Permalink
Merge pull request #228 from chali/AddRequstedVersions
Browse files Browse the repository at this point in the history
Add requested versions for each node in path based diff to allow conflict resolution analysis on visualization side
  • Loading branch information
chali authored Nov 29, 2021
2 parents ccc186f + 6cb20e3 commit fa10d9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class PathAwareDiffReportGenerator : DiffReportGenerator {
else {
result["status"] = dependencyPathElement.extractStatus()
result["version"] = dependencyPathElement.selected.moduleVersion()
result["requestedVersion"] = dependencyPathElement.requestedVersion() ?: "Unknown"
}

if (!dependencyPathElement.alreadyVisited) {
Expand Down Expand Up @@ -193,15 +194,24 @@ class PathAwareDiffReportGenerator : DiffReportGenerator {
}

fun isWinnerOfConflictResolution(): Boolean {
val requestedVersion = requestedVersion()
return if (selected.selectionReason.isConflictResolution &&
requested is ModuleComponentSelector &&
requestedVersion != null &&
selected.id is ModuleComponentIdentifier) {
val selector = VERSION_SCHEME.parseSelector(requested.version)
val selector = VERSION_SCHEME.parseSelector(requestedVersion)
selector.accept((selected.id as ModuleComponentIdentifier).version)
} else
false
}

fun requestedVersion(): String? {
return if (requested is ModuleComponentSelector) {
requested.version
} else {
null
}
}

fun extractStatus(): String {
return this.selected.variants.first().attributes.getAttribute(ProjectInternal.STATUS_ATTRIBUTE) ?: throw RuntimeException("Unknown status")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ class PathAwareDependencyDiffSpec extends IntegrationTestKitSpec {
alignedConsumer1.change.type == "UPDATED"
alignedConsumer1.change.previousVersion == "1.0.0"
def consumer1 = alignedConsumer1.children.find { it.dependency == "test.example.alignment:consumer1-library"}
consumer1.requestedVersion == "1.0.0"
consumer1.version == "2.0.0"
consumer1.change.description == "requested; the parent brought this participant in conflict resolution, but the winner is from a different path; belongs to platform aligned-platform:diff-lock-with-paths-with-alignment-without-clear-conflict-resolution-winner-0-for-test.example.alignment:2.0.0"
consumer1.change.type == "UPDATED"
Expand Down

0 comments on commit fa10d9f

Please sign in to comment.