Skip to content

Commit

Permalink
Stop truncating all-cabal-hashes repo
Browse files Browse the repository at this point in the history
Fix #2175.

* Fetch full history of tags (in particular, `current-hackage`).
* Before fetching tags, transition previously shallow repos to be
  non-shallow with `fetch --unshallow`.
* Fetch full history in initial clone, otherwise, we immediately
  afterwards use `fetch --unshallow`.

This means that the initial fetch and later updates require more data,
proportional to the entire repository history; however, reducing data
usage again is not trivial and would require changes in the layout of
all-cabal-hashes, as discussed in #2175.
  • Loading branch information
Blaisorblade committed Aug 13, 2016
1 parent 8d86a79 commit 753a7db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Stack/PackageIndex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import Data.Text.Unsafe (unsafeTail)
import Data.Traversable (forM)
import Data.Typeable (Typeable)
import Network.HTTP.Download
import Path (mkRelDir, parent, parseRelDir, toFilePath, parseAbsFile, (</>))
import Path (mkRelDir, mkRelFile, parent, parseRelDir, toFilePath, parseAbsFile, (</>))
import Path.IO
import Prelude -- Fix AMP warning
import Stack.Types.Config
Expand Down Expand Up @@ -239,8 +239,6 @@ updateIndexGit menv indexName' index gitUrl = do
["clone"
,T.unpack gitUrl
,toFilePath repoName
,"--depth"
,"1"
,"-b" --
,"display"]
sDir <- configPackageIndexRoot indexName'
Expand All @@ -251,9 +249,13 @@ updateIndexGit menv indexName' index gitUrl = do
repoExists <- doesDirExist acfDir
unless repoExists
(readProcessNull (Just suDir) menv "git" cloneArgs)
isShallow <- doesFileExist $ acfDir </> $(mkRelDir ".git") </> $(mkRelFile "shallow")
when isShallow $ do
$logWarn "Shallow package index repo detected, transitioning to a full clone..."
(readProcessNull (Just acfDir) menv "git" ["fetch", "--unshallow"])
$logSticky "Fetching package index ..."
let runFetch = callProcessInheritStderrStdout
(Cmd (Just acfDir) "git" menv ["fetch","--tags","--depth=1"])
(Cmd (Just acfDir) "git" menv ["fetch","--tags"])
runFetch `C.catch` \(ex :: ProcessExitedUnsuccessfully) -> do
-- we failed, so wipe the directory and try again, see #1418
$logWarn (T.pack (show ex))
Expand Down

0 comments on commit 753a7db

Please sign in to comment.