@@ -14,7 +14,7 @@ module Semantic.Task.Files
14
14
, Handle (.. )
15
15
, FilesC (.. )
16
16
, FilesArg (.. )
17
- , Excludes (.. )
17
+ , PathFilter (.. )
18
18
) where
19
19
20
20
import Control.Effect.Carrier
@@ -36,15 +36,17 @@ data Source blob where
36
36
FromPath :: File -> Source Blob
37
37
FromHandle :: Handle 'IO.ReadMode -> Source [Blob ]
38
38
FromDir :: FilePath -> Source [Blob ]
39
- FromGitRepo :: FilePath -> Git. OID -> Excludes -> Source [Blob ]
39
+ FromGitRepo :: FilePath -> Git. OID -> PathFilter -> Source [Blob ]
40
40
FromPathPair :: Both File -> Source BlobPair
41
41
FromPairHandle :: Handle 'IO.ReadMode -> Source [BlobPair ]
42
42
43
43
data Destination = ToPath FilePath | ToHandle (Handle 'IO.WriteMode )
44
44
45
- data Excludes
45
+ data PathFilter
46
46
= ExcludePaths [FilePath ]
47
47
| ExcludeFromHandle (Handle 'IO.ReadMode )
48
+ | IncludePaths [FilePath ]
49
+ | IncludePathsFromHandle (Handle 'IO.ReadMode )
48
50
49
51
-- | An effect to read/write 'Blob's from 'Handle's or 'FilePath's.
50
52
data Files (m :: * -> * ) k
@@ -80,8 +82,10 @@ instance (Member (Error SomeException) sig, Member Catch sig, MonadIO m, Carrier
80
82
Read (FromPath path) k -> rethrowing (readBlobFromFile' path) >>= k
81
83
Read (FromHandle handle) k -> rethrowing (readBlobsFromHandle handle) >>= k
82
84
Read (FromDir dir) k -> rethrowing (readBlobsFromDir dir) >>= k
83
- Read (FromGitRepo path sha (ExcludePaths excludePaths)) k -> rethrowing (readBlobsFromGitRepo path sha excludePaths) >>= k
84
- Read (FromGitRepo path sha (ExcludeFromHandle handle)) k -> rethrowing (readPathsFromHandle handle >>= readBlobsFromGitRepo path sha) >>= k
85
+ Read (FromGitRepo path sha (ExcludePaths excludePaths)) k -> rethrowing (readBlobsFromGitRepo path sha excludePaths mempty ) >>= k
86
+ Read (FromGitRepo path sha (ExcludeFromHandle handle)) k -> rethrowing (readPathsFromHandle handle >>= (\ x -> readBlobsFromGitRepo path sha x mempty )) >>= k
87
+ Read (FromGitRepo path sha (IncludePaths includePaths)) k -> rethrowing (readBlobsFromGitRepo path sha mempty includePaths) >>= k
88
+ Read (FromGitRepo path sha (IncludePathsFromHandle h)) k -> rethrowing (readPathsFromHandle h >>= readBlobsFromGitRepo path sha mempty ) >>= k
85
89
Read (FromPathPair paths) k -> rethrowing (runBothWith readFilePair paths) >>= k
86
90
Read (FromPairHandle handle) k -> rethrowing (readBlobPairsFromHandle handle) >>= k
87
91
ReadProject rootDir dir language excludeDirs k -> rethrowing (readProjectFromPaths rootDir dir language excludeDirs) >>= k
@@ -96,7 +100,7 @@ readBlob file = send (Read (FromPath file) pure)
96
100
data FilesArg
97
101
= FilesFromHandle (Handle 'IO.ReadMode )
98
102
| FilesFromPaths [File ]
99
- | FilesFromGitRepo FilePath Git. OID Excludes
103
+ | FilesFromGitRepo FilePath Git. OID PathFilter
100
104
101
105
-- | A task which reads a list of 'Blob's from a 'Handle' or a list of 'FilePath's optionally paired with 'Language's.
102
106
readBlobs :: (Member Files sig , Carrier sig m , MonadIO m ) => FilesArg -> m [Blob ]
@@ -107,7 +111,7 @@ readBlobs (FilesFromPaths [path]) = do
107
111
then send (Read (FromDir (filePath path)) pure )
108
112
else pure <$> send (Read (FromPath path) pure )
109
113
readBlobs (FilesFromPaths paths) = traverse (send . flip Read pure . FromPath ) paths
110
- readBlobs (FilesFromGitRepo path sha excludes ) = send (Read (FromGitRepo path sha excludes ) pure )
114
+ readBlobs (FilesFromGitRepo path sha filter ) = send (Read (FromGitRepo path sha filter ) pure )
111
115
112
116
-- | A task which reads a list of pairs of 'Blob's from a 'Handle' or a list of pairs of 'FilePath's optionally paired with 'Language's.
113
117
readBlobPairs :: (Member Files sig , Carrier sig m ) => Either (Handle 'IO.ReadMode ) [Both File ] -> m [BlobPair ]
0 commit comments