mkdocs-git-authors-plugin 0.9.5__tar.gz → 0.10.0__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.5/src/mkdocs_git_authors_plugin.egg-info → mkdocs_git_authors_plugin-0.10.0}/PKG-INFO +1 -1
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/pyproject.toml +1 -1
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/config.py +1 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/git/commit.py +14 -1
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/git/page.py +19 -10
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/git/repo.py +70 -2
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0/src/mkdocs_git_authors_plugin.egg-info}/PKG-INFO +1 -1
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/tests/test_basic.py +25 -8
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/tests/test_util.py +61 -42
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/LICENSE +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/README.md +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/setup.cfg +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/__init__.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/ci.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/exclude.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/git/__init__.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/git/author.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/git/command.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/plugin.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin/util.py +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin.egg-info/SOURCES.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin.egg-info/dependency_links.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin.egg-info/entry_points.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin.egg-info/requires.txt +0 -0
- {mkdocs_git_authors_plugin-0.9.5 → mkdocs_git_authors_plugin-0.10.0}/src/mkdocs_git_authors_plugin.egg-info/top_level.txt +0 -0
|
@@ -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.
|
|
15
|
+
version = "0.10.0"
|
|
16
16
|
requires-python = ">=3.8"
|
|
17
17
|
dependencies = ["mkdocs>=1.0"]
|
|
18
18
|
classifiers = [
|
|
@@ -6,6 +6,7 @@ class GitAuthorsPluginConfig(Config):
|
|
|
6
6
|
show_contribution = config_options.Type(bool, default=False)
|
|
7
7
|
show_line_count = config_options.Type(bool, default=False)
|
|
8
8
|
show_email_address = config_options.Type(bool, default=True)
|
|
9
|
+
add_co_authors = config_options.Type(bool, default=False)
|
|
9
10
|
href = config_options.Type(str, default="mailto:{email}")
|
|
10
11
|
count_empty_lines = config_options.Type(bool, default=True)
|
|
11
12
|
fallback_to_empty = config_options.Type(bool, default=False)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from typing import Union
|
|
2
|
+
from typing import Any, Union, List
|
|
3
3
|
|
|
4
4
|
from mkdocs_git_authors_plugin import util
|
|
5
5
|
from mkdocs_git_authors_plugin.git.repo import AbstractRepoObject, Repo
|
|
@@ -24,6 +24,7 @@ class Commit(AbstractRepoObject):
|
|
|
24
24
|
author_time: str,
|
|
25
25
|
author_tz: str,
|
|
26
26
|
summary: str,
|
|
27
|
+
co_authors: List[Any],
|
|
27
28
|
):
|
|
28
29
|
"""Initialize a commit from its SHA.
|
|
29
30
|
|
|
@@ -48,6 +49,7 @@ class Commit(AbstractRepoObject):
|
|
|
48
49
|
self._datetime = util.commit_datetime(author_time, author_tz)
|
|
49
50
|
self._datetime_string = util.commit_datetime_string(self._datetime)
|
|
50
51
|
self._summary = summary
|
|
52
|
+
self._co_authors = co_authors
|
|
51
53
|
|
|
52
54
|
def author(self):
|
|
53
55
|
"""
|
|
@@ -60,6 +62,17 @@ class Commit(AbstractRepoObject):
|
|
|
60
62
|
"""
|
|
61
63
|
return self._author
|
|
62
64
|
|
|
65
|
+
def co_authors(self):
|
|
66
|
+
"""
|
|
67
|
+
The commit's co-author.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Co-Authors list
|
|
73
|
+
"""
|
|
74
|
+
return self._co_authors
|
|
75
|
+
|
|
63
76
|
def datetime(self, _type=str) -> Union[str, util.datetime]:
|
|
64
77
|
"""
|
|
65
78
|
The commit's commit time.
|
|
@@ -149,7 +149,7 @@ class Page(AbstractRepoObject):
|
|
|
149
149
|
args.append("--ignore-revs-file")
|
|
150
150
|
args.append(self.repo().config("ignore_commits"))
|
|
151
151
|
args.append("--porcelain")
|
|
152
|
-
args.append("-w")
|
|
152
|
+
args.append("-w") # Ignore whitespace changes
|
|
153
153
|
args.append(str(self._path))
|
|
154
154
|
cmd = GitCommand("blame", args)
|
|
155
155
|
cmd.run()
|
|
@@ -189,15 +189,24 @@ class Page(AbstractRepoObject):
|
|
|
189
189
|
author_tz=commit_data.get("author-tz"),
|
|
190
190
|
summary=commit_data.get("summary"),
|
|
191
191
|
)
|
|
192
|
-
if
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
if len(line) > 1 or self.repo().config("count_empty_lines"):
|
|
193
|
+
if commit.author().email() not in ignore_authors:
|
|
194
|
+
author = commit.author()
|
|
195
|
+
if author not in self._authors:
|
|
196
|
+
self._authors.append(author)
|
|
197
|
+
author.add_lines(self, commit)
|
|
198
|
+
self.add_total_lines()
|
|
199
|
+
self.repo().add_total_lines()
|
|
200
|
+
# Process co-authors if present
|
|
201
|
+
for co_author in commit.co_authors():
|
|
202
|
+
# Create the co-author
|
|
203
|
+
if (
|
|
204
|
+
co_author.email() not in ignore_authors
|
|
205
|
+
and co_author.email() != commit.author().email()
|
|
206
|
+
):
|
|
207
|
+
if co_author not in self._authors:
|
|
208
|
+
self._authors.append(co_author)
|
|
209
|
+
co_author.add_lines(self, commit)
|
|
201
210
|
|
|
202
211
|
def path(self) -> Path:
|
|
203
212
|
"""
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import re
|
|
1
2
|
from pathlib import Path
|
|
2
|
-
from typing import Any, Union
|
|
3
|
+
from typing import Any, Union, List
|
|
3
4
|
|
|
4
5
|
from mkdocs_git_authors_plugin.git.command import GitCommand
|
|
5
6
|
|
|
7
|
+
from mkdocs_git_authors_plugin.git.command import GitCommandError
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
class Repo(object):
|
|
8
11
|
"""
|
|
@@ -49,7 +52,7 @@ class Repo(object):
|
|
|
49
52
|
self._authors[email] = Author(self, name, email)
|
|
50
53
|
return self._authors[email]
|
|
51
54
|
|
|
52
|
-
def get_authors(self) ->
|
|
55
|
+
def get_authors(self) -> List[Any]:
|
|
53
56
|
"""
|
|
54
57
|
Sorted list of authors in the repository.
|
|
55
58
|
|
|
@@ -113,9 +116,74 @@ class Repo(object):
|
|
|
113
116
|
if not self._commits.get(sha):
|
|
114
117
|
from .commit import Commit
|
|
115
118
|
|
|
119
|
+
if self.config("add_co_authors"):
|
|
120
|
+
kwargs["co_authors"] = self._get_co_authors(sha)
|
|
121
|
+
else:
|
|
122
|
+
kwargs["co_authors"] = []
|
|
116
123
|
self._commits[sha] = Commit(self, sha, **kwargs)
|
|
117
124
|
return self._commits.get(sha)
|
|
118
125
|
|
|
126
|
+
def _get_co_authors(self, sha) -> List[Any]:
|
|
127
|
+
"""
|
|
128
|
+
Execute git log and parse the results.
|
|
129
|
+
|
|
130
|
+
This retrieves [co-authors](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors) from comment.
|
|
131
|
+
Each line will be associated with a Commit object and counted
|
|
132
|
+
to its co-author's "account".
|
|
133
|
+
Whether empty lines are counted is determined by the
|
|
134
|
+
count_empty_lines configuration option.
|
|
135
|
+
|
|
136
|
+
git log -1 <sha> will produce output like the following
|
|
137
|
+
for each line in a file:
|
|
138
|
+
|
|
139
|
+
When a commit does not contain co-authors:
|
|
140
|
+
commit ca8b32b24af1ce97fb29c5139b2f80e0c2ad9d1c
|
|
141
|
+
Author: John Doe <jdoe@john.com>
|
|
142
|
+
Date: Sun Dec 22 11:10:32 2019 +0100
|
|
143
|
+
|
|
144
|
+
add plugin skeleton
|
|
145
|
+
|
|
146
|
+
When a commit contains co-authors:
|
|
147
|
+
commit ca8b32b24af1ce97fb29c5139b2f80e0c2ad9d1c
|
|
148
|
+
Author: John Doe <jdoe@john.com>
|
|
149
|
+
Date: Sun Dec 22 11:10:32 2019 +0100
|
|
150
|
+
|
|
151
|
+
add plugin skeleton
|
|
152
|
+
|
|
153
|
+
Co-authored-by: John Doe <jdoe@john.com>
|
|
154
|
+
Co-authored-by: Rock Smith <rsmith@smith.com>
|
|
155
|
+
|
|
156
|
+
In this case we skip the original author as redundant using email address to detect it.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
sha: the SHA of the commit to process
|
|
160
|
+
author_email: email of the author
|
|
161
|
+
Returns:
|
|
162
|
+
List of co-authors excluding commit author
|
|
163
|
+
"""
|
|
164
|
+
args = ["-1", sha]
|
|
165
|
+
cmd = GitCommand("log", args)
|
|
166
|
+
cmd.run()
|
|
167
|
+
|
|
168
|
+
lines = cmd.stdout()
|
|
169
|
+
|
|
170
|
+
# in case of empty, non-committed files, raise error
|
|
171
|
+
if len(lines) == 0:
|
|
172
|
+
raise GitCommandError
|
|
173
|
+
co_authors = []
|
|
174
|
+
|
|
175
|
+
for line in lines:
|
|
176
|
+
if line.startswith("Author: "):
|
|
177
|
+
# skip author as already available in Commit object
|
|
178
|
+
continue
|
|
179
|
+
|
|
180
|
+
result = re.search(r"Co-authored-by: (.*) <(.*)>", line)
|
|
181
|
+
if result is not None and result.group(1) != "" and result.group(2) != "":
|
|
182
|
+
# Extract co-authors from the commit
|
|
183
|
+
co_author = self.author(result.group(1), result.group(2))
|
|
184
|
+
co_authors.append(co_author)
|
|
185
|
+
return co_authors
|
|
186
|
+
|
|
119
187
|
def page(self, path):
|
|
120
188
|
"""
|
|
121
189
|
Return the (cached) Page object for given path.
|
|
@@ -45,8 +45,6 @@ SITES_THAT_SHOULD_SUCCEED = [
|
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
48
|
def build_docs_setup(mkdocs_path, output_path) -> Result:
|
|
51
49
|
runner = CliRunner()
|
|
52
50
|
return runner.invoke(
|
|
@@ -144,6 +142,25 @@ def test_ignore_authors_working(tmp_path) -> None:
|
|
|
144
142
|
assert not re.search("Julien", contents)
|
|
145
143
|
|
|
146
144
|
|
|
145
|
+
def test_co_authors_working(tmp_path) -> None:
|
|
146
|
+
result = build_docs_setup("tests/basic_setup/mkdocs_add_co_authors.yml", tmp_path)
|
|
147
|
+
assert (
|
|
148
|
+
result.exit_code == 0
|
|
149
|
+
), f"'mkdocs build' command failed. Error: {result.stdout}"
|
|
150
|
+
|
|
151
|
+
page_file = tmp_path / "page_with_co_authors/index.html"
|
|
152
|
+
assert page_file.exists(), f"{page_file} does not exist"
|
|
153
|
+
|
|
154
|
+
contents = page_file.read_text()
|
|
155
|
+
assert re.search("<span class='git-page-authors", contents)
|
|
156
|
+
assert re.search(
|
|
157
|
+
"fpozzobon@users.noreply.github.com'>Fabien Pozzobon</a>",
|
|
158
|
+
contents,
|
|
159
|
+
)
|
|
160
|
+
assert re.search("<a href='mailto:jdoe@john.com'>John Doe</a>", contents)
|
|
161
|
+
assert not re.search("Julien", contents)
|
|
162
|
+
|
|
163
|
+
|
|
147
164
|
def test_exclude_working_with_genfiles(tmp_path) -> None:
|
|
148
165
|
"""
|
|
149
166
|
A warning for uncommited files should not show up
|
|
@@ -331,11 +348,12 @@ def test_mkapi_v20x(tmp_path) -> None:
|
|
|
331
348
|
assert True
|
|
332
349
|
|
|
333
350
|
|
|
334
|
-
@pytest.mark.skipif(sys.version_info < (3, 7) or sys.version_info > (3, 9), reason="Requires Python 3.7 or higher")
|
|
335
351
|
@pytest.mark.skipif(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
352
|
+
sys.version_info < (3, 7) or sys.version_info > (3, 9),
|
|
353
|
+
reason="Requires Python 3.7 or higher",
|
|
354
|
+
)
|
|
355
|
+
@pytest.mark.skipif(
|
|
356
|
+
not (Version(mkdocs.__version__) < Version("1.6")),
|
|
339
357
|
reason="Requires mkdocs >= 1.6",
|
|
340
358
|
)
|
|
341
359
|
def test_mkapi_v1(tmp_path) -> None:
|
|
@@ -354,12 +372,12 @@ def test_mkapi_v1(tmp_path) -> None:
|
|
|
354
372
|
contents,
|
|
355
373
|
)
|
|
356
374
|
|
|
375
|
+
|
|
357
376
|
def test_custom_docs_dir(tmp_path):
|
|
358
377
|
|
|
359
378
|
testproject_path = tmp_path / "testproject"
|
|
360
379
|
shutil.copytree("tests/custom_docs_dir", testproject_path)
|
|
361
380
|
|
|
362
|
-
|
|
363
381
|
# init git inside the docs directory
|
|
364
382
|
with working_directory(str(testproject_path / "documentation")):
|
|
365
383
|
# setup git history
|
|
@@ -380,4 +398,3 @@ def test_custom_docs_dir(tmp_path):
|
|
|
380
398
|
|
|
381
399
|
contents = index_file.read_text()
|
|
382
400
|
assert re.search("<span class='git-page-authors", contents)
|
|
383
|
-
|
|
@@ -42,8 +42,8 @@ DEFAULT_CONFIG = {
|
|
|
42
42
|
"sort_authors_by": "name",
|
|
43
43
|
"authorship_threshold_percent": 0,
|
|
44
44
|
"strict": True,
|
|
45
|
-
#"sort_authors_by_name": True,
|
|
46
|
-
#"sort_reverse": False,
|
|
45
|
+
# "sort_authors_by_name": True,
|
|
46
|
+
# "sort_reverse": False,
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
#### Helpers ####
|
|
@@ -127,6 +127,11 @@ def setup_commit_history(testproject_path):
|
|
|
127
127
|
repo.git.commit(message="homepage", author=author)
|
|
128
128
|
repo.git.add("docs/page_with_tag.md")
|
|
129
129
|
repo.git.commit(message="homepage", author=author)
|
|
130
|
+
repo.git.add("docs/page_with_co_authors.md")
|
|
131
|
+
repo.git.commit(
|
|
132
|
+
message="co-authors commit\nCo-authored-by: Test Person <testtest@gmail.com>\nCo-authored-by: Roger Doe <rdoe@john.com>",
|
|
133
|
+
author=author,
|
|
134
|
+
)
|
|
130
135
|
os.chdir(str(cwd))
|
|
131
136
|
except:
|
|
132
137
|
os.chdir(str(cwd))
|
|
@@ -140,7 +145,7 @@ def commit_lines(r, file_name, author_name, author_email, num_of_lines=1):
|
|
|
140
145
|
with open(file_name, "a") as the_file:
|
|
141
146
|
for i in range(num_of_lines):
|
|
142
147
|
the_file.write("Hello\n")
|
|
143
|
-
|
|
148
|
+
|
|
144
149
|
r.index.add([file_name])
|
|
145
150
|
author = gitpython.Actor(author_name, author_email)
|
|
146
151
|
r.index.commit("some commit", author=author)
|
|
@@ -512,17 +517,18 @@ def test_page_authors_summary(tmp_path):
|
|
|
512
517
|
|
|
513
518
|
# Initial commit
|
|
514
519
|
commit_lines(r, file_name, "Tim", "abc@abc.com")
|
|
515
|
-
|
|
520
|
+
|
|
516
521
|
repo_instance = repo.Repo()
|
|
517
522
|
repo_instance.set_config(config)
|
|
518
523
|
page_instance = repo_instance.page(file_name)
|
|
519
524
|
|
|
520
525
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
521
526
|
|
|
522
|
-
assert
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
527
|
+
assert (
|
|
528
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
529
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"
|
|
530
|
+
"</span>"
|
|
531
|
+
)
|
|
526
532
|
|
|
527
533
|
# Now add a line to the file
|
|
528
534
|
# From a second author with same email
|
|
@@ -534,10 +540,11 @@ def test_page_authors_summary(tmp_path):
|
|
|
534
540
|
|
|
535
541
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
536
542
|
|
|
537
|
-
assert
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
543
|
+
assert (
|
|
544
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
545
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"
|
|
546
|
+
"</span>"
|
|
547
|
+
)
|
|
541
548
|
|
|
542
549
|
# Then a third commit from a new author
|
|
543
550
|
commit_lines(r, file_name, "John", "john@abc.com")
|
|
@@ -548,10 +555,12 @@ def test_page_authors_summary(tmp_path):
|
|
|
548
555
|
|
|
549
556
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
550
557
|
|
|
551
|
-
assert
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
558
|
+
assert (
|
|
559
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
560
|
+
"<a href='mailto:john@abc.com'>John</a>, "
|
|
561
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"
|
|
562
|
+
"</span>"
|
|
563
|
+
)
|
|
555
564
|
|
|
556
565
|
os.chdir(cwd)
|
|
557
566
|
|
|
@@ -575,7 +584,7 @@ def test_page_authors_summary_showing_contribution(tmp_path):
|
|
|
575
584
|
|
|
576
585
|
# Initial commit
|
|
577
586
|
commit_lines(r, file_name, "Tim", "abc@abc.com")
|
|
578
|
-
|
|
587
|
+
|
|
579
588
|
repo_instance = repo.Repo()
|
|
580
589
|
repo_instance.set_config(config)
|
|
581
590
|
page_instance = repo_instance.page(file_name)
|
|
@@ -583,10 +592,11 @@ def test_page_authors_summary_showing_contribution(tmp_path):
|
|
|
583
592
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
584
593
|
|
|
585
594
|
# Contribution is not shown if there is only single Author
|
|
586
|
-
assert
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
595
|
+
assert (
|
|
596
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
597
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"
|
|
598
|
+
"</span>"
|
|
599
|
+
)
|
|
590
600
|
|
|
591
601
|
# Now add a line to the file
|
|
592
602
|
# From a second author with same email
|
|
@@ -599,10 +609,11 @@ def test_page_authors_summary_showing_contribution(tmp_path):
|
|
|
599
609
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
600
610
|
|
|
601
611
|
# Contribution is not shown if there is only single Author
|
|
602
|
-
assert
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
612
|
+
assert (
|
|
613
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
614
|
+
"<a href='mailto:abc@abc.com'>Tim</a>"
|
|
615
|
+
"</span>"
|
|
616
|
+
)
|
|
606
617
|
|
|
607
618
|
# Then a third commit from a new author
|
|
608
619
|
commit_lines(r, file_name, "John", "john@abc.com")
|
|
@@ -614,15 +625,19 @@ def test_page_authors_summary_showing_contribution(tmp_path):
|
|
|
614
625
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
615
626
|
|
|
616
627
|
# Contribution is shown if there are multiple authors, ordered by contribution
|
|
617
|
-
assert
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
628
|
+
assert (
|
|
629
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
630
|
+
"<a href='mailto:abc@abc.com'>Tim</a> (66.67%), "
|
|
631
|
+
"<a href='mailto:john@abc.com'>John</a> (33.33%)"
|
|
632
|
+
"</span>"
|
|
633
|
+
)
|
|
621
634
|
|
|
622
635
|
os.chdir(cwd)
|
|
623
636
|
|
|
624
637
|
|
|
625
|
-
def test_page_authors_summary_showing_contribution_ordering_by_page_contribution(
|
|
638
|
+
def test_page_authors_summary_showing_contribution_ordering_by_page_contribution(
|
|
639
|
+
tmp_path,
|
|
640
|
+
):
|
|
626
641
|
"""
|
|
627
642
|
Builds a fake git project with some commits.
|
|
628
643
|
|
|
@@ -648,7 +663,7 @@ def test_page_authors_summary_showing_contribution_ordering_by_page_contribution
|
|
|
648
663
|
commit_lines(r, file_name2, "Tim", "tim@abc.com", 4)
|
|
649
664
|
commit_lines(r, file_name2, "John", "john@abc.com", 16)
|
|
650
665
|
commit_lines(r, file_name2, "Thomas", "thomas@abc.com", 8)
|
|
651
|
-
|
|
666
|
+
|
|
652
667
|
repo_instance = repo.Repo()
|
|
653
668
|
repo_instance.set_config(config)
|
|
654
669
|
page_instance = repo_instance.page(file_name)
|
|
@@ -657,19 +672,23 @@ def test_page_authors_summary_showing_contribution_ordering_by_page_contribution
|
|
|
657
672
|
authors_summary = util.page_authors_summary(page_instance, config)
|
|
658
673
|
|
|
659
674
|
# Contribution is shown if there are multiple authors, ordered by contribution on page
|
|
660
|
-
assert
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
675
|
+
assert (
|
|
676
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
677
|
+
"<a href='mailto:tim@abc.com'>Tim</a> (57.14%), "
|
|
678
|
+
"<a href='mailto:john@abc.com'>John</a> (28.57%), "
|
|
679
|
+
"<a href='mailto:thomas@abc.com'>Thomas</a> (14.29%)"
|
|
680
|
+
"</span>"
|
|
681
|
+
)
|
|
682
|
+
|
|
666
683
|
authors_summary = util.page_authors_summary(page_instance2, config)
|
|
667
684
|
|
|
668
|
-
assert
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
685
|
+
assert (
|
|
686
|
+
authors_summary == "<span class='git-page-authors git-authors'>"
|
|
687
|
+
"<a href='mailto:john@abc.com'>John</a> (57.14%), "
|
|
688
|
+
"<a href='mailto:thomas@abc.com'>Thomas</a> (28.57%), "
|
|
689
|
+
"<a href='mailto:tim@abc.com'>Tim</a> (14.29%)"
|
|
690
|
+
"</span>"
|
|
691
|
+
)
|
|
673
692
|
|
|
674
693
|
os.chdir(cwd)
|
|
675
694
|
|
|
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
|