Skip to content

Commit ad20883

Browse files
fpozzobontimvink
authored andcommitted
Add co authors as option
1 parent 0a216e7 commit ad20883

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

docs/options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins:
88
show_contribution: true
99
show_line_count: true
1010
show_email_address: true
11+
add_co_authors: true
1112
href: "mailto:{email}"
1213
count_empty_lines: true
1314
fallback_to_empty: false

src/mkdocs_git_authors_plugin/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class GitAuthorsPluginConfig(Config):
66
show_contribution = config_options.Type(bool, default=False)
77
show_line_count = config_options.Type(bool, default=False)
88
show_email_address = config_options.Type(bool, default=True)
9+
add_co_authors = config_options.Type(bool, default=False)
910
href = config_options.Type(str, default="mailto:{email}")
1011
count_empty_lines = config_options.Type(bool, default=True)
1112
fallback_to_empty = config_options.Type(bool, default=False)

src/mkdocs_git_authors_plugin/git/repo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def get_commit(self, sha: str, **kwargs) -> Union[Any, None]:
116116
if not self._commits.get(sha):
117117
from .commit import Commit
118118

119-
kwargs["co_authors"] = self._get_co_authors(sha)
119+
if self.config("add_co_authors"):
120+
kwargs["co_authors"] = self._get_co_authors(sha)
121+
else:
122+
kwargs["co_authors"] = []
120123
self._commits[sha] = Commit(self, sha, **kwargs)
121124
return self._commits.get(sha)
122125

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
site_name: test gitauthors_plugin
2+
use_directory_urls: true
3+
4+
plugins:
5+
- search
6+
- git-authors:
7+
add_co_authors: true
8+
ignore_authors:
9+
- 'guts@users.noreply.github.com'

tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_ignore_authors_working(tmp_path) -> None:
143143

144144

145145
def test_co_authors_working(tmp_path) -> None:
146-
result = build_docs_setup("tests/basic_setup/mkdocs_ignore_authors.yml", tmp_path)
146+
result = build_docs_setup("tests/basic_setup/mkdocs_add_co_authors.yml", tmp_path)
147147
assert (
148148
result.exit_code == 0
149149
), f"'mkdocs build' command failed. Error: {result.stdout}"

0 commit comments

Comments
 (0)