move hashObject to HashObject library and generalize it to support all git object types

This commit is contained in:
Joey Hess 2012-06-06 02:31:31 -04:00
parent f1bd72ea54
commit f596084a59
4 changed files with 36 additions and 22 deletions

View file

@ -48,3 +48,18 @@ instance Show Ref where
type Branch = Ref
type Sha = Ref
type Tag = Ref
{- Types of objects that can be stored in git. -}
data ObjectType = BlobObject | CommitObject | TreeObject
instance Show ObjectType where
show BlobObject = "blob"
show CommitObject = "commit"
show TreeObject = "tree"
readObjectType :: String -> Maybe ObjectType
readObjectType "blob" = Just BlobObject
readObjectType "commit" = Just CommitObject
readObjectType "tree" = Just TreeObject
readObjectType _ = Nothing