Skip to content

Commit 421a4db

Browse files
fpozzobontimvink
authored andcommitted
reformat
1 parent 76362a7 commit 421a4db

File tree

2 files changed

+66
-46
lines changed

2 files changed

+66
-46
lines changed

src/mkdocs_git_authors_plugin/git/page.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def _process_git_blame(self) -> None:
149149
args.append("--ignore-revs-file")
150150
args.append(self.repo().config("ignore_commits"))
151151
args.append("--porcelain")
152-
args.append("-w") # Ignore whitespace changes
152+
args.append("-w") # Ignore whitespace changes
153153
args.append(str(self._path))
154154
cmd = GitCommand("blame", args)
155155
cmd.run()
@@ -239,7 +239,7 @@ def _process_git_log(self, sha, commit) -> None:
239239
"""
240240

241241
args = []
242-
args.append("-1") # Only existing sha
242+
args.append("-1") # Only existing sha
243243
args.append(sha)
244244
cmd = GitCommand("log", args)
245245
cmd.run()
@@ -260,7 +260,10 @@ def _process_git_log(self, sha, commit) -> None:
260260
if result is not None and result.group(1) != "" and result.group(2) != "":
261261
# Extract co-authors from the commit
262262
co_author = self.repo().author(result.group(1), result.group(2))
263-
if co_author.email() not in ignore_authors and co_author.email() != commit.author().email():
263+
if (
264+
co_author.email() not in ignore_authors
265+
and co_author.email() != commit.author().email()
266+
):
264267
# Create the co-author
265268
if co_author not in self._authors:
266269
self._authors.append(co_author)

tests/test_util.py

Lines changed: 60 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"sort_authors_by": "name",
4343
"authorship_threshold_percent": 0,
4444
"strict": True,
45-
#"sort_authors_by_name": True,
46-
#"sort_reverse": False,
45+
# "sort_authors_by_name": True,
46+
# "sort_reverse": False,
4747
}
4848

4949
#### Helpers ####
@@ -128,7 +128,10 @@ def setup_commit_history(testproject_path):
128128
repo.git.add("docs/page_with_tag.md")
129129
repo.git.commit(message="homepage", author=author)
130130
repo.git.add("docs/page_with_co_authors.md")
131-
repo.git.commit(message="co-authors commit\nCo-authored-by: Test Person <[email protected]>\nCo-authored-by: John Doe <[email protected]>", author=author)
131+
repo.git.commit(
132+
message="co-authors commit\nCo-authored-by: Test Person <[email protected]>\nCo-authored-by: John Doe <[email protected]>",
133+
author=author,
134+
)
132135
os.chdir(str(cwd))
133136
except:
134137
os.chdir(str(cwd))
@@ -142,7 +145,7 @@ def commit_lines(r, file_name, author_name, author_email, num_of_lines=1):
142145
with open(file_name, "a") as the_file:
143146
for i in range(num_of_lines):
144147
the_file.write("Hello\n")
145-
148+
146149
r.index.add([file_name])
147150
author = gitpython.Actor(author_name, author_email)
148151
r.index.commit("some commit", author=author)
@@ -514,17 +517,18 @@ def test_page_authors_summary(tmp_path):
514517

515518
# Initial commit
516519
commit_lines(r, file_name, "Tim", "[email protected]")
517-
520+
518521
repo_instance = repo.Repo()
519522
repo_instance.set_config(config)
520523
page_instance = repo_instance.page(file_name)
521524

522525
authors_summary = util.page_authors_summary(page_instance, config)
523526

524-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
525-
"<a href='mailto:[email protected]'>Tim</a>"\
526-
"</span>"
527-
527+
assert (
528+
authors_summary == "<span class='git-page-authors git-authors'>"
529+
"<a href='mailto:[email protected]'>Tim</a>"
530+
"</span>"
531+
)
528532

529533
# Now add a line to the file
530534
# From a second author with same email
@@ -536,10 +540,11 @@ def test_page_authors_summary(tmp_path):
536540

537541
authors_summary = util.page_authors_summary(page_instance, config)
538542

539-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
540-
"<a href='mailto:[email protected]'>Tim</a>"\
541-
"</span>"
542-
543+
assert (
544+
authors_summary == "<span class='git-page-authors git-authors'>"
545+
"<a href='mailto:[email protected]'>Tim</a>"
546+
"</span>"
547+
)
543548

544549
# Then a third commit from a new author
545550
commit_lines(r, file_name, "John", "[email protected]")
@@ -550,10 +555,12 @@ def test_page_authors_summary(tmp_path):
550555

551556
authors_summary = util.page_authors_summary(page_instance, config)
552557

553-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
554-
"<a href='mailto:[email protected]'>John</a>, "\
555-
"<a href='mailto:[email protected]'>Tim</a>"\
556-
"</span>"
558+
assert (
559+
authors_summary == "<span class='git-page-authors git-authors'>"
560+
"<a href='mailto:[email protected]'>John</a>, "
561+
"<a href='mailto:[email protected]'>Tim</a>"
562+
"</span>"
563+
)
557564

558565
os.chdir(cwd)
559566

@@ -577,18 +584,19 @@ def test_page_authors_summary_showing_contribution(tmp_path):
577584

578585
# Initial commit
579586
commit_lines(r, file_name, "Tim", "[email protected]")
580-
587+
581588
repo_instance = repo.Repo()
582589
repo_instance.set_config(config)
583590
page_instance = repo_instance.page(file_name)
584591

585592
authors_summary = util.page_authors_summary(page_instance, config)
586593

587594
# Contribution is not shown if there is only single Author
588-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
589-
"<a href='mailto:[email protected]'>Tim</a>"\
590-
"</span>"
591-
595+
assert (
596+
authors_summary == "<span class='git-page-authors git-authors'>"
597+
"<a href='mailto:[email protected]'>Tim</a>"
598+
"</span>"
599+
)
592600

593601
# Now add a line to the file
594602
# From a second author with same email
@@ -601,10 +609,11 @@ def test_page_authors_summary_showing_contribution(tmp_path):
601609
authors_summary = util.page_authors_summary(page_instance, config)
602610

603611
# Contribution is not shown if there is only single Author
604-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
605-
"<a href='mailto:[email protected]'>Tim</a>"\
606-
"</span>"
607-
612+
assert (
613+
authors_summary == "<span class='git-page-authors git-authors'>"
614+
"<a href='mailto:[email protected]'>Tim</a>"
615+
"</span>"
616+
)
608617

609618
# Then a third commit from a new author
610619
commit_lines(r, file_name, "John", "[email protected]")
@@ -616,15 +625,19 @@ def test_page_authors_summary_showing_contribution(tmp_path):
616625
authors_summary = util.page_authors_summary(page_instance, config)
617626

618627
# Contribution is shown if there are multiple authors, ordered by contribution
619-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
620-
"<a href='mailto:[email protected]'>Tim</a> (66.67%), "\
621-
"<a href='mailto:[email protected]'>John</a> (33.33%)"\
622-
"</span>"
628+
assert (
629+
authors_summary == "<span class='git-page-authors git-authors'>"
630+
"<a href='mailto:[email protected]'>Tim</a> (66.67%), "
631+
"<a href='mailto:[email protected]'>John</a> (33.33%)"
632+
"</span>"
633+
)
623634

624635
os.chdir(cwd)
625636

626637

627-
def test_page_authors_summary_showing_contribution_ordering_by_page_contribution(tmp_path):
638+
def test_page_authors_summary_showing_contribution_ordering_by_page_contribution(
639+
tmp_path,
640+
):
628641
"""
629642
Builds a fake git project with some commits.
630643
@@ -650,7 +663,7 @@ def test_page_authors_summary_showing_contribution_ordering_by_page_contribution
650663
commit_lines(r, file_name2, "Tim", "[email protected]", 4)
651664
commit_lines(r, file_name2, "John", "[email protected]", 16)
652665
commit_lines(r, file_name2, "Thomas", "[email protected]", 8)
653-
666+
654667
repo_instance = repo.Repo()
655668
repo_instance.set_config(config)
656669
page_instance = repo_instance.page(file_name)
@@ -659,19 +672,23 @@ def test_page_authors_summary_showing_contribution_ordering_by_page_contribution
659672
authors_summary = util.page_authors_summary(page_instance, config)
660673

661674
# Contribution is shown if there are multiple authors, ordered by contribution on page
662-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
663-
"<a href='mailto:[email protected]'>Tim</a> (57.14%), "\
664-
"<a href='mailto:[email protected]'>John</a> (28.57%), "\
665-
"<a href='mailto:[email protected]'>Thomas</a> (14.29%)"\
666-
"</span>"
667-
675+
assert (
676+
authors_summary == "<span class='git-page-authors git-authors'>"
677+
"<a href='mailto:[email protected]'>Tim</a> (57.14%), "
678+
"<a href='mailto:[email protected]'>John</a> (28.57%), "
679+
"<a href='mailto:[email protected]'>Thomas</a> (14.29%)"
680+
"</span>"
681+
)
682+
668683
authors_summary = util.page_authors_summary(page_instance2, config)
669684

670-
assert authors_summary == "<span class='git-page-authors git-authors'>"\
671-
"<a href='mailto:[email protected]'>John</a> (57.14%), "\
672-
"<a href='mailto:[email protected]'>Thomas</a> (28.57%), "\
673-
"<a href='mailto:[email protected]'>Tim</a> (14.29%)"\
674-
"</span>"
685+
assert (
686+
authors_summary == "<span class='git-page-authors git-authors'>"
687+
"<a href='mailto:[email protected]'>John</a> (57.14%), "
688+
"<a href='mailto:[email protected]'>Thomas</a> (28.57%), "
689+
"<a href='mailto:[email protected]'>Tim</a> (14.29%)"
690+
"</span>"
691+
)
675692

676693
os.chdir(cwd)
677694

0 commit comments

Comments
 (0)