@@ -54,6 +54,7 @@ import Effect.ReadFS (ReadFS)
54
54
import Fossa.API.Types (ApiOpts , Organization (.. ), orgFileUpload )
55
55
import Path (Abs , Dir , File , Path )
56
56
import Srclib.Types (LicenseScanType (.. ), LicenseSourceUnit (.. ), LicenseUnit (.. ), LicenseUnitData (.. ), LicenseUnitInfo (.. ), LicenseUnitMatchData (.. ))
57
+ import Types (LicenseScanPathFilters )
57
58
58
59
newtype CustomLicensePath = CustomLicensePath { unCustomLicensePath :: Text }
59
60
deriving (Eq , Ord , Show , Hashable )
@@ -72,12 +73,13 @@ analyzeWithLernie ::
72
73
Path Abs Dir ->
73
74
Maybe ApiOpts ->
74
75
GrepOptions ->
76
+ Maybe LicenseScanPathFilters ->
75
77
m (Maybe LernieResults )
76
- analyzeWithLernie rootDir maybeApiOpts grepOptions = do
78
+ analyzeWithLernie rootDir maybeApiOpts grepOptions filters = do
77
79
case (maybeApiOpts, orgWideCustomLicenseScanConfigPolicy grepOptions) of
78
- (_, Ignore ) -> analyzeWithLernieMain rootDir grepOptions FileUploadMatchData
79
- (Nothing , Use ) -> analyzeWithLernieMain rootDir grepOptions FileUploadMatchData
80
- (Just apiOpts, Use ) -> runFossaApiClient apiOpts $ analyzeWithLernieWithOrgInfo rootDir grepOptions
80
+ (_, Ignore ) -> analyzeWithLernieMain rootDir grepOptions filters FileUploadMatchData
81
+ (Nothing , Use ) -> analyzeWithLernieMain rootDir grepOptions filters FileUploadMatchData
82
+ (Just apiOpts, Use ) -> runFossaApiClient apiOpts $ analyzeWithLernieWithOrgInfo rootDir grepOptions filters
81
83
82
84
analyzeWithLernieWithOrgInfo ::
83
85
( Has Diagnostics sig m
@@ -89,14 +91,15 @@ analyzeWithLernieWithOrgInfo ::
89
91
) =>
90
92
Path Abs Dir ->
91
93
GrepOptions ->
94
+ Maybe LicenseScanPathFilters ->
92
95
m (Maybe LernieResults )
93
- analyzeWithLernieWithOrgInfo rootDir grepOptions = do
96
+ analyzeWithLernieWithOrgInfo rootDir grepOptions filters = do
94
97
org <- getOrganization
95
98
let orgWideCustomLicenses = orgCustomLicenseScanConfigs org
96
99
uploadKind = orgFileUpload org
97
100
98
101
let options = grepOptions{customLicenseSearch = nub $ orgWideCustomLicenses <> customLicenseSearch grepOptions}
99
- analyzeWithLernieMain rootDir options uploadKind
102
+ analyzeWithLernieMain rootDir options filters uploadKind
100
103
101
104
analyzeWithLernieMain ::
102
105
( Has Diagnostics sig m
@@ -107,10 +110,11 @@ analyzeWithLernieMain ::
107
110
) =>
108
111
Path Abs Dir ->
109
112
GrepOptions ->
113
+ Maybe LicenseScanPathFilters ->
110
114
FileUpload ->
111
115
m (Maybe LernieResults )
112
- analyzeWithLernieMain rootDir grepOptions uploadKind = do
113
- let maybeLernieConfig = grepOptionsToLernieConfig rootDir grepOptions uploadKind
116
+ analyzeWithLernieMain rootDir grepOptions filters uploadKind = do
117
+ let maybeLernieConfig = grepOptionsToLernieConfig rootDir grepOptions filters uploadKind
114
118
case maybeLernieConfig of
115
119
Just lernieConfig -> do
116
120
unless (null $ customLicenseSearch grepOptions) $ trackUsage CustomLicenseSearchUsage
@@ -120,11 +124,11 @@ analyzeWithLernieMain rootDir grepOptions uploadKind = do
120
124
pure $ Just lernieResults
121
125
Nothing -> pure Nothing
122
126
123
- grepOptionsToLernieConfig :: Path Abs Dir -> GrepOptions -> FileUpload -> Maybe LernieConfig
124
- grepOptionsToLernieConfig rootDir grepOptions uploadKind =
127
+ grepOptionsToLernieConfig :: Path Abs Dir -> GrepOptions -> Maybe LicenseScanPathFilters -> FileUpload -> Maybe LernieConfig
128
+ grepOptionsToLernieConfig rootDir grepOptions filters uploadKind =
125
129
case (customLicenseSearches <> keywordSearches) of
126
130
[] -> Nothing
127
- res -> Just . LernieConfig rootDir res $ case uploadKind of
131
+ res -> Just . LernieConfig rootDir res filters $ case uploadKind of
128
132
FileUploadMatchData -> False
129
133
FileUploadFullContent -> True
130
134
where
0 commit comments