mirror of
https://github.com/NorfairKing/feedback.git
synced 2024-11-27 00:47:13 +03:00
Configurable gitignore filter
This commit is contained in:
parent
7a5ad699bd
commit
6ee86853f8
@ -44,7 +44,7 @@ See `feedback-test --help` for more details.
|
|||||||
|----|-|-|-|-|
|
|----|-|-|-|-|
|
||||||
| Indication of command starting | ✔️ | ✔️ | C | C |
|
| Indication of command starting | ✔️ | ✔️ | C | C |
|
||||||
| Indication of time | ✔️ | C | C | C |
|
| Indication of time | ✔️ | C | C | C |
|
||||||
| Clear screen between feedback | ✔️ | C | C | ✔️ |
|
| Clear screen between feedback | ✔️ | C | C | C |
|
||||||
| Gitignore-aware | ✔️ | ✖️ | ✔️ | ✖ |
|
| Gitignore-aware | ✔️ | ✖️ | ✔️ | ✖ |
|
||||||
| Named feedback loops | ✔️ | ✖️ | ✖ | ✖ |
|
| Named feedback loops | ✔️ | ✖️ | ✖ | ✖ |
|
||||||
| Configurable feedback loops | ✔️ | ✔️ | ✖ | ✖ |
|
| Configurable feedback loops | ✔️ | ✔️ | ✖ | ✖ |
|
||||||
|
@ -27,11 +27,30 @@ import Path.IO
|
|||||||
import Paths_feedback
|
import Paths_feedback
|
||||||
|
|
||||||
data LoopSettings = LoopSettings
|
data LoopSettings = LoopSettings
|
||||||
{ loopSettingRunSettings :: !RunSettings,
|
{ loopSettingFilterSettings :: !FilterSettings,
|
||||||
|
loopSettingRunSettings :: !RunSettings,
|
||||||
loopSettingOutputSettings :: !OutputSettings
|
loopSettingOutputSettings :: !OutputSettings
|
||||||
}
|
}
|
||||||
deriving (Show, Eq, Generic)
|
deriving (Show, Eq, Generic)
|
||||||
|
|
||||||
|
combineToLoopSettings :: Flags -> Environment -> Maybe OutputConfiguration -> LoopConfiguration -> IO LoopSettings
|
||||||
|
combineToLoopSettings Flags {..} Environment {} mDefaultOutputConfig LoopConfiguration {..} = do
|
||||||
|
let filterSettingGitingore = fromMaybe True loopConfigGitignore
|
||||||
|
let loopSettingFilterSettings = FilterSettings {..}
|
||||||
|
let runSettingCommand = loopConfigCommand
|
||||||
|
let runSettingExtraEnv = loopConfigExtraEnv
|
||||||
|
runSettingWorkingDir <- mapM resolveDir' loopConfigWorkingDir
|
||||||
|
|
||||||
|
let loopSettingRunSettings = RunSettings {..}
|
||||||
|
let outputConfig = liftA2 (<>) loopConfigOutputConfiguration mDefaultOutputConfig
|
||||||
|
let loopSettingOutputSettings = combineToOutputSettings flagOutputFlags outputConfig
|
||||||
|
pure LoopSettings {..}
|
||||||
|
|
||||||
|
data FilterSettings = FilterSettings
|
||||||
|
{ filterSettingGitingore :: !Bool
|
||||||
|
}
|
||||||
|
deriving (Show, Eq, Generic)
|
||||||
|
|
||||||
data RunSettings = RunSettings
|
data RunSettings = RunSettings
|
||||||
{ runSettingCommand :: !Command,
|
{ runSettingCommand :: !Command,
|
||||||
runSettingExtraEnv :: !(Map String String),
|
runSettingExtraEnv :: !(Map String String),
|
||||||
@ -39,17 +58,6 @@ data RunSettings = RunSettings
|
|||||||
}
|
}
|
||||||
deriving (Show, Eq, Generic)
|
deriving (Show, Eq, Generic)
|
||||||
|
|
||||||
combineToLoopSettings :: Flags -> Environment -> Maybe OutputConfiguration -> LoopConfiguration -> IO LoopSettings
|
|
||||||
combineToLoopSettings Flags {..} Environment {} mDefaultOutputConfig LoopConfiguration {..} = do
|
|
||||||
let runSettingCommand = loopConfigCommand
|
|
||||||
let runSettingExtraEnv = loopConfigExtraEnv
|
|
||||||
runSettingWorkingDir <- mapM resolveDir' loopConfigWorkingDir
|
|
||||||
|
|
||||||
let loopSettingRunSettings = RunSettings {..}
|
|
||||||
let outputConfig = liftA2 (<>) loopConfigOutputConfiguration mDefaultOutputConfig
|
|
||||||
let loopSettingOutputSettings = combineToOutputSettings flagOutputFlags outputConfig
|
|
||||||
pure LoopSettings {..}
|
|
||||||
|
|
||||||
data OutputSettings = OutputSettings
|
data OutputSettings = OutputSettings
|
||||||
{ outputSettingClear :: !Clear
|
{ outputSettingClear :: !Clear
|
||||||
}
|
}
|
||||||
@ -76,6 +84,7 @@ instance HasCodec Configuration where
|
|||||||
|
|
||||||
data LoopConfiguration = LoopConfiguration
|
data LoopConfiguration = LoopConfiguration
|
||||||
{ loopConfigCommand :: !Command,
|
{ loopConfigCommand :: !Command,
|
||||||
|
loopConfigGitignore :: !(Maybe Bool),
|
||||||
loopConfigExtraEnv :: !(Map String String),
|
loopConfigExtraEnv :: !(Map String String),
|
||||||
loopConfigWorkingDir :: !(Maybe FilePath),
|
loopConfigWorkingDir :: !(Maybe FilePath),
|
||||||
loopConfigOutputConfiguration :: !(Maybe OutputConfiguration)
|
loopConfigOutputConfiguration :: !(Maybe OutputConfiguration)
|
||||||
@ -91,6 +100,7 @@ instance HasCodec LoopConfiguration where
|
|||||||
object "LoopConfiguration" $
|
object "LoopConfiguration" $
|
||||||
LoopConfiguration
|
LoopConfiguration
|
||||||
<$> commandObjectCodec .= loopConfigCommand
|
<$> commandObjectCodec .= loopConfigCommand
|
||||||
|
<*> optionalField "gitignore" "whether to ignore files that are not in the git repo" .= loopConfigGitignore
|
||||||
<*> optionalFieldWithOmittedDefault "env" M.empty "extra environment variables to set" .= loopConfigExtraEnv
|
<*> optionalFieldWithOmittedDefault "env" M.empty "extra environment variables to set" .= loopConfigExtraEnv
|
||||||
<*> optionalField "working-dir" "where the process will be run" .= loopConfigWorkingDir
|
<*> optionalField "working-dir" "where the process will be run" .= loopConfigWorkingDir
|
||||||
<*> optionalField "output" "output configuration for this loop" .= loopConfigOutputConfiguration
|
<*> optionalField "output" "output configuration for this loop" .= loopConfigOutputConfiguration
|
||||||
@ -108,6 +118,7 @@ makeLoopConfiguration :: Command -> LoopConfiguration
|
|||||||
makeLoopConfiguration c =
|
makeLoopConfiguration c =
|
||||||
LoopConfiguration
|
LoopConfiguration
|
||||||
{ loopConfigCommand = c,
|
{ loopConfigCommand = c,
|
||||||
|
loopConfigGitignore = Nothing,
|
||||||
loopConfigExtraEnv = M.empty,
|
loopConfigExtraEnv = M.empty,
|
||||||
loopConfigWorkingDir = Nothing,
|
loopConfigWorkingDir = Nothing,
|
||||||
loopConfigOutputConfiguration = Nothing
|
loopConfigOutputConfiguration = Nothing
|
||||||
|
@ -41,7 +41,7 @@ runFeedbackLoop =
|
|||||||
-- 0.1 second debouncing, 0.001 was too little
|
-- 0.1 second debouncing, 0.001 was too little
|
||||||
let conf = FS.defaultConfig {confDebounce = Debounce 0.1}
|
let conf = FS.defaultConfig {confDebounce = Debounce 0.1}
|
||||||
FS.withManagerConf conf $ \watchManager -> do
|
FS.withManagerConf conf $ \watchManager -> do
|
||||||
eventFilter <- mkEventFilter here
|
eventFilter <- mkEventFilter here loopSettingFilterSettings
|
||||||
stopListeningAction <-
|
stopListeningAction <-
|
||||||
FS.watchTree
|
FS.watchTree
|
||||||
watchManager
|
watchManager
|
||||||
@ -54,9 +54,9 @@ runFeedbackLoop =
|
|||||||
(outputWorker loopSettingOutputSettings outputChan)
|
(outputWorker loopSettingOutputSettings outputChan)
|
||||||
stopListeningAction
|
stopListeningAction
|
||||||
|
|
||||||
mkEventFilter :: Path Abs Dir -> IO (FS.Event -> Bool)
|
mkEventFilter :: Path Abs Dir -> FilterSettings -> IO (FS.Event -> Bool)
|
||||||
mkEventFilter here = do
|
mkEventFilter here FilterSettings {..} = do
|
||||||
mGitFiles <- gitLsFiles here
|
mGitFiles <- if filterSettingGitingore then gitLsFiles here else pure Nothing
|
||||||
pure $ \event ->
|
pure $ \event ->
|
||||||
standardEventFilter here event
|
standardEventFilter here event
|
||||||
&& maybe True (eventPath event `S.member`) mGitFiles
|
&& maybe True (eventPath event `S.member`) mGitFiles
|
||||||
|
Loading…
Reference in New Issue
Block a user