Skip to content

Commit

Permalink
Merge pull request #9771 from peterbecich/source-repo-offline
Browse files Browse the repository at this point in the history
offline flag disables `source-repository-package` sync
  • Loading branch information
mergify[bot] committed Mar 8, 2024
2 parents 95436a3 + df8f0c5 commit b0f9d0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
21 changes: 15 additions & 6 deletions cabal-install/src/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ fetchAndReadSourcePackages
verbosity
distDirLayout
projectConfigShared
(fromFlag (projectConfigOfflineMode projectConfigBuildOnly))
[repo | ProjectPackageRemoteRepo repo <- pkgLocations]

let pkgsNamed =
Expand Down Expand Up @@ -1308,6 +1309,7 @@ syncAndReadSourcePackagesRemoteRepos
:: Verbosity
-> DistDirLayout
-> ProjectConfigShared
-> Bool
-> [SourceRepoList]
-> Rebuild [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
syncAndReadSourcePackagesRemoteRepos
Expand All @@ -1316,6 +1318,7 @@ syncAndReadSourcePackagesRemoteRepos
ProjectConfigShared
{ projectConfigProgPathExtra
}
offlineMode
repos = do
repos' <-
either reportSourceRepoProblems return $
Expand Down Expand Up @@ -1370,12 +1373,18 @@ syncAndReadSourcePackagesRemoteRepos

-- For syncing we don't care about different 'SourceRepo' values that
-- are just different subdirs in the same repo.
syncSourceRepos
verbosity
vcs
[ (repo, repoPath)
| (repo, _, repoPath) <- repoGroupWithPaths
]
-- Do not sync source repositories when `--offline` flag applied.
if not offlineMode
then
syncSourceRepos
verbosity
vcs
[ (repo, repoPath)
| (repo, _, repoPath) <- repoGroupWithPaths
]
else do
liftIO . warn verbosity $ "--offline was specified, skipping sync of repositories:"
liftIO . for_ repoGroupWithPaths $ \(repo, _, _) -> warn verbosity $ srpLocation repo

-- Run post-checkout-command if it is specified
for_ repoGroupWithPaths $ \(repo, _, repoPath) ->
Expand Down
8 changes: 8 additions & 0 deletions changelog.d/issue-9641
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
synopsis: offline flag applied to `source-repository-package`s
packages: Cabal-install
prs: #9771
issues: #9641

description: {
`--offline` flag is already used to block access to Hackage. Now with this PR, this also applies to remote dependency `source-repository-package` in `cabal.project`.
}

0 comments on commit b0f9d0b

Please sign in to comment.