Now supports git's insteadOf configuration, to modify the url used to access a remote. Note that pushInsteadOf is not used; that and pushurl are reserved for actual git pushes. Closes: #644278
This commit is contained in:
parent
dfee6e1ed6
commit
81ed7b203d
2 changed files with 21 additions and 4 deletions
22
Git.hs
22
Git.hs
|
@ -496,15 +496,29 @@ configParse s = M.fromList $ map pair $ lines s
|
||||||
configRemotes :: Repo -> IO [Repo]
|
configRemotes :: Repo -> IO [Repo]
|
||||||
configRemotes repo = mapM construct remotepairs
|
configRemotes repo = mapM construct remotepairs
|
||||||
where
|
where
|
||||||
remotepairs = M.toList $ filterremotes $ config repo
|
filterconfig f = filter f $ M.toList $ config repo
|
||||||
filterremotes = M.filterWithKey (\k _ -> isremote k)
|
filterkeys f = filterconfig (\(k,_) -> f k)
|
||||||
|
remotepairs = filterkeys isremote
|
||||||
isremote k = startswith "remote." k && endswith ".url" k
|
isremote k = startswith "remote." k && endswith ".url" k
|
||||||
construct (k,v) = do
|
construct (k,v) = do
|
||||||
r <- gen v
|
r <- gen $ calcloc v
|
||||||
return $ repoRemoteNameSet r k
|
return $ repoRemoteNameSet r k
|
||||||
gen v | scpstyle v = repoFromUrl $ scptourl v
|
gen v
|
||||||
|
| scpstyle v = repoFromUrl $ scptourl v
|
||||||
| isURI v = repoFromUrl v
|
| isURI v = repoFromUrl v
|
||||||
| otherwise = repoFromRemotePath v repo
|
| otherwise = repoFromRemotePath v repo
|
||||||
|
-- insteadof config can rewrite remote location
|
||||||
|
calcloc l
|
||||||
|
| null insteadofs = l
|
||||||
|
| otherwise = replacement ++ drop (length replacement) l
|
||||||
|
where
|
||||||
|
replacement = take (length bestkey - length prefix) bestkey
|
||||||
|
bestkey = fst $ maximumBy longestvalue insteadofs
|
||||||
|
longestvalue (_, a) (_, b) = compare b a
|
||||||
|
insteadofs = filterconfig $ \(k, v) ->
|
||||||
|
endswith prefix k &&
|
||||||
|
startswith v l
|
||||||
|
prefix = ".insteadof"
|
||||||
-- git remotes can be written scp style -- [user@]host:dir
|
-- git remotes can be written scp style -- [user@]host:dir
|
||||||
scpstyle v = ":" `isInfixOf` v && not ("//" `isInfixOf` v)
|
scpstyle v = ":" `isInfixOf` v && not ("//" `isInfixOf` v)
|
||||||
scptourl v = "ssh://" ++ host ++ slash dir
|
scptourl v = "ssh://" ++ host ++ slash dir
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -18,6 +18,9 @@ git-annex (3.20110929) UNRELEASED; urgency=low
|
||||||
the expected repository.
|
the expected repository.
|
||||||
* Note that this git-annex will not interoperate with remotes using
|
* Note that this git-annex will not interoperate with remotes using
|
||||||
older versions of git-annex-shell.
|
older versions of git-annex-shell.
|
||||||
|
* Now supports git's insteadOf configuration, to modify the url
|
||||||
|
used to access a remote. Note that pushInsteadOf is not used;
|
||||||
|
that and pushurl are reserved for actual git pushes. Closes: #644278
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 29 Sep 2011 18:58:53 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 29 Sep 2011 18:58:53 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue