-
Notifications
You must be signed in to change notification settings - Fork 15
feat(scanner): Add submodule fetch strategy for nested repositories #2679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
package org.eclipse.apoapsis.ortserver.workers.scanner | ||
|
||
import org.eclipse.apoapsis.ortserver.model.ScannerJobConfiguration | ||
import org.eclipse.apoapsis.ortserver.model.SubmoduleFetchStrategy | ||
import org.eclipse.apoapsis.ortserver.workers.common.OrtServerFileListStorage | ||
import org.eclipse.apoapsis.ortserver.workers.common.context.WorkerContext | ||
import org.eclipse.apoapsis.ortserver.workers.common.mapToOrt | ||
|
@@ -33,6 +34,7 @@ import org.ossreviewtoolkit.model.PackageType | |
import org.ossreviewtoolkit.model.Provenance | ||
import org.ossreviewtoolkit.model.ScannerRun | ||
import org.ossreviewtoolkit.model.SourceCodeOrigin | ||
import org.ossreviewtoolkit.model.VcsType | ||
import org.ossreviewtoolkit.model.config.DownloaderConfiguration | ||
import org.ossreviewtoolkit.model.config.ScannerConfiguration | ||
import org.ossreviewtoolkit.model.utils.FileArchiver | ||
|
@@ -85,7 +87,20 @@ class ScannerRunner( | |
?: listOf(SourceCodeOrigin.ARTIFACT, SourceCodeOrigin.VCS) | ||
) | ||
|
||
val workingTreeCache = DefaultWorkingTreeCache() | ||
// If the submodule fetch strategy is set to TOP_LEVEL_ONLY, for git use a plugin config that prevents that | ||
// submodules are fetched recursively. | ||
val vcsPluginConfigs = if (config.submoduleFetchStrategy == SubmoduleFetchStrategy.TOP_LEVEL_ONLY) { | ||
mapOf( | ||
VcsType.GIT.toString() to PluginConfig( | ||
options = mapOf("updateNestedSubmodules" to "false") | ||
) | ||
) | ||
} else { | ||
emptyMap() | ||
} | ||
|
||
val workingTreeCache = DefaultWorkingTreeCache().addVcsPluginConfigs(vcsPluginConfigs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The VCS options are not part of the storage key for the nested provenance storage. This means that changing this setting has no effect for repositories where there is already a stored resolution result which could lead to unexpected results. I think to implement this correctly, the storage would have to be adapted as well which might also require changes in ORT. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be more precise, in the analyzer this option only affects the project repository, but here it affects also repositories of dependencies which might also be dependencies of other projects which do not use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To my understanding: You are talking about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I mean the |
||
|
||
val provenanceDownloader = DefaultProvenanceDownloader(downloaderConfig, workingTreeCache) | ||
val packageProvenanceResolver = DefaultPackageProvenanceResolver( | ||
scanStorages.packageProvenanceStorage, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way to test this? Maybe with a constructor mock and a verification that the Git-specific plugin options have actually been set?