diff --git a/CHANGELOG b/CHANGELOG index 0c31e7fd8b..c9f7c20f9d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ git-annex (8.20200909) UNRELEASED; urgency=medium * add, addurl, importfeed, import: Added --no-check-gitignore option for finer grained control than using --force. * addunused: Don't check .gitignores when adding files. + * Improve the "Try making some of these repositories available" + message, with some hints for the user for what to do. -- Joey Hess Mon, 14 Sep 2020 18:34:37 -0400 diff --git a/Messages.hs b/Messages.hs index 07b152c24a..d3e63458ad 100644 --- a/Messages.hs +++ b/Messages.hs @@ -45,6 +45,7 @@ module Messages ( disableDebugOutput, debugEnabled, commandProgressDisabled, + jsonOutputEnabled, outputMessage, withMessageState, prompt, @@ -288,6 +289,12 @@ commandProgressDisabled = withMessageState $ \s -> return $ JSONOutput _ -> True NormalOutput -> concurrentOutputEnabled s +jsonOutputEnabled :: Annex Bool +jsonOutputEnabled = withMessageState $ \s -> return $ + case outputType s of + JSONOutput _ -> True + _ -> False + {- Prevents any concurrent console access while running an action, so - that the action is the only thing using the console, and can eg prompt - the user. diff --git a/Remote.hs b/Remote.hs index b343fac47b..1989f9382c 100644 --- a/Remote.hs +++ b/Remote.hs @@ -1,6 +1,6 @@ {- git-annex remotes - - - Copyright 2011-2019 Joey Hess + - Copyright 2011-2020 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -73,6 +73,7 @@ import Annex.UUID import Logs.UUID import Logs.Trust import Logs.Location hiding (logStatus) +import Logs.Remote import Logs.Web import Remote.List import Remote.List.Util @@ -337,31 +338,53 @@ remoteLocations locations trusted = do return (sortBy (comparing cost) validremotes, validtrustedlocations) -{- Displays known locations of a key. -} +{- Displays known locations of a key and helps the user take action + - to make them accessible. -} showLocations :: Bool -> Key -> [UUID] -> String -> Annex () showLocations separateuntrusted key exclude nolocmsg = do u <- getUUID + remotes <- remoteList uuids <- keyLocations key untrusteduuids <- if separateuntrusted then trustGet UnTrusted else pure [] - let uuidswanted = filteruuids uuids (u:exclude++untrusteduuids) + let uuidswanted = filteruuids uuids (u:exclude++untrusteduuids) let uuidsskipped = filteruuids uuids (u:exclude++uuidswanted) - ppuuidswanted <- prettyPrintUUIDs "wanted" uuidswanted - ppuuidsskipped <- prettyPrintUUIDs "skipped" uuidsskipped - let msg = message ppuuidswanted ppuuidsskipped - unless (null msg) $ - showLongNote msg - ignored <- remoteList - >>= filterM (liftIO . getDynamicConfig . remoteAnnexIgnore . gitconfig) + let remoteuuids = map uuid remotes + let isremoteuuid x = elem x remoteuuids + let (remotesmakeavailable, uuidsothers) = + partition isremoteuuid uuidswanted + isspecialremote <- flip M.member <$> remoteConfigMap + let (enablespecialremotes, addgitremotes) = + partition isspecialremote uuidsothers + + -- Add "wanted" field to the JSON. While it's since been split + -- up more, this avoids breaking any JSON parsers that expect it. + ifM jsonOutputEnabled + ( void $ prettyPrintUUIDs "wanted" uuidswanted + , do + ppremotesmakeavailable <- pp "remotes" remotesmakeavailable + "Try making some of these remotes available" + ppenablespecialremotes <- pp "enableremote" enablespecialremotes + "Maybe enable some of these special remotes (git annex initremote ...)" + ppaddgitremotes <- pp "repos" addgitremotes + "Maybe add some of these git remotes (git remote add ...)" + ppuuidsskipped <- pp "skipped" uuidsskipped + "Also these untrusted repositories may contain the file" + showLongNote $ case ppremotesmakeavailable ++ ppenablespecialremotes ++ ppaddgitremotes ++ ppuuidsskipped of + [] -> nolocmsg + s -> s + ) + ignored <- filterM (liftIO . getDynamicConfig . remoteAnnexIgnore . gitconfig) remotes unless (null ignored) $ showLongNote $ "(Note that these git remotes have annex-ignore set: " ++ unwords (map name ignored) ++ ")" where filteruuids l x = filter (`notElem` x) l - message [] [] = nolocmsg - message rs [] = "Try making some of these repositories available:\n" ++ rs - message [] us = "Also these untrusted repositories may contain the file:\n" ++ us - message rs us = message rs [] ++ message [] us + + pp jh l h = addheader h <$> prettyPrintUUIDs jh l + + addheader _ [] = [] + addheader h l = h ++ ":\n" ++ l showTriedRemotes :: [Remote] -> Annex () showTriedRemotes [] = noop diff --git a/doc/todo/make___34____Try_making_some_of_these_repositories_available__34___more_informative.mdwn b/doc/todo/make___34____Try_making_some_of_these_repositories_available__34___more_informative.mdwn index b92e91b160..2978049ab1 100644 --- a/doc/todo/make___34____Try_making_some_of_these_repositories_available__34___more_informative.mdwn +++ b/doc/todo/make___34____Try_making_some_of_these_repositories_available__34___more_informative.mdwn @@ -29,5 +29,5 @@ although those remote descriptions/names give an idea for an informed user, they """]] [[!meta author=yoh]] -[[!tag projects/dandi]] -[[!tag needsthought]] + +> implemented as shown. [[done]] --[[Joey]]