Detect when the remote is broken like bitbucket is, and exits 0 when it fails to run git-annex-shell.

This commit is contained in:
Joey Hess 2013-04-23 20:06:02 -04:00
parent 74712c20f1
commit 4b1cf3d731
3 changed files with 24 additions and 13 deletions

View file

@ -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.

2
debian/changelog vendored
View file

@ -23,6 +23,8 @@ git-annex (4.20130418) UNRELEASED; urgency=low
* rmurl: New command, removes one of the recorded urls for a file.
* sync: Bug fix, avoid adding to the annex the
dummy symlinks used on crippled filesystems.
* Detect when the remote is broken like bitbucket is, and exits 0 when
it fails to run git-annex-shell.
-- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400

View file

@ -204,3 +204,5 @@ Here is the contents of .git/config (the last line was added by git annex sync)
fetch = +refs/heads/*:refs/remotes/aaatos/*
annex-ignore = true
"""]]
> Reproduced and fixed. [[done]] --[[Joey]]