def get_commit(self, commit_id: str) -> Commit: """ Get the specified commit. :param str commit_id: hash of the commit to analyze :return: Commit """ return Commit(self.repo.commit(commit_id), self.path, self.main_branch)
def get_head(self) -> Commit: """ Get the head commit. :return: Commit of the head commit """ head_commit = self.repo.head.commit return Commit(head_commit, self._conf)
def get_head(self) -> Commit: """ Get the head commit. :return: Commit of the head commit """ head_commit = self.repo.head.commit return Commit(head_commit, self.path, self.main_branch)
def get_commit(self, commit_id: str) -> Commit: """ Get the specified commit. :param str commit_id: hash of the commit to analyze :return: Commit """ gp_commit = self.repo.commit(commit_id) return Commit(gp_commit, self._conf)
def get_head(self) -> Commit: """ Get the head commit. :return: ChangeSet of the head commit """ repo = self._open_repository() head_commit = repo.head.commit return Commit(head_commit, self.path, self.main_branch)
def get_commit(self, commit_id): """ Get the specified commit. :param str commit_id: hash of the commit to analyze :return: Commit """ repo = self._open_repository() return Commit(repo.commit(commit_id), self.path, self.main_branch)
def get_commit_from_gitpython(self, commit: GitCommit) -> Commit: """ Build a PyDriller commit object from a GitPython commit object. This is internal of PyDriller, I don't think users generally will need it. :param GitCommit commit: GitPython commit :return: Commit commit: PyDriller commit """ return Commit(commit, self._conf)
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
def test_good_proportion(dlo: int, dhi: int, prop: float): assert Commit._good_change_proportion(dlo, dhi) == prop