This commit is contained in:
Dmitry Zuikov 2024-06-14 09:21:44 +03:00
parent 07bc7cacf2
commit fed1845ec8
2 changed files with 20 additions and 2 deletions

View File

@ -729,6 +729,10 @@ runForms ss = for_ ss $ \s -> do
ListVal [SymbolVal "builtin:update-indexes"] -> do ListVal [SymbolVal "builtin:update-indexes"] -> do
updateIndexes updateIndexes
ListVal [SymbolVal "builtin:scan-magic"] -> do
magic <- scanMagic
liftIO $ print $ pretty magic
ListVal [SymbolVal "builtin:select-fixme-hash", FixmeHashLike x] -> do ListVal [SymbolVal "builtin:select-fixme-hash", FixmeHashLike x] -> do
w <- selectFixmeHash x w <- selectFixmeHash x
liftIO $ print $ pretty w liftIO $ print $ pretty w
@ -739,7 +743,6 @@ runForms ss = for_ ss $ \s -> do
Left (fn,h) -> liftIO $ print $ "N" <+> pretty h <+> pretty fn Left (fn,h) -> liftIO $ print $ "N" <+> pretty h <+> pretty fn
Right (fn,h) -> liftIO $ print $ "E" <+> pretty h <+> pretty fn Right (fn,h) -> liftIO $ print $ "E" <+> pretty h <+> pretty fn
ListVal (SymbolVal "builtin:git:extract-file-meta-data" : StringLikeList fs) -> do ListVal (SymbolVal "builtin:git:extract-file-meta-data" : StringLikeList fs) -> do
fxm <- gitExtractFileMetaData fs <&> HM.toList fxm <- gitExtractFileMetaData fs <&> HM.toList
liftIO $ print $ vcat (fmap (pretty.snd) fxm) liftIO $ print $ vcat (fmap (pretty.snd) fxm)

View File

@ -1,5 +1,5 @@
{-# Language MultiWayIf #-} {-# Language MultiWayIf #-}
module Fixme.Scan (scanBlob) where module Fixme.Scan (scanBlob,scanMagic) where
import Fixme.Prelude hiding (indent) import Fixme.Prelude hiding (indent)
import Fixme.Types import Fixme.Types
@ -52,6 +52,21 @@ data FixmeWhat = FixmeHead Int Int Text Text
data P = P0 [FixmePart] | P1 Int Fixme [FixmePart] data P = P0 [FixmePart] | P1 Int Fixme [FixmePart]
scanMagic :: FixmePerks m => FixmeM m HashRef
scanMagic = do
env <- ask
w <- atomically do
tagz <- fixmeEnvTags env & readTVar
co <- fixmeEnvDefComments env & readTVar
fco <- fixmeEnvFileComments env & readTVar
m <- fixmeEnvFileMask env & readTVar
a <- fixmeEnvAttribs env & readTVar
v <- fixmeEnvAttribValues env & readTVar
pure $ serialise (tagz, co, fco, m, a, v)
pure $ HashRef $ hashObject w
scanBlob :: forall m . FixmePerks m scanBlob :: forall m . FixmePerks m
=> Maybe FilePath -- ^ filename to detect type => Maybe FilePath -- ^ filename to detect type
-> ByteString -- ^ content -> ByteString -- ^ content