@@ -27,6 +27,7 @@ import kotlinx.coroutines.sync.withLock
2727import org.apache.logging.log4j.kotlin.logger
2828
2929import org.ossreviewtoolkit.model.VcsInfo
30+ import org.ossreviewtoolkit.plugins.api.PluginConfig
3031import org.ossreviewtoolkit.utils.common.safeDeleteRecursively
3132import org.ossreviewtoolkit.utils.ort.createOrtTempDir
3233
@@ -55,11 +56,23 @@ interface WorkingTreeCache {
5556
5657class DefaultWorkingTreeCache : WorkingTreeCache {
5758 private val mutex = Mutex ()
59+ private val vcsPluginConfigs = mutableMapOf<String , PluginConfig >()
5860 private val workingTreeMutexes = mutableMapOf<String , Mutex >()
5961 private val workingTrees = mutableMapOf<String , WorkingTree >()
6062
6163 private var terminated = false
6264
65+ /* *
66+ * Add [VCS plugin configurations][configs] that are applied when creating a [VersionControlSystem] instance
67+ * for this working tree. Calling this function is optional.
68+ */
69+ @Suppress(" unused" ) // Intended for use when this class is consumed externally as a library.
70+ fun addVcsPluginConfigs (configs : Map <String , PluginConfig >): DefaultWorkingTreeCache {
71+ logger.debug { " Using VCS plugin configs: $configs " }
72+ vcsPluginConfigs + = configs
73+ return this
74+ }
75+
6376 override suspend fun <T > use (vcsInfo : VcsInfo , block : (VersionControlSystem , WorkingTree ) -> T ): T {
6477 val vcs = getVcs(vcsInfo)
6578 return getWorkingTreeMutex(vcsInfo).withLock { block(vcs, getWorkingTree(vcsInfo, vcs)) }
@@ -75,8 +88,8 @@ class DefaultWorkingTreeCache : WorkingTreeCache {
7588 }
7689
7790 private fun getVcs (vcsInfo : VcsInfo ) =
78- VersionControlSystem .forType(vcsInfo.type)
79- ? : VersionControlSystem .forUrl(vcsInfo.url)
91+ VersionControlSystem .forType(vcsInfo.type, vcsPluginConfigs )
92+ ? : VersionControlSystem .forUrl(vcsInfo.url, vcsPluginConfigs )
8093 ? : throw IOException (" Could not determine VCS for type '${vcsInfo.type} ' and URL ${vcsInfo.url} ." )
8194
8295 private fun getWorkingTree (vcsInfo : VcsInfo , vcs : VersionControlSystem ) =
0 commit comments