From 22c77acb85aa7dffa52d28f7ff84b64b75f5b621 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Apr 2013 20:06:02 -0400 Subject: Detect when the remote is broken like bitbucket is, and exits 0 when it fails to run git-annex-shell. --- Remote/Git.hs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'Remote') diff --git a/Remote/Git.hs b/Remote/Git.hs index 4110c1491..752d70d23 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -136,21 +136,14 @@ guardUsable r onerr a - returns the updated repo. -} tryGitConfigRead :: Git.Repo -> Annex Git.Repo tryGitConfigRead r - | not $ M.null $ Git.config r = return r -- already read + | haveconfig r = return r -- already read | Git.repoIsSsh r = store $ do v <- onRemote r (pipedsshconfig, Left undefined) "configlist" [] [] - case (v, Git.remoteName r) of - (Right r', _) -> return r' - (Left _, Just n) -> do - {- Is this remote just not available, or does - - it not have git-annex-shell? - - Find out by trying to fetch from the remote. -} - whenM (inRepo $ Git.Command.runBool [Param "fetch", Param "--quiet", Param n]) $ do - let k = "remote." ++ n ++ ".annex-ignore" - warning $ "Remote " ++ n ++ " does not have git-annex installed; setting " ++ k - inRepo $ Git.Command.run [Param "config", Param k, Param "true"] - return r - _ -> return r + case v of + Right r' + | haveconfig r' -> return r' + | otherwise -> configlist_failed + Left _ -> configlist_failed | Git.repoIsHttp r = do headers <- getHttpHeaders store $ safely $ geturlconfig headers @@ -159,6 +152,8 @@ tryGitConfigRead r ensureInitialized Annex.getState Annex.repo where + haveconfig = not . M.null . Git.config + -- Reading config can fail due to IO error or -- for other reasons; catch all possible exceptions. safely a = either (const $ return r) return @@ -200,6 +195,18 @@ tryGitConfigRead r | otherwise = old : exchange ls new + {- Is this remote just not available, or does + - it not have git-annex-shell? + - Find out by trying to fetch from the remote. -} + configlist_failed = case Git.remoteName r of + Nothing -> return r + Just n -> do + whenM (inRepo $ Git.Command.runBool [Param "fetch", Param "--quiet", Param n]) $ do + let k = "remote." ++ n ++ ".annex-ignore" + warning $ "Remote " ++ n ++ " does not have git-annex installed; setting " ++ k + inRepo $ Git.Command.run [Param "config", Param k, Param "true"] + return r + {- Checks if a given remote has the content for a key inAnnex. - If the remote cannot be accessed, or if it cannot determine - whether it has the content, returns a Left error message. -- cgit v1.2.3