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

Safe HaskellNone
LanguageHaskell2010

Data.Git.Graph

Synopsis

Documentation

type NodeLabel = (ObjId, Commit) Source #

Each node in the commit graph represents a commit.

type EdgeLabel = Down Int Source #

Edges are tagged by numbers defining the order of parents of a commit. For each commit, the out-edges pointing to its parents are numbered according to the order in which the parents were specified in the commitParents field.

The Down wrapper reverses the comparison (the Ord instance), so that merged-from branches are inserted earlier into the sorted list than merged-to branches.

loadCommitGraph :: Graph g => Git -> [ObjId] -> IO (CommitGraph g) Source #

Build a directed acyclic graph of commits. The commits in the graph are the ones specified, and all their ancestors. The edges point from a commit to its parents.

type Depth = Int Source #

commitDepths :: Graph g => CommitGraph g -> [(Node, Depth)] Source #

Determine the depths of all the commits in the graph. Orphan commits (i.e. which don't have parents are assigned depth 1, and any other commit gets a higher depth. A commit's depth depends on the length of the shortest path between that commit and any of the orphan commits.

filterDepth :: DynGraph g => Depth -> CommitGraph g -> CommitGraph g Source #

Return a subgraph containing only commits whose depth is up to the depth specified.

partitionDepth :: Graph g => CommitGraph g -> HashMap Node Depth -> Depth -> ([LNode NodeLabel], [LNode NodeLabel], [LNode NodeLabel]) Source #

Given a depth threshold D, the commits in the graph can be partitioned into 3 groups:

  1. Commits at depth D or below, whose parents (if any) are all present in the graph and as well at depth D or below
  2. Commits at depth D which have parents, and the parents are at depth D+1 or missing from the graph
  3. Commits at depth D+1 or above

In this library, these groups are called healthy, shallow and excluded respectively.

isHealthy :: Graph g => CommitGraph g -> HashMap Node Depth -> Depth -> Node -> Bool Source #

Determine whether a given commit is healthy (see partitionDepth).

isShallow :: Graph g => CommitGraph g -> HashMap Node Depth -> Depth -> Node -> Bool Source #

Determine whether a given commit is shallow (see partitionDepth).

isExcluded :: Graph g => CommitGraph g -> HashMap Node Depth -> Depth -> Node -> Bool Source #

Determine whether a given commit is excluded (see partitionDepth).