Skip to content

Commit

Permalink
offline flag disables source-repository-package sync
Browse files Browse the repository at this point in the history
#9641

warning when offline mode skips `source-repository-package`s
i.e.
```
Warning: --offline was specified, skipping sync of repositories:
Warning: https://github.com/haskell/text.git
```

(cherry picked from commit df8f0c5)
  • Loading branch information
peterbecich authored and Mikolaj committed May 16, 2024
1 parent 8deb30e commit df33ffd
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 @@ -1196,6 +1196,7 @@ fetchAndReadSourcePackages
verbosity
distDirLayout
projectConfigShared
(fromFlag (projectConfigOfflineMode projectConfigBuildOnly))
[repo | ProjectPackageRemoteRepo repo <- pkgLocations]

let pkgsNamed =
Expand Down Expand Up @@ -1312,6 +1313,7 @@ syncAndReadSourcePackagesRemoteRepos
:: Verbosity
-> DistDirLayout
-> ProjectConfigShared
-> Bool
-> [SourceRepoList]
-> Rebuild [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
syncAndReadSourcePackagesRemoteRepos
Expand All @@ -1320,6 +1322,7 @@ syncAndReadSourcePackagesRemoteRepos
ProjectConfigShared
{ projectConfigProgPathExtra
}
offlineMode
repos = do
repos' <-
either reportSourceRepoProblems return $
Expand Down Expand Up @@ -1374,12 +1377,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 df33ffd

Please sign in to comment.