Skip to content

Commit 3c5efb8

Browse files
committed
doc(Repository): Add more comments to Deserializer
Signed-off-by: Jens Keim <[email protected]>
1 parent efe3d56 commit 3c5efb8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

model/src/main/kotlin/Repository.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,27 @@ private class RepositoryDeserializer : StdDeserializer<Repository>(Repository::c
8989
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Repository {
9090
val node = p.codec.readTree<JsonNode>(p)
9191
val parsedProvenance = when {
92-
// Parse [vcs] attribute and create a Repository
9392
node.has("vcs") -> {
93+
// Parse [vcs] and [vcsProcessed] attributes
9494
val vcsInfo = jsonMapper.treeToValue<VcsInfo>(node["vcs"])
9595
val vcsProcess = jsonMapper.treeToValue<VcsInfo>(node["vcs_processed"])
9696

97+
// Get the [vcs]'s revision
9798
val resolvedRevision = if (vcsInfo.revision != "") {
9899
vcsInfo.revision
99100
} else if (vcsProcess.revision != "") {
101+
// Fall back to [vcsProcessed], if [vcs] has empty revision
100102
vcsProcess.revision
101103
} else {
102104
HashAlgorithm.SHA1.emptyValue
103105
}
104106

107+
// Build a RepositoryProvenance from the parsed VcsInfo fields
105108
RepositoryProvenance(vcsInfo, resolvedRevision)
106109
}
107110

108111
else -> {
112+
// Parse the [provenance], if no legacy fields are present
109113
jsonMapper.treeToValue<RepositoryProvenance>(node["provenance"])
110114
}
111115
}

0 commit comments

Comments
 (0)