hit-graph-0.1: Use graph algorithms to access and manipulate Git repos

Safe HaskellNone
LanguageHaskell2010

Data.Git.Graph.Util

Synopsis

Documentation

newtype ObjId Source #

A git object identifier. This is a SHA-1 hash. Its common textual representation is a 40-byte ASCII hexadecimal string.

Constructors

ObjId 

Fields

Instances

Eq ObjId Source # 

Methods

(==) :: ObjId -> ObjId -> Bool #

(/=) :: ObjId -> ObjId -> Bool #

Hashable ObjId Source # 

Methods

hashWithSalt :: Int -> ObjId -> Int #

hash :: ObjId -> Int #

resolveNameMaybe :: Git -> String -> IO (Maybe ObjId) Source #

For a given ref name - HEAD or branch or tag - determine its ref hash.

resolveName :: Git -> String -> IO ObjId Source #

For a given ref name - HEAD or branch or tag - determine its ref hash.

listReferences :: Git -> IO [(ObjId, String)] Source #

List the available references in a git repo, sorted by ref name. The list includes HEAD, branches and tags.

loadCommits Source #

Arguments

:: MonadIO m 
=> Git

Open git repository context

-> ((ObjId, Commit) -> ObjId -> a -> m (a, Maybe Commit))

Given a child commit, one of its parent commits and an a value, generate an updated a value. The second returned value determines whether traversal should proceed to the parent of the parent commit. If you return Nothing, it won't. If you load the parent commit (e.g. with getCommit) and return Just it, traversal will proceed to its parents.

-> a

Initial value

-> ObjId

Hash of the commit whose ancestor graph should be loaded

-> Maybe Commit

If you already read the commit for the ref passed as the previous parameter, pass the commit here to avoid repeated loading of it. Otherwise, pass Nothing and it will be read from the repo.

-> m a 

Load the entire graph of commits which are ancestors of the given ref (and that ref itself). Fold the commit structure into a value of type a inside monad m.

This is a low-level function which operates on a commit tree, i.e. the same ref may be visited more than once (if it has more than one child commit). You can use the provided flexibility to implement graph algorithms over the commits, or build a graph using some graph library and use that library's tools for further processing.

loadCommitsMulti Source #

Arguments

:: MonadIO m 
=> Git

Open git repository context

-> ((ObjId, Commit) -> ObjId -> a -> m (a, Maybe Commit))

Given a child commit, one of its parent commits and an a value, generate an updated a value. The second returned value determines whether traversal should proceed to the parent of the parent commit. If you return Nothing, it won't. If you load the parent commit (e.g. with getCommit) and return Just it, traversal will proceed to its parents.

-> a

Initial value

-> [(ObjId, Maybe Commit)]

Commits whose ancestors to scan. For each commit, pass:

  1. Hash of the commit
  2. If you already loaded the commit from the ref, pass the commit here to avoid repeated loading of it. Otherwise, pass Nothing and it will be read from the repo.
-> m a 

Like loadCommits, but takes a list of refs and goes over all their ancestors. This is just a convenience shortcut which folds a list with loadCommits. Passing a list with a single element is the same as running loadCommits.