info: Added --dead-repositories option

I considered a more wide-ranging config option to make other commands
also show dead repositories. But it would be difficult to implement that
because Remote.keyLocations is used to get locations, filtering out dead
repos, and commands like get then try to use those locations. So a config
setting would make dead repos sometimes be acted on by commands.

Sponsored-by: unqueued on Patreon
This commit is contained in:
Joey Hess 2023-08-09 12:43:48 -04:00
parent 27a9915a67
commit 3efad7f5f4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 23 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command
-
- Copyright 2011-2022 Joey Hess <id@joeyh.name>
- Copyright 2011-2023 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -109,6 +109,7 @@ data InfoOptions = InfoOptions
, bytesOption :: Bool
, batchOption :: BatchMode
, autoenableOption :: Bool
, deadrepositoriesOption :: Bool
}
optParser :: CmdParamsDesc -> Parser InfoOptions
@ -123,6 +124,10 @@ optParser desc = InfoOptions
( long "autoenable"
<> help "list special remotes that are configured to autoenable"
)
<*> switch
( long "dead-repositories"
<> help "list repositories that have been marked as dead"
)
seek :: InfoOptions -> CommandSeek
seek o = case batchOption o of
@ -134,7 +139,9 @@ start :: InfoOptions -> [String] -> CommandStart
start o [] = do
if autoenableOption o
then autoenableInfo
else globalInfo o
else if deadrepositoriesOption o
then deadrepositoriesInfo o
else globalInfo o
stop
start o ps = do
mapM_ (\p -> itemInfo o (SeekInput [p], p)) ps
@ -163,6 +170,11 @@ autoenableInfo = showCustom "info" (SeekInput []) $ do
showRaw (encodeBS s)
return True
deadrepositoriesInfo :: InfoOptions -> Annex ()
deadrepositoriesInfo o = showCustom "info" (SeekInput []) $ do
evalStateT (showStat (repo_list DeadTrusted)) (emptyStatInfo o)
return True
itemInfo :: InfoOptions -> (SeekInput, String) -> Annex ()
itemInfo o (si, p) = ifM (isdir (toRawFilePath p))
( dirInfo o p si