diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2026-09-10 16:59:16 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2026-09-10 17:03:25 +0200 |
| commit | 826075786b2ddb58190c27294cdb70cbf19f5b25 (patch) | |
| tree | 150626725ffef79ebd5b20a37329f2fbecf7675e /Main.hs | |
| parent | a4826233e7eb9c6bf55994172acf284605f47fa7 (diff) | |
| download | git-auto-acp-826075786b2ddb58190c27294cdb70cbf19f5b25.tar.gz git-auto-acp-826075786b2ddb58190c27294cdb70cbf19f5b25.tar.bz2 | |
prevent git from triggering over itself
Diffstat (limited to 'Main.hs')
| -rw-r--r-- | Main.hs | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -16,8 +16,10 @@ import qualified Data.Set as S import Options.Applicative import System.Clock import System.Environment +import System.FilePath import System.Exit import System.FSNotify +import System.FSNotify.Devel import System.IO import System.Process @@ -108,28 +110,31 @@ main = do <> (footer "This program is free software; see LICENSE file for details.")) git <- fromMaybe "git" <$> lookupEnv "AUTO_ACP_GIT" + gitDir <- fromMaybe ".git" <$> lookupEnv "AUTO_ACP_GIT_DIRNAME" withManager $ \fsmgr -> do chan <- newChan done <- newEmptyMVar -- TODO catch sigterm -- start some watchers for_ (optWatches o) $ \w@(Watch path _) -> - watchTree fsmgr path (const True) . const $ writeChan chan (Change w) + watchTree fsmgr path (allEvents $ elem gitDir . splitPath) . const + $ writeChan chan (Change w) -- start the event crunching thread - forkIO - $ let loop ws lastAdd addsPending lastPush pushesPending = do + void . forkIO + $ let loop :: S.Set Watch -> TimeSpec -> Int -> TimeSpec -> Int -> IO () + loop ws lastAdd addsPending lastPush pushesPending = do ev <- readChan chan now <- getTime Monotonic case ev of Finished -> pure () Change w -> do - forkIO + void . forkIO $ delaySec (optAddCommitDelay o) >> writeChan chan AddBounce let ws' = S.insert w ws case optPushDelay o of Nothing -> loop ws' lastAdd (succ addsPending) lastPush pushesPending Just pd -> do - forkIO $ delaySec pd >> writeChan chan PushBounce + void . forkIO $ delaySec pd >> writeChan chan PushBounce loop ws' lastAdd |
