diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2026-09-23 15:23:05 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2026-09-23 15:23:05 +0200 |
| commit | 6b26897a92b43dc065c3611f3cce84aa95287eaf (patch) | |
| tree | 9aac751fce1bebf12d6fcc687f5ba95f67c11d54 | |
| parent | 48d42ef2e5f6c615725ee3b6017a5ceef68ca13e (diff) | |
| download | git-auto-acp-6b26897a92b43dc065c3611f3cce84aa95287eaf.tar.gz git-auto-acp-6b26897a92b43dc065c3611f3cce84aa95287eaf.tar.bz2 | |
allow update-only adds
| -rw-r--r-- | Main.hs | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -22,9 +22,22 @@ import System.IO import System.Posix.Signals import System.Process +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 @@ -58,12 +71,17 @@ 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" @@ -173,11 +191,9 @@ main = do | not (S.null stWatch) , stAddsPending == 1 || 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 |
