From e197afeaa22906b13cc534814c7dbcfc652270d6 Mon Sep 17 00:00:00 2001 From: Kim Altintop <kim.altintop@gmail.com> Date: Tue, 11 Dec 2018 12:56:58 +0100 Subject: [PATCH] Consider "refs/*/" path prefixes when resolving 'Revision's e.g. resolve "refs/heads/master", resolve "refs/tags/v0.42" --- Data/Git/Repository.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Data/Git/Repository.hs b/Data/Git/Repository.hs index 2ba1141..507232e 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) -- GitLab