diff --git a/Data/Git/Repository.hs b/Data/Git/Repository.hs index 2ba11412e5471ef42638071990f27cfbe3a54f69..507232e521f94b9d791560c1e16fbbbb755bc93f 100644 --- a/Data/Git/Repository.hs +++ b/Data/Git/Repository.hs @@ -42,7 +42,7 @@ module Data.Git.Repository import Control.Exception (Exception, throw) import Data.Maybe (fromMaybe) -import Data.List (find) +import Data.List (find, stripPrefix) import Data.Data import Data.IORef @@ -129,7 +129,11 @@ resolveRevision git (Revision prefix modifiers) = "HEAD" -> [ RefHead ] "ORIG_HEAD" -> [ RefOrigHead ] "FETCH_HEAD" -> [ RefFetchHead ] - _ -> map (flip ($) (RefName prefix)) [RefTag,RefBranch,RefRemote] + _ -> + maybe (map (flip ($) (RefName prefix)) [RefTag,RefBranch,RefRemote]) (:[]) $ + (RefBranch . RefName <$> stripPrefix "refs/heads/" prefix) + <|> (RefTag . RefName <$> stripPrefix "refs/tags/" prefix) + <|> (RefRemote . RefName <$> stripPrefix "refs/remotes/" prefix) tryResolvers :: HashAlgorithm hash => [IO (Maybe (Ref hash))] -> IO (Maybe (Ref hash)) tryResolvers [] = return $ if (isHexString prefix)