@@ -409,7 +409,7 @@ initThunk :: MonadObelisk m => FilePath -> m ()
409409initThunk target = withSpinner [i|Initializing thunk at ${target}|] $ do
410410 checkThunkDirectory target
411411 unlessM (liftIO $ doesDirectoryExist $ target </> ".git") $ failWith [i|${target} is not a git checkout.|]
412− ptr <- getThunkPtr False target Nothing
412+ ptr <- getThunkPtr CheckClean_NoCheck target Nothing
413413 let tempThunkDir = target <.> "thunk-init"
414414 whenM (liftIO $ doesPathExist tempThunkDir) $
415415 failWith [i|A previous 'thunk init' left unfinished state at ${tempThunkDir}. You will need to rename or remove that path before trying again.|]
@@ -831,7 +831,8 @@ packThunk' noTrail (ThunkPackConfig force thunkConfig) thunkDir = checkThunkDire
831831 ("Packing thunk " <> T.pack thunkDir)
832832 (finalMsg noTrail $ const $ "Packed thunk " <> T.pack thunkDir) $
833833 do
834− thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) thunkDir (_thunkConfig_private thunkConfig)
834+ let checkClean = if force then CheckClean_NoCheck else CheckClean_FullCheck
835+ thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr checkClean thunkDir (_thunkConfig_private thunkConfig)
835836 callProcessAndLogOutput (Debug, Error) $ proc rmPath ["-rf", thunkDir] -- thunkDir may be a symlink
836837 createThunk thunkDir $ Right thunkPtr
837838 pure thunkPtr
@@ -844,15 +845,27 @@ modifyThunkPtrByConfig (ThunkConfig markPrivate') ptr = case markPrivate' of
844845 ThunkSource_GitHub s -> ThunkSource_GitHub $ s { _gitHubSource_private = markPrivate }
845846 }
846847
847−getThunkPtr :: forall m. MonadObelisk m => Bool -> FilePath -> Maybe Bool -> m ThunkPtr
848−getThunkPtr checkClean dir mPrivate = do
848+data CheckClean
849+ = CheckClean_FullCheck
850+ -- ^ Check that the repo is clean, including .gitignored files
851+ | CheckClean_NotIgnored
852+ -- ^ Check that the repo is clean, not including .gitignored files
853+ | CheckClean_NoCheck
854+ -- ^ Don't check that the repo is clean
855+
856+getThunkPtr :: forall m. MonadObelisk m => CheckClean -> FilePath -> Maybe Bool -> m ThunkPtr
857+getThunkPtr gitCheckClean dir mPrivate = do
849858 let repoLocations = [(".git", "."), (unpackedDirName, unpackedDirName)]
850859 repoLocation' <- liftIO $ flip findM repoLocations $ doesDirectoryExist . (dir </>) . fst
851860 thunkDir <- case repoLocation' of
852861 Nothing -> failWith [i|Can't find an unpacked thunk in ${dir}|]
853862 Just (_, path) -> pure $ normalise $ dir </> path
854863
855− when checkClean $ ensureCleanGitRepo thunkDir True
864+ let (checkClean, checkIgnored) = case gitCheckClean of
865+ CheckClean_FullCheck -> (True, True)
866+ CheckClean_NotIgnored -> (True, False)
867+ CheckClean_NoCheck -> (False, False)
868+ when checkClean $ ensureCleanGitRepo thunkDir checkIgnored
856869 "thunk pack: thunk checkout contains unsaved modifications"
857870
858871 -- Check whether there are any stashes