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