Skip to content
Snippets Groups Projects
Commit 8617d39d authored by Duncan Coutts's avatar Duncan Coutts
Browse files

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.
parent ac093b28
No related branches found
No related tags found
No related merge requests found
{-# 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment