mkdocs-git-authors-plugin 0.9.3__tar.gz → 0.9.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/PKG-INFO +4 -3
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/README.md +1 -1
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/pyproject.toml +4 -1
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/git/page.py +22 -2
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/plugin.py +23 -12
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin.egg-info/PKG-INFO +4 -3
- mkdocs_git_authors_plugin-0.9.5/src/mkdocs_git_authors_plugin.egg-info/SOURCES.txt +23 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/tests/test_util.py +200 -3
- mkdocs_git_authors_plugin-0.9.3/mkdocs_git_authors_plugin.egg-info/SOURCES.txt +0 -23
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/LICENSE +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/setup.cfg +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/__init__.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/ci.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/config.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/exclude.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/git/__init__.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/git/author.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/git/command.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/git/commit.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/git/repo.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin/util.py +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin.egg-info/dependency_links.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin.egg-info/entry_points.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin.egg-info/requires.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5/src}/mkdocs_git_authors_plugin.egg-info/top_level.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.3 → mkdocs_git_authors_plugin-0.9.5}/tests/test_basic.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-git-authors-plugin
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.5
|
|
4
4
|
Summary: Mkdocs plugin to display git authors of a page
|
|
5
5
|
Author-email: Tim Vink <vinktim@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -23,6 +23,7 @@ Requires-Python: >=3.8
|
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
Requires-Dist: mkdocs>=1.0
|
|
26
|
+
Dynamic: license-file
|
|
26
27
|
|
|
27
28
|
[](https://github.com/timvink/mkdocs-git-authors-plugin/actions)
|
|
28
29
|

|
|
@@ -72,7 +73,7 @@ This plugin needs access to the last commit that touched a specific file to be a
|
|
|
72
73
|
<summary>Change your CI settings</summary>
|
|
73
74
|
|
|
74
75
|
- github actions: set `fetch_depth` to `0` ([docs](https://github.com/actions/checkout))
|
|
75
|
-
- gitlab runners: set `GIT_DEPTH` to `
|
|
76
|
+
- gitlab runners: set `GIT_DEPTH` to `0` ([docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone))
|
|
76
77
|
- bitbucket pipelines: set `clone: depth: full` ([docs](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/))
|
|
77
78
|
</details>
|
|
78
79
|
|
|
@@ -46,7 +46,7 @@ This plugin needs access to the last commit that touched a specific file to be a
|
|
|
46
46
|
<summary>Change your CI settings</summary>
|
|
47
47
|
|
|
48
48
|
- github actions: set `fetch_depth` to `0` ([docs](https://github.com/actions/checkout))
|
|
49
|
-
- gitlab runners: set `GIT_DEPTH` to `
|
|
49
|
+
- gitlab runners: set `GIT_DEPTH` to `0` ([docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone))
|
|
50
50
|
- bitbucket pipelines: set `clone: depth: full` ([docs](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/))
|
|
51
51
|
</details>
|
|
52
52
|
|
|
@@ -12,7 +12,7 @@ authors = [
|
|
|
12
12
|
]
|
|
13
13
|
keywords = ["mkdocs", "git", "contributors", "committers", "authors", "plugin"]
|
|
14
14
|
urls = {Homepage = "https://github.com/timvink/mkdocs-git-authors-plugin"}
|
|
15
|
-
version = "0.9.
|
|
15
|
+
version = "0.9.5"
|
|
16
16
|
requires-python = ">=3.8"
|
|
17
17
|
dependencies = ["mkdocs>=1.0"]
|
|
18
18
|
classifiers = [
|
|
@@ -34,6 +34,9 @@ classifiers = [
|
|
|
34
34
|
[project.entry-points."mkdocs.plugins"]
|
|
35
35
|
git-authors = "mkdocs_git_authors_plugin.plugin:GitAuthorsPlugin"
|
|
36
36
|
|
|
37
|
+
[tool.setuptools]
|
|
38
|
+
package-dir = {"" = "src"}
|
|
39
|
+
|
|
37
40
|
[dependency-groups]
|
|
38
41
|
dev = [
|
|
39
42
|
"click>=8.1.8",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import re
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import List
|
|
4
|
+
from typing import Any, List
|
|
5
5
|
|
|
6
6
|
from mkdocs_git_authors_plugin.git.command import GitCommand, GitCommandError
|
|
7
7
|
from mkdocs_git_authors_plugin.git.repo import AbstractRepoObject, Repo
|
|
@@ -73,7 +73,7 @@ class Page(AbstractRepoObject):
|
|
|
73
73
|
or repo.config("show_contribution")
|
|
74
74
|
or repo.config("sort_authors_by") == "contribution"
|
|
75
75
|
)
|
|
76
|
-
self._authors = sorted(self._authors, key=
|
|
76
|
+
self._authors = sorted(self._authors, key=self._sort_key, reverse=reverse)
|
|
77
77
|
self._sorted = True
|
|
78
78
|
author_threshold = repo.config("authorship_threshold_percent")
|
|
79
79
|
if author_threshold > 0 and len(self._authors) > 1:
|
|
@@ -210,6 +210,26 @@ class Page(AbstractRepoObject):
|
|
|
210
210
|
"""
|
|
211
211
|
return self._path
|
|
212
212
|
|
|
213
|
+
def _sort_key(self, author) -> Any:
|
|
214
|
+
"""
|
|
215
|
+
Return a sort key for an author.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
author: an Author object
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
comparison key for the sorted() function,
|
|
222
|
+
"""
|
|
223
|
+
repo = self.repo()
|
|
224
|
+
if (
|
|
225
|
+
repo.config("show_line_count")
|
|
226
|
+
or repo.config("show_contribution")
|
|
227
|
+
or repo.config("sort_authors_by") == "contribution"
|
|
228
|
+
):
|
|
229
|
+
return getattr(author, "contribution")(self.path())
|
|
230
|
+
else:
|
|
231
|
+
return getattr(author, "name")()
|
|
232
|
+
|
|
213
233
|
def total_lines(self) -> int:
|
|
214
234
|
"""
|
|
215
235
|
Total number of lines in the markdown source file.
|
|
@@ -58,21 +58,32 @@ class GitAuthorsPlugin(BasePlugin[GitAuthorsPluginConfig]):
|
|
|
58
58
|
assert self.config.authorship_threshold_percent >= 0
|
|
59
59
|
assert self.config.authorship_threshold_percent <= 100
|
|
60
60
|
|
|
61
|
+
self._fallback = False
|
|
62
|
+
# Find the git repository in the current working directory
|
|
61
63
|
try:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
self.
|
|
64
|
+
self._repo = Repo()
|
|
65
|
+
except GitCommandError:
|
|
66
|
+
self._repo = None
|
|
67
|
+
|
|
68
|
+
# Try finding the git repository inside the documentation directory
|
|
69
|
+
if self._repo is None:
|
|
70
|
+
try:
|
|
71
|
+
with working_directory(config.get("docs_dir", ".")):
|
|
72
|
+
self._repo = Repo()
|
|
73
|
+
except GitCommandError:
|
|
74
|
+
if self.config.fallback_to_empty:
|
|
75
|
+
self._fallback = True
|
|
76
|
+
logger.warning(
|
|
77
|
+
"[git-authors-plugin] Unable to find a git directory and/or git is not installed."
|
|
78
|
+
" Option 'fallback_to_empty' set to 'true': Falling back to empty authors list"
|
|
79
|
+
)
|
|
80
|
+
else:
|
|
81
|
+
raise
|
|
82
|
+
|
|
83
|
+
if self._repo is not None:
|
|
65
84
|
self.repo().set_config(self.config)
|
|
66
85
|
raise_ci_warnings(path=self.repo()._root)
|
|
67
|
-
|
|
68
|
-
if self.config.fallback_to_empty:
|
|
69
|
-
self._fallback = True
|
|
70
|
-
logger.warning(
|
|
71
|
-
"[git-authors-plugin] Unable to find a git directory and/or git is not installed."
|
|
72
|
-
" Option 'fallback_to_empty' set to 'true': Falling back to empty authors list"
|
|
73
|
-
)
|
|
74
|
-
else:
|
|
75
|
-
raise
|
|
86
|
+
|
|
76
87
|
|
|
77
88
|
def on_files(
|
|
78
89
|
self, files: Files, *, config: MkDocsConfig, **kwargs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-git-authors-plugin
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.5
|
|
4
4
|
Summary: Mkdocs plugin to display git authors of a page
|
|
5
5
|
Author-email: Tim Vink <vinktim@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -23,6 +23,7 @@ Requires-Python: >=3.8
|
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
Requires-Dist: mkdocs>=1.0
|
|
26
|
+
Dynamic: license-file
|
|
26
27
|
|
|
27
28
|
[](https://github.com/timvink/mkdocs-git-authors-plugin/actions)
|
|
28
29
|

|
|
@@ -72,7 +73,7 @@ This plugin needs access to the last commit that touched a specific file to be a
|
|
|
72
73
|
<summary>Change your CI settings</summary>
|
|
73
74
|
|
|
74
75
|
- github actions: set `fetch_depth` to `0` ([docs](https://github.com/actions/checkout))
|
|
75
|
-
- gitlab runners: set `GIT_DEPTH` to `
|
|
76
|
+
- gitlab runners: set `GIT_DEPTH` to `0` ([docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone))
|
|
76
77
|
- bitbucket pipelines: set `clone: depth: full` ([docs](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/))
|
|
77
78
|
</details>
|
|
78
79
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/mkdocs_git_authors_plugin/__init__.py
|
|
5
|
+
src/mkdocs_git_authors_plugin/ci.py
|
|
6
|
+
src/mkdocs_git_authors_plugin/config.py
|
|
7
|
+
src/mkdocs_git_authors_plugin/exclude.py
|
|
8
|
+
src/mkdocs_git_authors_plugin/plugin.py
|
|
9
|
+
src/mkdocs_git_authors_plugin/util.py
|
|
10
|
+
src/mkdocs_git_authors_plugin.egg-info/PKG-INFO
|
|
11
|
+
src/mkdocs_git_authors_plugin.egg-info/SOURCES.txt
|
|
12
|
+
src/mkdocs_git_authors_plugin.egg-info/dependency_links.txt
|
|
13
|
+
src/mkdocs_git_authors_plugin.egg-info/entry_points.txt
|
|
14
|
+
src/mkdocs_git_authors_plugin.egg-info/requires.txt
|
|
15
|
+
src/mkdocs_git_authors_plugin.egg-info/top_level.txt
|
|
16
|
+
src/mkdocs_git_authors_plugin/git/__init__.py
|
|
17
|
+
src/mkdocs_git_authors_plugin/git/author.py
|
|
18
|
+
src/mkdocs_git_authors_plugin/git/command.py
|
|
19
|
+
src/mkdocs_git_authors_plugin/git/commit.py
|
|
20
|
+
src/mkdocs_git_authors_plugin/git/page.py
|
|
21
|
+
src/mkdocs_git_authors_plugin/git/repo.py
|
|
22
|
+
tests/test_basic.py
|
|
23
|
+
tests/test_util.py
|
|
@@ -31,12 +31,19 @@ DEFAULT_CONFIG = {
|
|
|
31
31
|
"show_contribution": False,
|
|
32
32
|
"show_line_count": False,
|
|
33
33
|
"show_email_address": True,
|
|
34
|
+
"href": "mailto:{email}",
|
|
34
35
|
"count_empty_lines": True,
|
|
35
|
-
"
|
|
36
|
-
"
|
|
36
|
+
"fallback_to_empty": False,
|
|
37
|
+
"exclude": [],
|
|
38
|
+
"ignore_commits": "",
|
|
39
|
+
"ignore_authors": [],
|
|
40
|
+
"enabled": True,
|
|
41
|
+
"enabled_on_serve": True,
|
|
37
42
|
"sort_authors_by": "name",
|
|
38
43
|
"authorship_threshold_percent": 0,
|
|
39
|
-
"
|
|
44
|
+
"strict": True,
|
|
45
|
+
#"sort_authors_by_name": True,
|
|
46
|
+
#"sort_reverse": False,
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
#### Helpers ####
|
|
@@ -129,6 +136,16 @@ def setup_commit_history(testproject_path):
|
|
|
129
136
|
return repo
|
|
130
137
|
|
|
131
138
|
|
|
139
|
+
def commit_lines(r, file_name, author_name, author_email, num_of_lines=1):
|
|
140
|
+
with open(file_name, "a") as the_file:
|
|
141
|
+
for i in range(num_of_lines):
|
|
142
|
+
the_file.write("Hello\n")
|
|
143
|
+
|
|
144
|
+
r.index.add([file_name])
|
|
145
|
+
author = gitpython.Actor(author_name, author_email)
|
|
146
|
+
r.index.commit("some commit", author=author)
|
|
147
|
+
|
|
148
|
+
|
|
132
149
|
#### Tests ####
|
|
133
150
|
|
|
134
151
|
|
|
@@ -477,6 +494,186 @@ def test_mkdocs_in_git_subdir(tmp_path):
|
|
|
477
494
|
os.chdir(cwd)
|
|
478
495
|
|
|
479
496
|
|
|
497
|
+
def test_page_authors_summary(tmp_path):
|
|
498
|
+
"""
|
|
499
|
+
Builds a fake git project with some commits.
|
|
500
|
+
|
|
501
|
+
Args:
|
|
502
|
+
tmp_path (PosixPath): Directory of a tempdir
|
|
503
|
+
"""
|
|
504
|
+
cwd = os.getcwd()
|
|
505
|
+
os.chdir(str(tmp_path))
|
|
506
|
+
|
|
507
|
+
config = DEFAULT_CONFIG.copy()
|
|
508
|
+
|
|
509
|
+
# Create a git repo and file
|
|
510
|
+
r = gitpython.Repo.init(tmp_path)
|
|
511
|
+
file_name = str(tmp_path / "new-file")
|
|
512
|
+
|
|
513
|
+
# Initial commit
|
|
514
|
+
commit_lines(r, file_name, "Tim", "abc@abc.com")
|
|
515
|
+
|
|
516
|
+
repo_instance = repo.Repo()
|
|
517
|
+
repo_instance.set_config(config)
|
|
518
|
+
page_instance = repo_instance.page(file_name)
|
|
519
|
+
|
|
520
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
521
|
+
|
|
522
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
523
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"\
|
|
524
|
+
"</span>"
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
# Now add a line to the file
|
|
528
|
+
# From a second author with same email
|
|
529
|
+
commit_lines(r, file_name, "Tim2", "abc@abc.com")
|
|
530
|
+
|
|
531
|
+
repo_instance = repo.Repo()
|
|
532
|
+
repo_instance.set_config(config)
|
|
533
|
+
page_instance = repo_instance.page(file_name)
|
|
534
|
+
|
|
535
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
536
|
+
|
|
537
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
538
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"\
|
|
539
|
+
"</span>"
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
# Then a third commit from a new author
|
|
543
|
+
commit_lines(r, file_name, "John", "john@abc.com")
|
|
544
|
+
|
|
545
|
+
repo_instance = repo.Repo()
|
|
546
|
+
repo_instance.set_config(config)
|
|
547
|
+
page_instance = repo_instance.page(file_name)
|
|
548
|
+
|
|
549
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
550
|
+
|
|
551
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
552
|
+
"<a href='mailto:john@abc.com'>John</a>, "\
|
|
553
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"\
|
|
554
|
+
"</span>"
|
|
555
|
+
|
|
556
|
+
os.chdir(cwd)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
def test_page_authors_summary_showing_contribution(tmp_path):
|
|
560
|
+
"""
|
|
561
|
+
Builds a fake git project with some commits.
|
|
562
|
+
|
|
563
|
+
Args:
|
|
564
|
+
tmp_path (PosixPath): Directory of a tempdir
|
|
565
|
+
"""
|
|
566
|
+
cwd = os.getcwd()
|
|
567
|
+
os.chdir(str(tmp_path))
|
|
568
|
+
|
|
569
|
+
config = DEFAULT_CONFIG.copy()
|
|
570
|
+
config["show_contribution"] = True
|
|
571
|
+
|
|
572
|
+
# Create a git repo and file
|
|
573
|
+
r = gitpython.Repo.init(tmp_path)
|
|
574
|
+
file_name = str(tmp_path / "new-file")
|
|
575
|
+
|
|
576
|
+
# Initial commit
|
|
577
|
+
commit_lines(r, file_name, "Tim", "abc@abc.com")
|
|
578
|
+
|
|
579
|
+
repo_instance = repo.Repo()
|
|
580
|
+
repo_instance.set_config(config)
|
|
581
|
+
page_instance = repo_instance.page(file_name)
|
|
582
|
+
|
|
583
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
584
|
+
|
|
585
|
+
# Contribution is not shown if there is only single Author
|
|
586
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
587
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"\
|
|
588
|
+
"</span>"
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
# Now add a line to the file
|
|
592
|
+
# From a second author with same email
|
|
593
|
+
commit_lines(r, file_name, "Tim2", "abc@abc.com")
|
|
594
|
+
|
|
595
|
+
repo_instance = repo.Repo()
|
|
596
|
+
repo_instance.set_config(config)
|
|
597
|
+
page_instance = repo_instance.page(file_name)
|
|
598
|
+
|
|
599
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
600
|
+
|
|
601
|
+
# Contribution is not shown if there is only single Author
|
|
602
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
603
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"\
|
|
604
|
+
"</span>"
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
# Then a third commit from a new author
|
|
608
|
+
commit_lines(r, file_name, "John", "john@abc.com")
|
|
609
|
+
|
|
610
|
+
repo_instance = repo.Repo()
|
|
611
|
+
repo_instance.set_config(config)
|
|
612
|
+
page_instance = repo_instance.page(file_name)
|
|
613
|
+
|
|
614
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
615
|
+
|
|
616
|
+
# Contribution is shown if there are multiple authors, ordered by contribution
|
|
617
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
618
|
+
"<a href='mailto:abc@abc.com'>Tim</a> (66.67%), "\
|
|
619
|
+
"<a href='mailto:john@abc.com'>John</a> (33.33%)"\
|
|
620
|
+
"</span>"
|
|
621
|
+
|
|
622
|
+
os.chdir(cwd)
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
def test_page_authors_summary_showing_contribution_ordering_by_page_contribution(tmp_path):
|
|
626
|
+
"""
|
|
627
|
+
Builds a fake git project with some commits.
|
|
628
|
+
|
|
629
|
+
Args:
|
|
630
|
+
tmp_path (PosixPath): Directory of a tempdir
|
|
631
|
+
"""
|
|
632
|
+
cwd = os.getcwd()
|
|
633
|
+
os.chdir(str(tmp_path))
|
|
634
|
+
|
|
635
|
+
config = DEFAULT_CONFIG.copy()
|
|
636
|
+
config["show_contribution"] = True
|
|
637
|
+
|
|
638
|
+
# Create a git repo and files
|
|
639
|
+
r = gitpython.Repo.init(tmp_path)
|
|
640
|
+
file_name = str(tmp_path / "new-file")
|
|
641
|
+
file_name2 = str(tmp_path / "new-file2")
|
|
642
|
+
|
|
643
|
+
# Commits by multiple authors on multiple files
|
|
644
|
+
commit_lines(r, file_name, "Tim", "tim@abc.com", 8)
|
|
645
|
+
commit_lines(r, file_name, "John", "john@abc.com", 4)
|
|
646
|
+
commit_lines(r, file_name, "Thomas", "thomas@abc.com", 2)
|
|
647
|
+
|
|
648
|
+
commit_lines(r, file_name2, "Tim", "tim@abc.com", 4)
|
|
649
|
+
commit_lines(r, file_name2, "John", "john@abc.com", 16)
|
|
650
|
+
commit_lines(r, file_name2, "Thomas", "thomas@abc.com", 8)
|
|
651
|
+
|
|
652
|
+
repo_instance = repo.Repo()
|
|
653
|
+
repo_instance.set_config(config)
|
|
654
|
+
page_instance = repo_instance.page(file_name)
|
|
655
|
+
page_instance2 = repo_instance.page(file_name2)
|
|
656
|
+
|
|
657
|
+
authors_summary = util.page_authors_summary(page_instance, config)
|
|
658
|
+
|
|
659
|
+
# Contribution is shown if there are multiple authors, ordered by contribution on page
|
|
660
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
661
|
+
"<a href='mailto:tim@abc.com'>Tim</a> (57.14%), "\
|
|
662
|
+
"<a href='mailto:john@abc.com'>John</a> (28.57%), "\
|
|
663
|
+
"<a href='mailto:thomas@abc.com'>Thomas</a> (14.29%)"\
|
|
664
|
+
"</span>"
|
|
665
|
+
|
|
666
|
+
authors_summary = util.page_authors_summary(page_instance2, config)
|
|
667
|
+
|
|
668
|
+
assert authors_summary == "<span class='git-page-authors git-authors'>"\
|
|
669
|
+
"<a href='mailto:john@abc.com'>John</a> (57.14%), "\
|
|
670
|
+
"<a href='mailto:thomas@abc.com'>Thomas</a> (28.57%), "\
|
|
671
|
+
"<a href='mailto:tim@abc.com'>Tim</a> (14.29%)"\
|
|
672
|
+
"</span>"
|
|
673
|
+
|
|
674
|
+
os.chdir(cwd)
|
|
675
|
+
|
|
676
|
+
|
|
480
677
|
def test_summarize_authors():
|
|
481
678
|
"""
|
|
482
679
|
Test summary functions.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
mkdocs_git_authors_plugin/__init__.py
|
|
5
|
-
mkdocs_git_authors_plugin/ci.py
|
|
6
|
-
mkdocs_git_authors_plugin/config.py
|
|
7
|
-
mkdocs_git_authors_plugin/exclude.py
|
|
8
|
-
mkdocs_git_authors_plugin/plugin.py
|
|
9
|
-
mkdocs_git_authors_plugin/util.py
|
|
10
|
-
mkdocs_git_authors_plugin.egg-info/PKG-INFO
|
|
11
|
-
mkdocs_git_authors_plugin.egg-info/SOURCES.txt
|
|
12
|
-
mkdocs_git_authors_plugin.egg-info/dependency_links.txt
|
|
13
|
-
mkdocs_git_authors_plugin.egg-info/entry_points.txt
|
|
14
|
-
mkdocs_git_authors_plugin.egg-info/requires.txt
|
|
15
|
-
mkdocs_git_authors_plugin.egg-info/top_level.txt
|
|
16
|
-
mkdocs_git_authors_plugin/git/__init__.py
|
|
17
|
-
mkdocs_git_authors_plugin/git/author.py
|
|
18
|
-
mkdocs_git_authors_plugin/git/command.py
|
|
19
|
-
mkdocs_git_authors_plugin/git/commit.py
|
|
20
|
-
mkdocs_git_authors_plugin/git/page.py
|
|
21
|
-
mkdocs_git_authors_plugin/git/repo.py
|
|
22
|
-
tests/test_basic.py
|
|
23
|
-
tests/test_util.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|