Skip to content

Commit 73bde1f

Browse files
committed
Merge branch 'add-co-authors'
2 parents 12d91c6 + 72cf71c commit 73bde1f

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

‎AUTHORS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ Contributors are:
4848
-Hiroki Tokunaga <tokusan441 _at_ gmail.com>
4949
-Julien Mauroy <pro.julien.mauroy _at_ gmail.com>
5050
-Patrick Gerard
51+
-Luke Twist <[email protected]>
5152
Portions derived from other open source works and are clearly marked.

‎git/config.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
CONDITIONAL_INCLUDE_REGEXP=re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"")
8585

8686

87-
classMetaParserBuilder(abc.ABCMeta):
87+
classMetaParserBuilder(abc.ABCMeta):# noqa: B024
8888
"""Utility class wrapping base-class methods into decorators that assure read-only properties"""
8989

9090
def__new__(cls, name: str, bases: Tuple, clsdict: Dict[str, Any]) ->"MetaParserBuilder":

‎git/objects/commit.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
importdatetime
7+
importre
78
fromsubprocessimportPopen, PIPE
89
fromgitdbimportIStream
910
fromgit.utilimporthex_to_bin, Actor, Stats, finalize_process
@@ -738,3 +739,24 @@ def _deserialize(self, stream: BytesIO) -> "Commit":
738739
returnself
739740

740741
# } END serializable implementation
742+
743+
@property
744+
defco_authors(self) ->List[Actor]:
745+
"""
746+
Search the commit message for any co-authors of this commit.
747+
Details on co-authors: https://github.blog/2018-01-29-commit-together-with-co-authors/
748+
749+
:return: List of co-authors for this commit (as Actor objects).
750+
"""
751+
co_authors= []
752+
753+
ifself.message:
754+
results=re.findall(
755+
r"^Co-authored-by: (.*) <(.*?)>$",
756+
self.message,
757+
re.MULTILINE,
758+
)
759+
forauthorinresults:
760+
co_authors.append(Actor(*author))
761+
762+
returnco_authors

‎test/test_commit.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,3 +509,18 @@ def test_trailers(self):
509509
assertKEY_1notincommit.trailers.keys()
510510
assertKEY_2incommit.trailers.keys()
511511
assertcommit.trailers[KEY_2] ==VALUE_2
512+
513+
deftest_commit_co_authors(self):
514+
commit=copy.copy(self.rorepo.commit("4251bd5"))
515+
commit.message="""Commit message
516+
517+
Co-authored-by: Test User 1 <[email protected]>
518+
Co-authored-by: test_user_2 <[email protected]>
519+
Co_authored_by: test_user_x <[email protected]>
520+
Co-authored-by: test_user_y <[email protected]> text
521+
Co-authored-by: test_user_3 <[email protected]>"""
522+
assertcommit.co_authors== [
523+
Actor("Test User 1", "[email protected]"),
524+
Actor("test_user_2", "[email protected]"),
525+
Actor("test_user_3", "[email protected]"),
526+
]

‎test/test_util.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
importos
88
importpickle
9+
importsys
910
importtempfile
1011
importtime
1112
fromunittestimportmock, skipIf
1213
fromdatetimeimportdatetime
1314

15+
importpytest
1416
importddt
1517

1618
fromgit.cmdimportdashify
@@ -154,6 +156,11 @@ def test_lock_file(self):
154156
lock_file._obtain_lock_or_raise()
155157
lock_file._release_lock()
156158

159+
@pytest.mark.xfail(
160+
sys.platform=="cygwin",
161+
reason="Cygwin fails here for some reason, always",
162+
raises=AssertionError
163+
)
157164
deftest_blocking_lock_file(self):
158165
my_file=tempfile.mktemp()
159166
lock_file=BlockingLockFile(my_file)

0 commit comments

Comments
(0)