Skip to content

Commit a310cc8

Browse files
sort the authors by contribution and eliminate low-contribution authors
1 parent 452ab06 commit a310cc8

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

mkdocs_git_authors_plugin/git/page.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ def get_authors(self):
6060
"""
6161
if not self._sorted:
6262
repo = self.repo()
63-
reverse = repo.config("show_line_count") or repo.config("show_contribution")
63+
reverse = repo.config("show_line_count") or repo.config("show_contribution") or repo.config("sort_authors_by") == "contribution"
6464
self._authors = sorted(self._authors, key=repo._sort_key, reverse=reverse)
6565
self._sorted = True
66+
# TODO - Remove authors with under a certain line percentage
67+
author_threshold = repo.config("authorship_threshold_percent")
68+
if author_threshold > 0 and len(self._authors) > 1:
69+
self._authors = [a for a in self._authors if a.contribution()*100 > author_threshold]
6670
return self._authors
6771

6872
def _process_git_blame(self):

mkdocs_git_authors_plugin/git/repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _sort_key(self, author):
152152
Returns:
153153
comparison key for the sorted() function,
154154
"""
155-
if self.config("show_line_count") or self.config("show_contribution"):
155+
if self.config("show_line_count") or self.config("show_contribution") or self.config("sort_authors_by") == "contribution":
156156
key = "contribution"
157157
else:
158158
key = "name"

mkdocs_git_authors_plugin/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class GitAuthorsPlugin(BasePlugin):
1919
("fallback_to_empty", config_options.Type(bool, default=False)),
2020
("exclude", config_options.Type(list, default=[])),
2121
("enabled", config_options.Type(bool, default=True)),
22+
("sort_authors_by", config_options.Type(str, default="name")),
23+
("authorship_threshold_percent", config_options.Type(int, default=0)),
2224
# ('sort_authors_by_name', config_options.Type(bool, default=True)),
2325
# ('sort_reverse', config_options.Type(bool, default=False))
2426
)

0 commit comments

Comments
 (0)