Skip to content

Commit

Permalink
downloader: Do not guess revision if it was already resolved
Browse files Browse the repository at this point in the history
The `VcsInfo.isResolvedRevision` property can be used by the analyzer to
signal that the provided revision was already resolved. Therefore do not
try to guess a revision anymore if this property is set to true and fail
the download instead if the revision cannot be downloaded.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@here.com>
  • Loading branch information
mnonnenmacher committed Jun 9, 2021
1 parent 8ac7b84 commit 71c603b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions downloader/src/main/kotlin/VersionControlSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,22 @@ abstract class VersionControlSystem {
emptyRevisionCandidatesException.addSuppressed(it)
}.isSuccess

if (!addGuessedRevision(pkg.id.name, pkg.id.version)) {
when {
pkg.id.type == "NPM" && pkg.id.namespace.isNotEmpty() -> {
// Fallback for Lerna workspaces when scoped packages combined with independent versioning are used,
// e.g. support Git tag of the format "@organisation/my-component@x.x.x".
addGuessedRevision("${pkg.id.namespace}/${pkg.id.name}", pkg.id.version)
}
if (!pkg.vcsProcessed.isResolvedRevision) {
if (!addGuessedRevision(pkg.id.name, pkg.id.version)) {
when {
pkg.id.type == "NPM" && pkg.id.namespace.isNotEmpty() -> {
// Fallback for Lerna workspaces when scoped packages combined with independent versioning are
// used, e.g. support Git tag of the format "@organisation/my-component@x.x.x".
addGuessedRevision("${pkg.id.namespace}/${pkg.id.name}", pkg.id.version)
}

pkg.id.type == "GoMod" && pkg.vcsProcessed.path.isNotEmpty() -> {
// Fallback for GoMod packages from mono repos which use the tag format described in
// https://golang.org/ref/mod#vcs-version.
val tag = "${pkg.vcsProcessed.path}/${pkg.id.version}"
pkg.id.type == "GoMod" && pkg.vcsProcessed.path.isNotEmpty() -> {
// Fallback for GoMod packages from mono repos which use the tag format described in
// https://golang.org/ref/mod#vcs-version.
val tag = "${pkg.vcsProcessed.path}/${pkg.id.version}"

if (tag in workingTree.listRemoteTags()) revisionCandidates += tag
if (tag in workingTree.listRemoteTags()) revisionCandidates += tag
}
}
}
}
Expand Down

0 comments on commit 71c603b

Please sign in to comment.