support reading git config from http remotes
The config file is downloaded to a temp file, and git-config run on that to parse it.
This commit is contained in:
parent
5000aba76e
commit
07f2e7ee72
1 changed files with 15 additions and 1 deletions
|
@ -12,6 +12,7 @@ import Control.Monad.State (liftIO)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import System.Cmd.Utils
|
import System.Cmd.Utils
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
|
import System.IO
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
|
@ -24,7 +25,8 @@ import qualified Content
|
||||||
import Messages
|
import Messages
|
||||||
import Utility.CopyFile
|
import Utility.CopyFile
|
||||||
import Utility.RsyncFile
|
import Utility.RsyncFile
|
||||||
import Remote.Ssh
|
import Remote.Helper.Ssh
|
||||||
|
import qualified Remote.Helper.Url as Url
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
remote :: RemoteType Annex
|
remote :: RemoteType Annex
|
||||||
|
@ -75,6 +77,7 @@ tryGitConfigRead :: Git.Repo -> Annex Git.Repo
|
||||||
tryGitConfigRead r
|
tryGitConfigRead r
|
||||||
| not $ M.null $ Git.configMap r = return r -- already read
|
| not $ M.null $ Git.configMap r = return r -- already read
|
||||||
| Git.repoIsSsh r = store $ onRemote r (pipedconfig, r) "configlist" []
|
| Git.repoIsSsh r = store $ onRemote r (pipedconfig, r) "configlist" []
|
||||||
|
| Git.repoIsHttp r = store $ safely $ geturlconfig
|
||||||
| Git.repoIsUrl r = return r
|
| Git.repoIsUrl r = return r
|
||||||
| otherwise = store $ safely $ Git.configRead r
|
| otherwise = store $ safely $ Git.configRead r
|
||||||
where
|
where
|
||||||
|
@ -85,9 +88,19 @@ tryGitConfigRead r
|
||||||
case result of
|
case result of
|
||||||
Left _ -> return r
|
Left _ -> return r
|
||||||
Right r' -> return r'
|
Right r' -> return r'
|
||||||
|
|
||||||
pipedconfig cmd params = safely $
|
pipedconfig cmd params = safely $
|
||||||
pOpen ReadFromPipe cmd (toCommand params) $
|
pOpen ReadFromPipe cmd (toCommand params) $
|
||||||
Git.hConfigRead r
|
Git.hConfigRead r
|
||||||
|
|
||||||
|
geturlconfig = do
|
||||||
|
s <- Url.get (Git.repoLocation r ++ "/config")
|
||||||
|
withTempFile "git-annex.tmp" $ \tmpfile -> \h -> do
|
||||||
|
hPutStr h s
|
||||||
|
hClose h
|
||||||
|
pOpen ReadFromPipe "git" ["config", "--list", "--file", tmpfile] $
|
||||||
|
Git.hConfigRead r
|
||||||
|
|
||||||
store a = do
|
store a = do
|
||||||
r' <- a
|
r' <- a
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
|
@ -95,6 +108,7 @@ tryGitConfigRead r
|
||||||
let g' = Git.remotesAdd g $ exchange l r'
|
let g' = Git.remotesAdd g $ exchange l r'
|
||||||
Annex.changeState $ \s -> s { Annex.repo = g' }
|
Annex.changeState $ \s -> s { Annex.repo = g' }
|
||||||
return r'
|
return r'
|
||||||
|
|
||||||
exchange [] _ = []
|
exchange [] _ = []
|
||||||
exchange (old:ls) new =
|
exchange (old:ls) new =
|
||||||
if Git.repoRemoteName old == Git.repoRemoteName new
|
if Git.repoRemoteName old == Git.repoRemoteName new
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue