summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2022-08-25 09:42:50 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2022-08-25 09:42:50 +0800
commit73bde1f27711e48bd887b5a13cd5e3a0a8d9d723 (patch)
treec2379ccfe94deec08d37ebe2e9a0ba6ab3a75e49 /git
parent12d91c6459422c034b790c8bcc5e429aa3a42c3b (diff)
parent72cf71cb3e9d0458dc27158ecb67d8dd4f26af04 (diff)
downloadgitpython-73bde1f27711e48bd887b5a13cd5e3a0a8d9d723.tar.gz
Merge branch 'add-co-authors'
Diffstat (limited to 'git')
-rw-r--r--git/config.py2
-rw-r--r--git/objects/commit.py22
2 files changed, 23 insertions, 1 deletions
diff --git a/git/config.py b/git/config.py
index 5f07cb00..71d7ea68 100644
--- a/git/config.py
+++ b/git/config.py
@@ -84,7 +84,7 @@ CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")
CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"")
-class MetaParserBuilder(abc.ABCMeta):
+class MetaParserBuilder(abc.ABCMeta): # noqa: B024
"""Utility class wrapping base-class methods into decorators that assure read-only properties"""
def __new__(cls, name: str, bases: Tuple, clsdict: Dict[str, Any]) -> "MetaParserBuilder":
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