From cc21a060c44c6af6b68345e5d7a91412df237f13 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 5 Apr 2015 15:02:55 -0400 Subject: expire --no-act --- Command/Expire.hs | 18 ++++++++++++------ doc/git-annex-expire.mdwn | 5 +++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Command/Expire.hs b/Command/Expire.hs index d01d3a965..f4d1a06e3 100644 --- a/Command/Expire.hs +++ b/Command/Expire.hs @@ -21,7 +21,7 @@ import Data.Time.Clock.POSIX import qualified Data.Map as M cmd :: [Command] -cmd = [withOptions [activityOption] $ command "expire" paramExpire seek +cmd = [withOptions [activityOption, noActOption] $ command "expire" paramExpire seek SectionMaintenance "expire inactive repositories"] paramExpire :: String @@ -30,27 +30,33 @@ paramExpire = (paramRepeating $ paramOptional paramRemote ++ ":" ++ paramTime) activityOption :: Option activityOption = fieldOption [] "activity" "Name" "specify activity" +noActOption :: Option +noActOption = flagOption [] "no-act" "don't really do anything" + seek :: CommandSeek seek ps = do expire <- parseExpire ps wantact <- getOptionField activityOption (pure . parseActivity) + noact <- getOptionFlag noActOption actlog <- lastActivities wantact u <- getUUID us <- filter (/= u) . M.keys <$> uuidMap descs <- uuidMap - seekActions $ pure $ map (start expire actlog descs) us + seekActions $ pure $ map (start expire noact actlog descs) us -start :: Expire -> Log Activity -> M.Map UUID String -> UUID -> CommandStart -start (Expire expire) actlog descs u = +start :: Expire -> Bool -> Log Activity -> M.Map UUID String -> UUID -> CommandStart +start (Expire expire) noact actlog descs u = case lastact of Just ent | notexpired ent -> checktrust (== DeadTrusted) $ do showStart "unexpire" desc showNote =<< whenactive - trustSet u SemiTrusted + unless noact $ + trustSet u SemiTrusted _ -> checktrust (/= DeadTrusted) $ do showStart "expire" desc showNote =<< whenactive - trustSet u DeadTrusted + unless noact $ + trustSet u DeadTrusted where lastact = changed <$> M.lookup u actlog whenactive = case lastact of diff --git a/doc/git-annex-expire.mdwn b/doc/git-annex-expire.mdwn index ff167804a..ce07d7976 100644 --- a/doc/git-annex-expire.mdwn +++ b/doc/git-annex-expire.mdwn @@ -30,6 +30,11 @@ expired. # OPTIONS +* `--no-act` + + Print out what would be done, but not not actually expite or unexpire + any repositories. + * `--activity=Name` Specify the activity that a repository must have performed to avoid being -- cgit v1.2.3