@@ -71,7 +71,7 @@ import System.Process (StdStream (CreatePipe), callProcess, createProcess, proc,
7171import Development.Placeholders
7272import Obelisk.App (MonadObelisk)
7373import Obelisk.CLI (Severity (..), callProcessAndLogOutput, failWith, putLog, withSpinner)
74−import Obelisk.Command.Utils (callProcessNixShell, checkGitCleanStatus, cp)
74+import Obelisk.Command.Utils (checkGitCleanStatus, cp, procWithPackages)
7575
7676--TODO: Support symlinked thunk data
7777data ThunkData
@@ -472,36 +472,35 @@ unpackThunk thunkDir = readThunk thunkDir >>= \case
472472 Nothing -> fail "Cannot determine clone URI for thunk source"
473473 Just c -> return $ T.unpack $ getUrl c
474474 withSpinner ("Retrieving thunk " <> T.pack thunkName <> " from GitHub") $ do
475− callProcessAndLogOutput Notice (proc "hub" ["clone", "-n", githubURI, tmpRepo])
476− let obGitDir = tmpRepo </> ".git" </> "obelisk"
477− --If this directory already exists then something is weird and we should fail
478− liftIO $ createDirectory obGitDir
479− withSpinner ("Copying thunk " <> T.pack thunkName <> " to " <> T.pack thunkDir) $ do
480− liftIO $ cp
481− [ "-r"
482− , "-T"
483− , thunkDir </> "."
484− , obGitDir </> "orig-thunk"
485− ]
486− let checkoutOptions = concat
475+ callProcessAndLogOutput Notice $
476+ proc "hub" ["clone", "-n", githubURI, tmpRepo]
477+ let obGitDir = tmpRepo </> ".git" </> "obelisk"
478+ --If this directory already exists then something is weird and we should fail
479+ liftIO $ createDirectory obGitDir
480+ callProcessAndLogOutput Notice $
481+ cp ["-r", "-T", thunkDir </> ".", obGitDir </> "orig-thunk"]
482+ withSpinner ("Preparing thunk in " <> T.pack thunkDir) $ do
483+ -- Checkout
484+ putLog Notice $ "Checking out " <> T.pack (show $ maybe "" untagName $ _gitHubSource_branch s)
485+ callProcessAndLogOutput Debug $
486+ proc "hub" $ concat
487487 [ ["-C", tmpRepo]
488488 , pure "checkout"
489489 , maybe [] (\n -> ["-B", T.unpack (untagName n)]) (_gitHubSource_branch s)
490490 , pure $ Ref.toHexString $ _thunkRev_commit $ _thunkPtr_rev tptr
491491 ]
492− liftIO $ do
493− callProcess "hub" checkoutOptions
492+ -- Set upstream branch
494493 forM_ (_gitHubSource_branch s) $ \branch ->
495− callProcess "hub" ["-C", tmpRepo, "branch", "-u", "origin/" <> T.unpack (untagName branch)]
496− callProcess "rm"
497− [ "-r"
498− , thunkDir
499− ]
500− callProcessNixShell ["coreutils"] "mv"
501− [ "-T"
502− , tmpRepo
503− , thunkDir
504− ]
494+ callProcessAndLogOutput Debug $
495+ proc "hub" ["-C", tmpRepo, "branch", "-u", "origin/" <> T.unpack (untagName branch)]
496+ callProcessAndLogOutput Notice $
497+ proc "rm" ["-r", thunkDir]
498+ callProcessAndLogOutput Notice $
499+ procWithPackages ["coreutils"] "mv"
500+ [ "-T"
501+ , tmpRepo
502+ , thunkDir
503+ ]
505504 ThunkSource_Git _s -> do
506505 $notImplemented
507506