Data.Git.Repository

hit-0.6.3: Git operations in haskell

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unix
Safe Haskell | None
Language | Haskell98

Data.Git.Repository

Contents

- Config
- Trees
- named refs manipulation

Description

Synopsis

- data Git
- configGetAll :: Git -> IO [Config]
- configGet :: Git -> String -> String -> IO (Maybe String)
- newtype Config = Config [Section]
- data Section = Section {
  - sectionName :: String
  - sectionKVs :: [(String, String)]
  }
- type HTree = [(ModePerm, EntName, HTreeEnt)]
- data HTreeEnt
  - = TreeDir Ref HTree
  - | TreeFile Ref
- newtype RefName = RefName {
  - refNameRaw :: String
  }
- getCommitMaybe :: Git -> Ref -> IO (Maybe Commit)
- getCommit :: Git -> Ref -> IO Commit
- getTreeMaybe :: Git -> Ref -> IO (Maybe Tree)
- getTree :: Git -> Ref -> IO Tree
- rewrite :: Git -> (Commit -> IO Commit) -> Revision -> Int -> IO Ref
- buildHTree :: Git -> Tree -> IO HTree
- resolvePath :: Git -> Ref -> EntPath -> IO (Maybe Ref)
- resolveTreeish :: Git -> Ref -> IO (Maybe Tree)
- resolveRevision :: Git -> Revision -> IO (Maybe Ref)
- initRepo :: FilePath -> IO ()
- isRepo :: FilePath -> IO Bool
- branchWrite :: Git -> RefName -> Ref -> IO ()
- branchList :: Git -> IO (Set RefName)
- tagWrite :: Git -> RefName -> Ref -> IO ()
- tagList :: Git -> IO (Set RefName)
- headSet :: Git -> Either Ref RefName -> IO ()
- headGet :: Git -> IO (Either Ref RefName)

# Documentation

data Git #

represent a git repo, with possibly already opened filereaders for indexes and packs

# Config

configGetAll :: Git -> IO [Config] #

Read the Config

configGet #

Arguments

:: Git | Git context
-> String | section name
-> String | key name
-> IO (Maybe String) | The resulting value if it exists

Get a configuration element from the config file, starting from the local repository config file, then the global config file.

for example the equivalent to git config user.name is:

    configGet git "user" "name"

newtype Config #

Constructors

Config [Section] |

Instances

Eq Config # |
Methods (==) :: Config -> Config -> Bool # (/=) :: Config -> Config -> Bool #
Show Config # |
Methods showsPrec :: Int -> Config -> ShowS # show :: Config -> String # showList :: [Config] -> ShowS #

data Section #

Constructors

Section |
Fields sectionName :: String sectionKVs :: [(String, String)]

Instances

Eq Section # |
Methods (==) :: Section -> Section -> Bool # (/=) :: Section -> Section -> Bool #
Show Section # |
Methods showsPrec :: Int -> Section -> ShowS # show :: Section -> String # showList :: [Section] -> ShowS #

# Trees

type HTree = [(ModePerm, EntName, HTreeEnt)] #

data HTreeEnt #

hierarchy tree, either a reference to a blob (file) or a tree (directory).

Constructors

TreeDir Ref HTree |
TreeFile Ref |

newtype RefName #

Constructors

RefName |
Fields refNameRaw :: String

Instances

Eq RefName # |
Methods (==) :: RefName -> RefName -> Bool # (/=) :: RefName -> RefName -> Bool #
Ord RefName # |
Methods compare :: RefName -> RefName -> Ordering # (<) :: RefName -> RefName -> Bool # (<=) :: RefName -> RefName -> Bool # (>) :: RefName -> RefName -> Bool # (>=) :: RefName -> RefName -> Bool # max :: RefName -> RefName -> RefName # min :: RefName -> RefName -> RefName #
Show RefName # |
Methods showsPrec :: Int -> RefName -> ShowS # show :: RefName -> String # showList :: [RefName] -> ShowS #
IsString RefName # |
Methods fromString :: String -> RefName #

getCommitMaybe :: Git -> Ref -> IO (Maybe Commit) #

get a specified commit

getCommit :: Git -> Ref -> IO Commit #

get a specified commit but raises an exception if doesn't exists or type is not appropriate

getTreeMaybe :: Git -> Ref -> IO (Maybe Tree) #

get a specified tree

getTree :: Git -> Ref -> IO Tree #

get a specified tree but raise

rewrite #

Arguments

:: Git | Repository
-> (Commit -> IO Commit) | Mapping function
-> Revision | revision to start from
-> Int | the number of parents to map
-> IO Ref | return the new head REF

Rewrite a set of commits from a revision and returns the new ref.

If during revision traversal (diving) there's a commit with zero or multiple parents then the traversal will stop regardless of the amount of parent requested.

calling "rewrite f 2 (revisionOf d)" on the following tree:

a <-- b <-- c <-- d

result in the following tree after mapping with f:

a <-- f(b) <-- f(c) <-- f(d)

buildHTree :: Git -> Tree -> IO HTree #

build a hierarchy tree from a tree object

resolvePath #

Arguments

:: Git | repository
-> Ref | commit reference
-> EntPath | paths
-> IO (Maybe Ref) |

resolve the ref (tree or blob) related to a path at a specific commit ref

resolveTreeish :: Git -> Ref -> IO (Maybe Tree) #

returns a tree from a ref that might be either a commit, a tree or a tag.

resolveRevision :: Git -> Revision -> IO (Maybe Ref) #

try to resolve a string to a specific commit ref for example: HEAD, HEAD^, master~3, shortRef

initRepo :: FilePath -> IO () #

initialize a new repository at a specific location.

isRepo :: FilePath -> IO Bool #

basic checks to see if a specific path looks like a git repo.

# named refs manipulation

branchWrite #

Arguments

:: Git | repository
-> RefName | the name of the branch to write
-> Ref | the reference to set
-> IO () |

Write a branch to point to a specific reference

branchList :: Git -> IO (Set RefName) #

Return the list of branches

tagWrite #

Arguments

:: Git | repository
-> RefName | the name of the tag to write
-> Ref | the reference to set
-> IO () |

Write a tag to point to a specific reference

tagList :: Git -> IO (Set RefName) #

Return the list of branches

headSet #

Arguments

:: Git | repository
-> Either Ref RefName | either a raw reference or a branch name
-> IO () |

Set head to point to either a reference or a branch name.

headGet :: Git -> IO (Either Ref RefName) #

Get what the head is pointing to, or the reference otherwise