@@ -640,17 +640,20 @@ getThunkPtr' checkClean thunkDir = do
640640 True -> return ()
641641
642642 -- Get current branch ``
643− mCurrentBranch <- do
643+ (mCurrentBranch, mCurrentCommit) <- do
644644 b <- listToMaybe
645645 <$> T.lines
646646 <$> readGitProcess thunkDir ["rev-parse", "--abbrev-ref", "HEAD"]
647+ c <- listToMaybe
648+ <$> T.lines
649+ <$> readGitProcess thunkDir ["rev-parse", "HEAD"]
647650 case b of
648651 (Just "HEAD") -> failWith $ T.unlines $
649652 [ "thunk pack: You are in 'detached HEAD' state."
650653 , "If you want to pack at the current ref \
651654 \then please create a new branch with 'git checkout -b <new-branch-name>' and push this upstream."
652655 ]
653− _ -> return b
656+ _ -> return (b, c)
654657
655658 -- Get information on all branches and their (optional) designated upstream
656659 -- correspondents
@@ -738,7 +741,7 @@ getThunkPtr' checkClean thunkDir = do
738741 remoteUri <- case parseGitUri remoteUri' of
739742 Nothing -> failWith $ "Could not identify git remote: " <> remoteUri'
740743 Just uri -> pure uri
741− uriThunkPtr remoteUri mCurrentBranch
744+ uriThunkPtr remoteUri mCurrentBranch mCurrentCommit
742745
743746-- | Get the latest revision available from the given source
744747getLatestRev :: MonadObelisk m => ThunkSource -> m ThunkRev
@@ -757,9 +760,11 @@ getLatestRev os = do
757760-- performance. If that doesn't work (e.g. authentication issue), we fall back
758761-- on just doing things the normal way for git repos in general, and save it as
759762-- a regular git thunk.
760−uriThunkPtr :: MonadObelisk m => URI -> Maybe Text -> m ThunkPtr
761−uriThunkPtr uri mbranch = do
762− (_, commit) <- gitGetCommitBranch uri mbranch
763+uriThunkPtr :: MonadObelisk m => URI -> Maybe Text -> Maybe Text -> m ThunkPtr
764+uriThunkPtr uri mbranch mcommit = do
765+ commit <- case mcommit of
766+ Nothing -> gitGetCommitBranch uri mbranch >>= return . snd
767+ (Just c) -> return c
763768 (src, rev) <- case uriToThunkSource uri mbranch of
764769 ThunkSource_GitHub s -> do
765770 rev <- runExceptT $ githubThunkRev s commit