diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2026-09-23 15:27:25 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2026-09-23 15:27:25 +0200 |
| commit | 74b5b6ef1bcdbba0baf01530f44b4ca8df655b9f (patch) | |
| tree | 8a0fd19d4fd9aee111ad2b971a0eceeaa6a03bc3 /Main.hs | |
| parent | bd78cd3842f6ac2fcd7516019729af0e78b1a563 (diff) | |
| parent | 6b26897a92b43dc065c3611f3cce84aa95287eaf (diff) | |
| download | git-auto-acp-74b5b6ef1bcdbba0baf01530f44b4ca8df655b9f.tar.gz git-auto-acp-74b5b6ef1bcdbba0baf01530f44b4ca8df655b9f.tar.bz2 | |
Merge branch 'mk-update'
Diffstat (limited to 'Main.hs')
| -rw-r--r-- | Main.hs | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -61,9 +61,22 @@ import System.IO (hPutStrLn, stderr) import System.Posix.Signals (Handler(Catch), installHandler, sigINT) import System.Process (rawSystem) +data WatchType + = UpdateOnly + | Add + | AddAndRemove + deriving (Show, Eq, Ord) + +watchGitOption :: WatchType -> String +watchGitOption x = + case x of + UpdateOnly -> "--update" + Add -> "--ignore-removal" + AddAndRemove -> "--no-ignore-removal" + data Watch = Watch { watchPath :: FilePath - , watchWithRemoval :: Bool + , watchWithRemoval :: WatchType } deriving (Show, Eq, Ord) data Opts = Opts @@ -101,13 +114,19 @@ opts = do optWatches <- some $ asum - [ fmap (`Watch` False) . strOption + [ fmap (`Watch` UpdateOnly) . strOption + ~~ [ short 'u' + , long "update" + , metavar "PATH" + , help "like `--add' but does not add new files" + ] + , fmap (`Watch` Add) . strOption ~~ [ short 'a' , long "add" , metavar "PATH" , help "paths to auto-add" ] - , fmap (`Watch` True) . strOption + , fmap (`Watch` AddAndRemove) . strOption ~~ [ short 'A' , long "add-all" , metavar "PATH" @@ -228,11 +247,9 @@ mainLoop git dbg chan done o = loop | not (S.null stWatch) , stAddsPending == 1 {- protection against triggering too early -} || intervalPassed (optAddCommitDelay o) now stLastAdd = do - for_ stWatch $ \w@(Watch p addAll) -> do + for_ stWatch $ \w@(Watch p wtype) -> do dbg $ "will add: " ++ show w - if addAll - then runCmd git ["add", p] - else runCmd git ["add", "--ignore-removal", p] + runCmd git ["add", watchGitOption wtype, p] dbg "commit!" runCmd git ["commit", "--message", mkMsg stCommitSeries $ optMsg o] loop |
