avoid running pre-commit hook from watch commits

This commit is contained in:
Joey Hess 2012-06-10 17:53:17 -04:00
parent cda6c4dff5
commit fc0dd79774

View file

@ -197,26 +197,28 @@ refillChanges chan cs = atomically $ mapM_ (writeTChan chan) cs
commitThread :: MVar Annex.AnnexState -> ChangeChan -> IO () commitThread :: MVar Annex.AnnexState -> ChangeChan -> IO ()
commitThread st changechan = forever $ do commitThread st changechan = forever $ do
-- First, a simple rate limiter. -- First, a simple rate limiter.
threadDelay $ oneSecond threadDelay oneSecond
liftIO $ putStrLn "running"
-- Next, wait until at least one change has been made. -- Next, wait until at least one change has been made.
cs <- getChanges changechan cs <- getChanges changechan
-- Now see if now's a good time to commit. -- Now see if now's a good time to commit.
ifM (shouldCommit <$> getCurrentTime <*> pure cs) $ time <- getCurrentTime
( commit if shouldCommit time cs
, do then commit
liftIO $ putStrLn $ "no commit now " ++ show (length cs) else refillChanges changechan cs
refillChanges changechan cs
)
where where
commit = void $ tryIO $ runStateMVar st $ do commit = void $ tryIO $ runStateMVar st $ do
Annex.Queue.flush Annex.Queue.flush
{- Empty commits may be made if tree
- changes cancel each other out, etc. -}
inRepo $ Git.Command.run "commit" inRepo $ Git.Command.run "commit"
[ Param "--allow-empty-message" [ Param "--allow-empty-message"
, Param "-m", Param "" , Param "-m", Param ""
-- Empty commits may be made if tree
-- changes cancel each other out, etc
, Param "--allow-empty" , Param "--allow-empty"
-- Avoid running the usual git-annex
-- pre-commit hook; watch does the same
-- symlink fixing, and we don't want to
-- deal with unlocked files in these
-- commits.
, Param "--quiet" , Param "--quiet"
] ]
oneSecond = 1000000 -- microseconds oneSecond = 1000000 -- microseconds