diff --git a/model/src/main/kotlin/Provenance.kt b/model/src/main/kotlin/Provenance.kt index cdea2aa391201..f0d2a535e7885 100644 --- a/model/src/main/kotlin/Provenance.kt +++ b/model/src/main/kotlin/Provenance.kt @@ -76,7 +76,9 @@ data class RepositoryProvenance( val resolvedRevision: String ) : KnownProvenance { init { - require(resolvedRevision.isNotBlank()) { "The resolved revision must not be blank." } + require(vcsInfo == VcsInfo.EMPTY || resolvedRevision.isNotBlank()) { + "The resolved revision must not be blank." + } } /** diff --git a/model/src/test/kotlin/OrtResultTest.kt b/model/src/test/kotlin/OrtResultTest.kt index c5065a38cd65a..a514d4e351908 100644 --- a/model/src/test/kotlin/OrtResultTest.kt +++ b/model/src/test/kotlin/OrtResultTest.kt @@ -83,9 +83,9 @@ class OrtResultTest : WordSpec({ "getDefinitionFilePathRelativeToAnalyzerRoot()" should { "use the correct vcs" { - val vcs = VcsInfo(type = VcsType.GIT, url = "https://example.com/git", revision = "") - val nestedVcs1 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git1", revision = "") - val nestedVcs2 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git2", revision = "") + val vcs = VcsInfo(type = VcsType.GIT, url = "https://example.com/git", revision = "main") + val nestedVcs1 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git1", revision = "main") + val nestedVcs2 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git2", revision = "main") val project1 = Project.EMPTY.copy( id = Identifier("Gradle:org.ossreviewtoolkit:project1:1.0"), definitionFilePath = "project1/build.gradle", @@ -123,9 +123,9 @@ class OrtResultTest : WordSpec({ } "fail if no vcs matches" { - val vcs = VcsInfo(type = VcsType.GIT, url = "https://example.com/git", revision = "") - val nestedVcs1 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git1", revision = "") - val nestedVcs2 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git2", revision = "") + val vcs = VcsInfo(type = VcsType.GIT, url = "https://example.com/git", revision = "main") + val nestedVcs1 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git1", revision = "main") + val nestedVcs2 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git2", revision = "main") val project = Project.EMPTY.copy( id = Identifier("Gradle:org.ossreviewtoolkit:project1:1.0"), definitionFilePath = "build.gradle",