Ejemplo n.º 1
0
def test_eq_dev():
    d1 = Developer("Davide", "*****@*****.**")
    d2 = Developer("Davide", "*****@*****.**")
    d3 = Developer("Davide", "*****@*****.**")
    d4 = None

    assert d1 == d1
    assert d1 == d2
    assert d1 != d3
    assert d1 != d4
Ejemplo n.º 2
0
    def get_commit(self, commit_id: str) -> Commit:
        """
        Get the specified commit.

        :param commit_id: hash of the commit to analyze
        :return: Commit
        """
        git = self._open_git()
        repo = self._open_repository()
        commit = repo.commit(commit_id)

        author = Developer(commit.author.name, commit.author.email)
        committer = Developer(commit.committer.name, commit.committer.email)
        author_timezone = commit.author_tz_offset
        committer_timezone = commit.committer_tz_offset

        msg = commit.message.strip()
        commit_hash = commit.hexsha

        author_date = commit.authored_datetime
        committer_date = commit.committed_datetime

        merge = True if len(commit.parents) > 1 else False

        parents = []
        for p in commit.parents:
            parents.append(p.hexsha)

        branches = self._get_branches(git, commit_hash)
        is_in_main_branch = self.main_branch in branches

        the_commit = Commit(commit_hash, author, committer, author_date,
                            committer_date, author_timezone,
                            committer_timezone, msg, parents, merge, branches,
                            is_in_main_branch)

        if len(parents) > 0:
            # the commit has a parent
            parent = repo.commit(parents[0])
            diff_index = parent.diff(commit, create_patch=True)
        else:
            # this is the first commit of the repo. Comparing it with git NULL TREE
            parent = repo.tree(NULL_TREE)
            diff_index = parent.diff(commit.tree, create_patch=True)

        self._parse_diff(diff_index, the_commit)

        return the_commit
Ejemplo n.º 3
0
    def committer(self) -> Developer:
        """
        Return the committer of the commit as a Developer object.

        :return: committer
        """
        return Developer(self._c_object.committer.name, self._c_object.committer.email)
Ejemplo n.º 4
0
    def author(self) -> Developer:
        """
        Return the author of the commit as a Developer object.

        :return: author
        """
        return Developer(self._c_object.author.name, self._c_object.author.email)
Ejemplo n.º 5
0
 def __init__(self, hash, msg, name, date):
     self.hash = hash
     self.msg = msg
     self.author = Developer(name, "")
     self.author.name = name
     self.author_date = date
     self.modifications = [
         MockRepositoryMinerCommitModification(),
         MockRepositoryMinerCommitAltModification()
     ]