Skip to content

Commit 35476b5

Browse files
committed
fix(Analyzer): Init Repository.EMPTY on blank vcs
Signed-off-by: Jens Keim <[email protected]>
1 parent 2301ab2 commit 35476b5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

analyzer/src/main/kotlin/Analyzer.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import org.ossreviewtoolkit.model.AnalyzerRun
4343
import org.ossreviewtoolkit.model.OrtResult
4444
import org.ossreviewtoolkit.model.Repository
4545
import org.ossreviewtoolkit.model.RepositoryProvenance
46+
import org.ossreviewtoolkit.model.VcsInfo
4647
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
4748
import org.ossreviewtoolkit.model.config.Excludes
4849
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
@@ -149,14 +150,19 @@ class Analyzer(private val config: AnalyzerConfiguration, private val labels: Ma
149150
// Only include nested VCS if they are part of the analyzed directory.
150151
workingTree.getRootPath().resolve(path).startsWith(info.absoluteProjectPath)
151152
}.orEmpty()
152-
val repository = Repository(
153-
provenance = RepositoryProvenance(
154-
vcsInfo = vcs,
155-
resolvedRevision = vcs.revision
156-
),
157-
nestedRepositories = nestedVcs,
158-
config = info.repositoryConfiguration
159-
)
153+
154+
val repository = if (vcs == VcsInfo.EMPTY) {
155+
Repository.EMPTY
156+
} else {
157+
Repository(
158+
provenance = RepositoryProvenance(
159+
vcsInfo = vcs,
160+
resolvedRevision = vcs.revision
161+
),
162+
nestedRepositories = nestedVcs,
163+
config = info.repositoryConfiguration
164+
)
165+
}
160166

161167
val endTime = Instant.now()
162168

0 commit comments

Comments
 (0)