From 8617d39d3c0be275e4373c1c6d5ddc7368083960 Mon Sep 17 00:00:00 2001 From: Duncan Coutts <duncan@community.haskell.org> Date: Sun, 28 Jun 2015 00:00:05 +0100 Subject: [PATCH] Add a point where we can add extra info for known repositories This will be useful for adding crypto credentials without people having to update their config files. Also useful point to add any other special casing for known repos. --- cabal-install/Distribution/Client/Config.hs | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cabal-install/Distribution/Client/Config.hs b/cabal-install/Distribution/Client/Config.hs index 16da44ee8d..1588d032d6 100644 --- a/cabal-install/Distribution/Client/Config.hs +++ b/cabal-install/Distribution/Client/Config.hs @@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-} -{-# LANGUAGE ViewPatterns #-} ----------------------------------------------------------------------------- -- | @@ -508,6 +507,19 @@ defaultRemoteRepo = RemoteRepo name uri () -- entries that match repo name and url (not only be used for generating -- fresh config files). +-- For the default repo we know extra information, fill this in. +-- +-- We need this because the 'defaultRemoteRepo' above is only used for the +-- first time when a config file is made. So for users with older config files +-- we might have only have older info. This lets us fill that in even for old +-- config files. +-- +addInfoForKnownRepos :: RemoteRepo -> RemoteRepo +addInfoForKnownRepos repo@RemoteRepo{ remoteRepoName = "hackage.haskell.org" } = + repo + --remoteRepoRootKeys --TODO: when this list is empty, fill in known crypto credentials +addInfoForKnownRepos other = other + -- -- * Config file reading -- @@ -783,12 +795,17 @@ parseConfig initial = \str -> do config <- parse others let user0 = savedUserInstallDirs config global0 = savedGlobalInstallDirs config - compileRemoteRepos = reverse . nubBy ((==) `on` remoteRepoName) - (compileRemoteRepos -> remoteRepoSections, haddockFlags, user, global, paths, args) <- + (remoteRepoSections0, haddockFlags, user, global, paths, args) <- foldM parseSections ([], savedHaddockFlags config, user0, global0, [], []) knownSections + let remoteRepoSections = + map addInfoForKnownRepos + . reverse + . nubBy ((==) `on` remoteRepoName) + $ remoteRepoSections0 + return config { savedGlobalFlags = (savedGlobalFlags config) { globalRemoteRepos = toNubList remoteRepoSections -- GitLab