Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e9ac22

Browse files
committed
Add support for co-author retrieval
1 parent 44410d9 commit 4e9ac22

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

pydriller/domain/commit.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,22 @@ def author(self) -> Developer:
576576
self._c_object.author.name, self._c_object.author.email
577577
)
578578

579+
@property
580+
def co_authors(self) -> List[Developer]:
581+
"""
582+
Return the co-authors of the commit as a list of Developer objects.
583+
584+
:return: List[Developer] author
585+
"""
586+
co_authors = []
587+
for co_author in self._c_object.co_authors:
588+
d = Developer(
589+
co_author.name, co_author.email
590+
)
591+
co_authors.append(d)
592+
593+
return co_authors
594+
579595
@property
580596
def committer(self) -> Developer:
581597
"""

test-repos.zip

4.12 KB
Binary file not shown.

tests/test_commit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,11 @@ def test_modification_dictset(repo: Git):
421421
assert isinstance(mod_set, set)
422422
assert m1 in mod_set
423423
assert mod_set - {m1} == set(m2s)
424+
425+
426+
@pytest.mark.parametrize('repo', ['test-repos/multiple_authors'], indirect=True)
427+
def test_co_authors(repo: Git):
428+
c1 = repo.get_commit('a455e6c8ba6960aa8b89bd0fd5f9abefcd10bcd6')
429+
430+
assert c1.co_authors[0].name == "Somebody"
431+
assert c1.co_authors[0].email == "[email protected]"

0 commit comments

Comments
 (0)