Skip to content

Commit 04fc52e

Browse files
authored
Merge pull request #79 from Xiaokang2022/master
Add a new option `exclude_committers` to ignore some committers
2 parents 6a95da3 + 5809aa5 commit 04fc52e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ For private GitHub repositories, you only need to allow read-only access to `Con
104104
- all_files_inside_folder/*
105105
- folder_and_subfolders/**
106106
```
107+
- `exclude_committers` - Specify a list of usernames to exclude certain committers. Default is empty.
107108
108109
## History
109110

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)