Skip to content
Snippets Groups Projects
Commit 07a27254 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov Committed by GitHub
Browse files

Merge pull request #4115 from hvr/pr/unpack-index-state

Add `--index-state` support to `cabal get`
parents 81ae5c2f a3ed4679
No related branches found
No related tags found
No related merge requests found
......@@ -2274,6 +2274,15 @@ The ``get`` command supports the following options:
Fork the package's source repository using the appropriate version
control system. The optional argument allows to choose a specific
repository kind.
``--index-state`` *[HEAD\|@<unix-timestamp>\|<iso8601-utc-timestamp>]*
Use source package index state as it existed at a previous time. Accepts
unix-timestamps (e.g. ``@1474732068``), ISO8601 UTC timestamps (e.g.
``2016-09-24T17:47:48Z``), or ``HEAD`` (default).
This determines which package versions are available as well as which
``.cabal`` file revision is selected (unless ``--pristine`` is used).
``--pristine``
Unpack the original pristine tarball, rather than updating the
``.cabal`` file with the latest revision from the package archive.
Custom setup scripts
--------------------
......
......@@ -39,7 +39,7 @@ import Distribution.Client.Dependency
import Distribution.Client.FetchUtils
import qualified Distribution.Client.Tar as Tar (extractTarGzFile)
import Distribution.Client.IndexUtils as IndexUtils
( getSourcePackages )
( getSourcePackagesAtIndexState, IndexState(..) )
import Distribution.Client.Compat.Process
( readProcessWithExitCode )
import Distribution.Compat.Exception
......@@ -82,7 +82,10 @@ get verbosity repoCtxt globalFlags getFlags userTargets = do
unless useFork $
mapM_ checkTarget userTargets
sourcePkgDb <- getSourcePackages verbosity repoCtxt
let idxState = fromFlagOrDefault IndexStateHead $
getIndexState getFlags
sourcePkgDb <- getSourcePackagesAtIndexState verbosity repoCtxt idxState
pkgSpecifiers <- resolveUserTargets verbosity repoCtxt
(fromFlag $ globalWorldFile globalFlags)
......
......@@ -1013,6 +1013,7 @@ instance Semigroup ReportFlags where
data GetFlags = GetFlags {
getDestDir :: Flag FilePath,
getPristine :: Flag Bool,
getIndexState :: Flag IndexState,
getSourceRepository :: Flag (Maybe RepoKind),
getVerbosity :: Flag Verbosity
} deriving Generic
......@@ -1021,6 +1022,7 @@ defaultGetFlags :: GetFlags
defaultGetFlags = GetFlags {
getDestDir = mempty,
getPristine = mempty,
getIndexState = mempty,
getSourceRepository = mempty,
getVerbosity = toFlag normal
}
......@@ -1058,6 +1060,20 @@ getCommand = CommandUI {
(Flag Nothing)
(map (fmap show) . flagToList))
, option [] ["index-state"]
("Use source package index state as it existed at a previous time. " ++
"Accepts unix-timestamps (e.g. '@1474732068'), ISO8601 UTC timestamps " ++
"(e.g. '2016-09-24T17:47:48Z'), or 'HEAD' (default: 'HEAD'). " ++
"This determines which package versions are available as well as " ++
".cabal file revision is selected (unless --pristine is used).")
getIndexState (\v flags -> flags { getIndexState = v })
(reqArg "STATE" (readP_to_E (const $ "index-state must be a " ++
"unix-timestamps (e.g. '@1474732068'), " ++
"a ISO8601 UTC timestamp " ++
"(e.g. '2016-09-24T17:47:48Z'), or 'HEAD'")
(toFlag `fmap` parse))
(flagToList . fmap display))
, option [] ["pristine"]
("Unpack the original pristine tarball, rather than updating the "
++ ".cabal file with the latest revision from the package archive.")
......
......@@ -24,6 +24,8 @@
'.../$pkgid.log' to '.../$compiler/$libname.log' (#3807).
* Added a new command, 'cabal reconfigure', which re-runs 'configure'
with the most recently used flags (#2214).
* Added add the '--index-state' flag for requesting a specific
version of the package index (#3893, #4115).
* Support for building Backpack packages. See
https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst
for more details.
......
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