further insteadOf fix
This commit is contained in:
parent
7d05ca1d6d
commit
80a0be5116
1 changed files with 5 additions and 4 deletions
9
Git.hs
9
Git.hs
|
@ -521,16 +521,17 @@ genRemote s repo = gen $ calcloc s
|
||||||
-- insteadof config can rewrite remote location
|
-- insteadof config can rewrite remote location
|
||||||
calcloc l
|
calcloc l
|
||||||
| null insteadofs = l
|
| null insteadofs = l
|
||||||
| otherwise = replacement ++ drop (length replacement) l
|
| otherwise = replacement ++ drop (length bestvalue) l
|
||||||
where
|
where
|
||||||
replacement = drop (length "url.") $
|
replacement = drop (length prefix) $
|
||||||
take (length bestkey - length suffix) bestkey
|
take (length bestkey - length suffix) bestkey
|
||||||
bestkey = fst $ maximumBy longestvalue insteadofs
|
(bestkey, bestvalue) = maximumBy longestvalue insteadofs
|
||||||
longestvalue (_, a) (_, b) = compare b a
|
longestvalue (_, a) (_, b) = compare b a
|
||||||
insteadofs = filterconfig $ \(k, v) ->
|
insteadofs = filterconfig $ \(k, v) ->
|
||||||
|
startswith prefix k &&
|
||||||
endswith suffix k &&
|
endswith suffix k &&
|
||||||
startswith v l
|
startswith v l
|
||||||
suffix = ".insteadof"
|
(prefix, suffix) = ("url." , ".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
|
||||||
|
|
Loading…
Reference in a new issue