Skip to content

Commit f4e7167

Browse files
committed
feat: Add a new option exclude_committers to ignore some committers
1 parent 6a95da3 commit f4e7167

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: mkdocs_git_committers_plugin_2/plugin.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class GitCommittersPlugin(BasePlugin):
3131
('enabled', config_options.Type(bool, default=True)),
3232
('cache_dir', config_options.Type(str, default='.cache/plugin/git-committers')),
3333
("exclude", config_options.Type(list, default=[])),
34+
("exclude_committers", config_options.Type(list, default=[])),
3435
('token', config_options.Type(str, default='')),
3536
)
3637

@@ -41,6 +42,7 @@ def __init__(self):
4142
self.authors = dict()
4243
self.cache_page_authors = dict()
4344
self.exclude = list()
45+
self.exclude_committers = list()
4446
self.cache_date = ''
4547
self.last_request_return_code = 0
4648
self.githuburl = "https://api.github.com"
@@ -88,6 +90,7 @@ def on_config(self, config):
8890
self.localrepo = Repo(".", search_parent_directories=True)
8991
self.branch = self.config['branch']
9092
self.excluded_pages = self.config['exclude']
93+
self.exclude_committers = self.config['exclude_committers']
9194
return config
9295

9396
# Get unique contributors for a given path
@@ -268,7 +271,13 @@ def list_contributors(self, path):
268271
else:
269272
LOG.info("git-committers: fetching submodule info for " + path + " from repository " + submodule_repo + " with path " + path_in_submodule)
270273
authors = self.get_contributors_to_file(path_in_submodule, submodule_repo=submodule_repo)
271-
274+
275+
for exclude_committer in set(self.exclude_committers):
276+
for author in tuple(authors):
277+
if author["login"] == exclude_committer:
278+
authors.remove(author)
279+
break
280+
272281
if path not in self.cache_page_authors or self.cache_page_authors[path] != {'last_commit_date': last_commit_date, 'authors': authors}:
273282
self.should_save_cache = True
274283
self.cache_page_authors[path] = {'last_commit_date': last_commit_date, 'authors': authors}

0 commit comments

Comments
 (0)