diff --git a/src/App/Fossa/VSIDeps.hs b/src/App/Fossa/VSIDeps.hs index 678c816230..b4d5e4fc53 100644 --- a/src/App/Fossa/VSIDeps.hs +++ b/src/App/Fossa/VSIDeps.hs @@ -30,8 +30,8 @@ import Graphing (Graphing) import Graphing qualified import Path (Abs, Dir, Path, toFilePath) import Srclib.Converter qualified as Srclib -import Srclib.Types (AdditionalDepData (..), SourceUnit (..), SourceUserDefDep) -import Types (DiscoveredProjectType (..)) +import Srclib.Types (AdditionalDepData (..), SourceUnit (..), SourceUserDefDep, textToOriginPath) +import Types (DiscoveredProjectType (..), GraphBreadth (Complete)) -- | VSI analysis is sufficiently different from other analysis types that it cannot be just another strategy. -- Instead, VSI analysis is run separately over the entire scan directory, outputting its own source unit. @@ -62,9 +62,8 @@ analyzeVSIDeps dir projectRevision filters skipResolving = do -- These deps have to get up to the backend somehow on a 'SourceUnit's 'additionalData'. -- This generates an empty-graph source unit and puts the userdeps on it. - let renderedPath = toText (toFilePath dir) - let userDepSrcUnits = toSourceUnit renderedPath mempty resolvedUserDeps + userDepSrcUnits = toSourceUnit renderedPath mempty resolvedUserDeps pure . Just $ userDepSrcUnits : directSrcUnits @@ -76,7 +75,7 @@ ruleToSourceUnit skipResolving VSI.VsiRule{..} = do toSourceUnit :: Text -> Graphing Dependency -> Maybe [SourceUserDefDep] -> SourceUnit toSourceUnit path deps additionalDeps = do - let unit = Srclib.toSourceUnit False path deps VsiProjectType + let unit = Srclib.toSourceUnit False path deps VsiProjectType Complete [textToOriginPath path] unit{additionalData = fmap toDepData additionalDeps} where toDepData d = AdditionalDepData (Just d) Nothing diff --git a/src/Srclib/Converter.hs b/src/Srclib/Converter.hs index f7380cdeb4..18407c8838 100644 --- a/src/Srclib/Converter.hs +++ b/src/Srclib/Converter.hs @@ -34,6 +34,7 @@ import Graphing qualified import Path (toFilePath) import Srclib.Types ( Locator (..), + OriginPath, SourceUnit (..), SourceUnitBuild ( SourceUnitBuild, @@ -43,18 +44,19 @@ import Srclib.Types ( buildSucceeded ), SourceUnitDependency (..), - textToOriginPath, + somePathToOriginPath, ) import Types (DiscoveredProjectType, GraphBreadth (..)) projectToSourceUnit :: Bool -> ProjectResult -> SourceUnit projectToSourceUnit leaveUnfiltered ProjectResult{..} = - toSourceUnit leaveUnfiltered renderedPath projectResultGraph projectResultType + toSourceUnit leaveUnfiltered renderedPath projectResultGraph projectResultType projectResultGraphBreadth originPaths where renderedPath = toText (toFilePath projectResultPath) + originPaths = map somePathToOriginPath projectResultManifestFiles -toSourceUnit :: Bool -> Text -> Graphing Dependency -> DiscoveredProjectType -> SourceUnit -toSourceUnit leaveUnfiltered path dependencies projectType = +toSourceUnit :: Bool -> Text -> Graphing Dependency -> DiscoveredProjectType -> GraphBreadth -> [OriginPath] -> SourceUnit +toSourceUnit leaveUnfiltered path dependencies projectType graphBreadth originPaths = SourceUnit { sourceUnitName = path , sourceUnitType = toText projectType @@ -67,8 +69,8 @@ toSourceUnit leaveUnfiltered path dependencies projectType = , buildImports = imports , buildDependencies = deps } - , sourceUnitGraphBreadth = Complete - , sourceUnitOriginPaths = [textToOriginPath path] + , sourceUnitGraphBreadth = graphBreadth + , sourceUnitOriginPaths = originPaths , additionalData = Nothing } where