diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2022-08-25 09:42:50 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2022-08-25 09:42:50 +0800 |
commit | 73bde1f27711e48bd887b5a13cd5e3a0a8d9d723 (patch) | |
tree | c2379ccfe94deec08d37ebe2e9a0ba6ab3a75e49 /git/objects/commit.py | |
parent | 12d91c6459422c034b790c8bcc5e429aa3a42c3b (diff) | |
parent | 72cf71cb3e9d0458dc27158ecb67d8dd4f26af04 (diff) | |
download | gitpython-73bde1f27711e48bd887b5a13cd5e3a0a8d9d723.tar.gz |
Merge branch 'add-co-authors'
Diffstat (limited to 'git/objects/commit.py')
-rw-r--r-- | git/objects/commit.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py index 66cb9191..cf7d9aaa 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -4,6 +4,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php import datetime +import re from subprocess import Popen, PIPE from gitdb import IStream from git.util import hex_to_bin, Actor, Stats, finalize_process @@ -738,3 +739,24 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable): return self # } END serializable implementation + + @property + def co_authors(self) -> List[Actor]: + """ + Search the commit message for any co-authors of this commit. + Details on co-authors: https://github.blog/2018-01-29-commit-together-with-co-authors/ + + :return: List of co-authors for this commit (as Actor objects). + """ + co_authors = [] + + if self.message: + results = re.findall( + r"^Co-authored-by: (.*) <(.*?)>$", + self.message, + re.MULTILINE, + ) + for author in results: + co_authors.append(Actor(*author)) + + return co_authors |