on master help sign in
added error message for 'ob thunk' when on detached HEAD
commit6a6bb5d364d87d83faa469fb48e349ecc7319927 authorDivam <dfordivam@gmail.com> dateFri 7 Dec 2018, 15:04 (8 years ago) parent61dce9b
1 file changed+13−5
lib/command/src/Obelisk/Command/Thunk.hs+13−5
lib/command/src/Obelisk/Command/Thunk.hs+13−5
@@ -639,6 +639,19 @@ getThunkPtr' checkClean thunkDir = do
639639 ] ++ T.lines stashOutput
640640 True -> return ()
641641
642+ -- Get current branch ``
643+ mCurrentBranch <- do
644+ b <- listToMaybe
645+ <$> T.lines
646+ <$> readGitProcess thunkDir ["rev-parse", "--abbrev-ref", "HEAD"]
647+ case b of
648+ (Just "HEAD") -> failWith $ T.unlines $
649+ [ "thunk pack: You are in 'detached HEAD' state."
650+ , "If you want to pack at the current ref \
651+ \then please create a new branch with 'git checkout -b <new-branch-name>' and push this upstream."
652+ ]
653+ _ -> return b
654+
642655 -- Get information on all branches and their (optional) designated upstream
643656 -- correspondents
644657 (headDump :: [Text]) <- T.lines <$> readGitProcess thunkDir
@@ -714,11 +727,6 @@ getThunkPtr' checkClean thunkDir = do
714727 -- We assume it's safe to pack the thunk at this point
715728 putLog Informational $ "All changes safe in git remotes. OK to pack thunk."
716729
717− -- Get current branch ``
718− mCurrentBranch <- listToMaybe
719− <$> T.lines
720− <$> readGitProcess thunkDir ["rev-parse", "--abbrev-ref", "HEAD"]
721−
722730 let remote = maybe "origin" snd $ flip Map.lookup headUpstream =<< mCurrentBranch
723731
724732 [remoteUri'] <- fmap T.lines $ readGitProcess thunkDir