From 826075786b2ddb58190c27294cdb70cbf19f5b25 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 10 Sep 2026 16:59:16 +0200 Subject: prevent git from triggering over itself --- Main.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Main.hs b/Main.hs index 6b966b2..73acb57 100644 --- a/Main.hs +++ b/Main.hs @@ -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 -- cgit v1.2.3