summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-16 16:31:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-16 16:31:59 -0400
commit8560f266ebcafb59b9da88a99144a336e1aa747e (patch)
tree0855097b863bc94ed7d514b30f43245e378da2d2 /Command
parent0d967326df6332d701e39206d3389b4770735397 (diff)
map: Combine duplicate repositories, for a nicer looking map.
Diffstat (limited to 'Command')
-rw-r--r--Command/Map.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/Command/Map.hs b/Command/Map.hs
index 94b1289dc..f2ac52047 100644
--- a/Command/Map.hs
+++ b/Command/Map.hs
@@ -35,7 +35,7 @@ seek = [withNothing start]
start :: CommandStart
start = do
- rs <- spider =<< gitRepo
+ rs <- combineSame <$> (spider =<< gitRepo)
umap <- uuidMap
trusted <- trustGet Trusted
@@ -77,7 +77,7 @@ hostname r
| otherwise = "localhost"
basehostname :: Git.Repo -> String
-basehostname r = Prelude.head $ split "." $ hostname r
+basehostname r = fromMaybe "" $ headMaybe $ split "." $ hostname r
{- A name to display for a repo. Uses the name from uuid.log if available,
- or the remote name if not. -}
@@ -236,3 +236,11 @@ tryScan r
sshnote = do
showAction "sshing"
showOutput
+
+{- Spidering can find multiple paths to the same repo, so this is used
+ - to combine (really remove) duplicate repos with the same UUID. -}
+combineSame :: [Git.Repo] -> [Git.Repo]
+combineSame = map snd . nubBy sameuuid . map pair
+ where
+ sameuuid (u1, _) (u2, _) = u1 == u2 && u1 /= NoUUID
+ pair r = (getUncachedUUID r, r)