@@ -445,7 +445,7 @@ updateThunkToLatest (ThunkUpdateConfig mBranch thunkConfig) target = withSpinner
445445
446446setThunk :: MonadObelisk m => ThunkConfig -> FilePath -> GitSource -> String -> m ()
447447setThunk thunkConfig target gs branch = do
448− newThunkPtr <- uriThunkPtr (_gitSource_url gs) (Just $ T.pack branch) Nothing
448+ newThunkPtr <- uriThunkPtr (_gitSource_url gs) (_thunkConfig_private thunkConfig) (Just $ T.pack branch) Nothing
449449 overwriteThunk target newThunkPtr
450450 updateThunkToLatest (ThunkUpdateConfig Nothing thunkConfig) target
451451
@@ -701,7 +701,7 @@ packThunk' noTrail (ThunkPackConfig force thunkConfig) thunkDir = checkThunkDire
701701 Right (ThunkData_Checkout _) -> do
702702 withSpinner' ("Packing thunk " <> T.pack thunkDir)
703703 (finalMsg noTrail $ const $ "Packed thunk " <> T.pack thunkDir) $ do
704− thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) thunkDir
704+ thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) thunkDir (_thunkConfig_private thunkConfig)
705705 callProcessAndLogOutput (Debug, Error) $ proc "rm" ["-rf", thunkDir]
706706 liftIO $ createThunk thunkDir thunkPtr
707707 pure thunkPtr
@@ -714,8 +714,8 @@ modifyThunkPtrByConfig (ThunkConfig markPrivate') ptr = case markPrivate' of
714714 ThunkSource_GitHub s -> ThunkSource_GitHub $ s { _gitHubSource_private = markPrivate }
715715 }
716716
717−getThunkPtr :: forall m. MonadObelisk m => Bool -> FilePath -> m ThunkPtr
718−getThunkPtr checkClean thunkDir = do
717+getThunkPtr :: forall m. MonadObelisk m => Bool -> FilePath -> Maybe Bool -> m ThunkPtr
718+getThunkPtr checkClean thunkDir mPrivate = do
719719 when checkClean $ ensureCleanGitRepo thunkDir True
720720 "thunk pack: thunk checkout contains unsaved modifications"
721721
@@ -729,7 +729,7 @@ getThunkPtr checkClean thunkDir = do
729729 ] ++ T.lines stashOutput
730730 True -> return ()
731731
732− -- Get current branch ``
732+ -- Get current branch
733733 (mCurrentBranch, mCurrentCommit) <- do
734734 b <- listToMaybe
735735 <$> T.lines
@@ -831,7 +831,7 @@ getThunkPtr checkClean thunkDir = do
831831 remoteUri <- case parseGitUri remoteUri' of
832832 Nothing -> failWith $ "Could not identify git remote: " <> remoteUri'
833833 Just uri -> pure uri
834− uriThunkPtr remoteUri mCurrentBranch mCurrentCommit
834+ uriThunkPtr remoteUri mPrivate mCurrentBranch mCurrentCommit
835835
836836-- | Get the latest revision available from the given source
837837getLatestRev :: MonadObelisk m => ThunkSource -> m ThunkRev
@@ -850,12 +850,12 @@ getLatestRev os = do
850850-- performance. If that doesn't work (e.g. authentication issue), we fall back
851851-- on just doing things the normal way for git repos in general, and save it as
852852-- a regular git thunk.
853−uriThunkPtr :: MonadObelisk m => GitUri -> Maybe Text -> Maybe Text -> m ThunkPtr
854−uriThunkPtr uri mbranch mcommit = do
853+uriThunkPtr :: MonadObelisk m => GitUri -> Maybe Bool -> Maybe Text -> Maybe Text -> m ThunkPtr
854+uriThunkPtr uri mPrivate mbranch mcommit = do
855855 commit <- case mcommit of
856856 Nothing -> gitGetCommitBranch uri mbranch >>= return . snd
857857 (Just c) -> return c
858− (src, rev) <- uriToThunkSource uri mbranch >>= \case
858+ (src, rev) <- uriToThunkSource uri mPrivate mbranch >>= \case
859859 ThunkSource_GitHub s -> do
860860 rev <- runExceptT $ githubThunkRev s commit
861861 case rev of
@@ -878,8 +878,8 @@ uriThunkPtr uri mbranch mcommit = do
878878-- If the thunk is a GitHub thunk and fails, we do *not* fall back like with
879879-- `uriThunkPtr`. Unlike a plain URL, a thunk src explicitly states which method
880880-- should be employed, and so we respect that.
881−uriToThunkSource :: MonadObelisk m => GitUri -> Maybe Text -> m ThunkSource
882−uriToThunkSource (GitUri u)
881+uriToThunkSource :: MonadObelisk m => GitUri -> Maybe Bool -> Maybe Text -> m ThunkSource
882+uriToThunkSource (GitUri u) mPrivate
883883 | Right uriAuth <- URI.uriAuthority u
884884 , Just scheme <- URI.unRText <$> URI.uriScheme u
885885 , case scheme of
@@ -892,7 +892,7 @@ uriToThunkSource (GitUri u)
892892 && URI.unRText (URI.authHost uriAuth) == "github.com"
893893 , Just (_, owner :| [repoish]) <- URI.uriPath u
894894 = \mbranch -> do
895− isPrivate <- guessGitRepoIsPrivate $ GitUri u
895+ isPrivate <- getIsPrivate
896896 pure $ ThunkSource_GitHub $ GitHubSource
897897 { _gitHubSource_owner = N $ URI.unRText owner
898898 , _gitHubSource_repo = N $ let
@@ -903,13 +903,15 @@ uriToThunkSource (GitUri u)
903903 }
904904
905905 | otherwise = \mbranch -> do
906− isPrivate <- guessGitRepoIsPrivate $ GitUri u
906+ isPrivate <- getIsPrivate
907907 pure $ ThunkSource_Git $ GitSource
908908 { _gitSource_url = GitUri u
909909 , _gitSource_branch = N <$> mbranch
910910 , _gitSource_fetchSubmodules = False -- TODO: How do we determine if this should be true?
911911 , _gitSource_private = isPrivate
912912 }
913+ where
914+ getIsPrivate = maybe (guessGitRepoIsPrivate $ GitUri u) pure mPrivate
913915
914916guessGitRepoIsPrivate :: MonadObelisk m => GitUri -> m Bool
915917guessGitRepoIsPrivate uri = flip fix urisToTry $ \loop -> \case