Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 868 Bytes

README.md

File metadata and controls

23 lines (18 loc) · 868 Bytes

Git repository organization

Given a git repository, the commits can be thought of as having the structure of a directed acyclic graph (DAG) with the commits being the vertices. There is a directed edge from each child commit to each of its parent commits, and a directed edge from each parent to each of its children.

The shell script:

  1. Discovers the .git directory.
  2. Gets the list of local branch names.
  3. Builds the commit graph. Each commit can be represented as an instance of the CommitNode class, which is defined as follows:
class CommitNode:
    def __init__(self, commit_hash):
        """
        :type commit_hash: str
        """
        self.commit_hash = commit_hash
        self.parents = set()
        self.children = set()
  1. Generates a topological ordering of the commits in the graph.
  2. Prints the commit hashes in order.