Skip to content
Snippets Groups Projects
Unverified Commit 0e47ae7e authored by Vincent Hanquez's avatar Vincent Hanquez Committed by GitHub
Browse files

Merge pull request #12 from kim/resolve-refs

Consider "refs/*/" path prefixes when resolving 'Revision's
parents eec66740 e197afea
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ module Data.Git.Repository ...@@ -42,7 +42,7 @@ module Data.Git.Repository
import Control.Exception (Exception, throw) import Control.Exception (Exception, throw)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Data.List (find) import Data.List (find, stripPrefix)
import Data.Data import Data.Data
import Data.IORef import Data.IORef
...@@ -129,7 +129,11 @@ resolveRevision git (Revision prefix modifiers) = ...@@ -129,7 +129,11 @@ resolveRevision git (Revision prefix modifiers) =
"HEAD" -> [ RefHead ] "HEAD" -> [ RefHead ]
"ORIG_HEAD" -> [ RefOrigHead ] "ORIG_HEAD" -> [ RefOrigHead ]
"FETCH_HEAD" -> [ RefFetchHead ] "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 :: HashAlgorithm hash => [IO (Maybe (Ref hash))] -> IO (Maybe (Ref hash))
tryResolvers [] = return $ if (isHexString prefix) tryResolvers [] = return $ if (isHexString prefix)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment