on master help sign in
Disallow using '.' in 'ob thunk update'
commitee5acbb7ad30105e8e98041616d2c995890c87d9 authorhsloan <ishaqsloan@gmail.com> dateFri 30 Nov 2018, 22:41 (8 years ago) parent61dce9b
1 file changed+15−12
lib/command/src/Obelisk/Command/Thunk.hs+15−12
lib/command/src/Obelisk/Command/Thunk.hs+15−12
@@ -379,18 +379,21 @@ createThunkWithLatest target s = do
379379 }
380380
381381updateThunkToLatest :: MonadObelisk m => FilePath -> m ()
382−updateThunkToLatest target = withSpinner' ("Updating thunk " <> T.pack target <> " to latest") (pure $ const $ "Thunk " <> T.pack target <> " updated to latest") $ do
383− (overwrite, ptr) <- readThunk target >>= \case
384− Left err -> failWith $ T.pack $ "thunk update: " <> show err
385− Right c -> case c of
386− ThunkData_Packed t -> return (target, t)
387− ThunkData_Checkout _ -> failWith "cannot update an unpacked thunk"
388− let src = _thunkPtr_source ptr
389− rev <- getLatestRev src
390− overwriteThunk overwrite $ ThunkPtr
391− { _thunkPtr_source = src
392− , _thunkPtr_rev = rev
393− }
382+updateThunkToLatest target = withSpinner' ("Updating thunk " <> T.pack target <> " to latest") (pure $ const $ "Thunk " <> T.pack target <> " updated to latest") $
383+ case target of
384+ "." -> failWith "ob thunk update directory cannot be '.'"
385+ _ -> do
386+ (overwrite, ptr) <- readThunk target >>= \case
387+ Left err -> failWith $ T.pack $ "thunk update: " <> show err
388+ Right c -> case c of
389+ ThunkData_Packed t -> return (target, t)
390+ ThunkData_Checkout _ -> failWith "cannot update an unpacked thunk"
391+ let src = _thunkPtr_source ptr
392+ rev <- getLatestRev src
393+ overwriteThunk overwrite $ ThunkPtr
394+ { _thunkPtr_source = src
395+ , _thunkPtr_rev = rev
396+ }
394397
395398-- | All recognized github standalone loaders, ordered from newest to oldest.
396399-- This tool will only ever produce the newest one when it writes a thunk.