diff options
author | 2011-03-30 14:00:54 -0400 | |
---|---|---|
committer | 2011-03-30 14:00:54 -0400 | |
commit | 619f07ee6a0ad875f365886096b112b6c18b0606 (patch) | |
tree | 4b2de6c0657b6d46fff477982d3bc78c2c8ccc4c /Remote/Git.hs | |
parent | a47ed922e1302480d79f54f553532e85eebae872 (diff) |
boilerplate reduction
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r-- | Remote/Git.hs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index d0dedd4fd..286a8c645 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -42,33 +42,27 @@ list = do g <- Annex.gitRepo return $ Git.remotes g -gen :: Git.Repo -> Maybe (M.Map String String) -> Annex (Remote Annex) -gen repo _ = do +gen :: Git.Repo -> UUID -> Cost -> Maybe (M.Map String String) -> Annex (Remote Annex) +gen r u cst _ = do {- It's assumed to be cheap to read the config of non-URL remotes, - so this is done each time git-annex is run. Conversely, - the config of an URL remote is only read when there is no - cached UUID value. -} - let cheap = not $ Git.repoIsUrl repo - u <- getUUID repo - repo' <- case (cheap, u) of - (True, _) -> tryGitConfigRead repo - (False, "") -> tryGitConfigRead repo - _ -> return repo - genRemote repo' - -genRemote :: Git.Repo -> Annex (Remote Annex) -genRemote r = do - u <- getUUID r - c <- remoteCost r + let cheap = not $ Git.repoIsUrl r + r' <- case (cheap, u) of + (True, _) -> tryGitConfigRead r + (False, "") -> tryGitConfigRead r + _ -> return r + return $ Remote { uuid = u, - cost = c, - name = Git.repoDescribe r, - storeKey = copyToRemote r, - retrieveKeyFile = copyFromRemote r, - removeKey = dropKey r, - hasKey = inAnnex r, - hasKeyCheap = not (Git.repoIsUrl r), + cost = cst, + name = Git.repoDescribe r', + storeKey = copyToRemote r', + retrieveKeyFile = copyFromRemote r', + removeKey = dropKey r', + hasKey = inAnnex r', + hasKeyCheap = not (Git.repoIsUrl r'), config = Nothing } |