Exemple #1
0
    def __init__(self,
                 directory=".",
                 fake_branch_name="",
                 from_commits=False,
                 remote_ref=None):
        """
            Initializes the model with the repository root directory.

            :param directory:
                Root directory of the git repository.
        """
        self._directory = directory

        self._remote_ref = False
        self._current_branch = None

        if fake_branch_name:
            # This is an empy gitModel that will be filled with data from
            # another model
            self._repo = None
            self._current_branch = DummyBranch(fake_branch_name)

            if not from_commits:
                raise GfbiException("Can't build a fake model without commits")

            self._from_commits = from_commits
        elif remote_ref:
            # This is a model on a remote repository
            self._repo = Repo(directory)
            self._remote_ref = remote_ref
            self._current_branch = False
        else:
            self._repo = Repo(directory)
            self._current_branch = self._repo.active_branch

        self._columns = [
            'hexsha', 'authored_date', 'committed_date', 'author_name',
            'author_email', 'committer_name', 'committer_email', 'message',
            'parents', 'tree', 'children'
        ]

        self._changed_branch_once = False
        self._commits = []
        self._unpushed = []
        self._children = {}

        self._old_branch_name = ""