From fac80eec48cbe9dbc8b5bde6df30a792a03fea88 Mon Sep 17 00:00:00 2001 From: vrenjith Date: Thu, 5 Jun 2025 00:01:56 +0530 Subject: [PATCH 01/12] Update plugin.py --- mkdocs_git_committers_plugin_2/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 9ed30cf..52109e6 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -119,7 +119,7 @@ def get_contributors_to_file(self, path, submodule_repo=None): # GitHub if commit['author'] and commit['author']['login'] and commit['author']['login'] not in [author['login'] for author in authors]: authors.append({'login': commit['author']['login'], - 'name': commit['author']['login'], + 'name': commit['author']['name'], 'url': commit['author']['html_url'], 'avatar': commit['author']['avatar_url'] if commit['author']['avatar_url'] is not None else '' }) From 5e0f3e7b490d0c54f675fdcf4fc3602567737f53 Mon Sep 17 00:00:00 2001 From: vrenjith Date: Thu, 5 Jun 2025 00:05:27 +0530 Subject: [PATCH 02/12] Update plugin.py --- mkdocs_git_committers_plugin_2/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 52109e6..b12a831 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -125,7 +125,7 @@ def get_contributors_to_file(self, path, submodule_repo=None): }) if commit['committer'] and commit['committer']['login'] and commit['committer']['login'] not in [author['login'] for author in authors]: authors.append({'login': commit['committer']['login'], - 'name': commit['committer']['login'], + 'name': commit['committer']['name'], 'url': commit['committer']['html_url'], 'avatar': commit['committer']['avatar_url'] if commit['committer']['avatar_url'] is not None else '' }) From 4c12328c01a38928db0fae9ba91f357c13240d64 Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Thu, 5 Jun 2025 13:29:37 +0530 Subject: [PATCH 03/12] Save authors cache after retrieving contributors and during post-build --- mkdocs_git_committers_plugin_2/plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 76577d0..f8c7c35 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -180,6 +180,7 @@ def list_contributors(self, path): authors = self.get_contributors_to_file(path) self.cache_page_authors[path] = {'last_commit_date': last_commit_date, 'authors': authors} + self.save_cache() return authors, last_commit_date @@ -207,6 +208,9 @@ def on_page_context(self, context, page, config, nav): return context def on_post_build(self, config): + self.save_cache() + + def save_cache(self): LOG.info("git-committers: saving page authors cache file") json_data = json.dumps({'cache_date': datetime.now().strftime("%Y-%m-%d"), 'page_authors': self.cache_page_authors}) os.makedirs(self.config['cache_dir'], exist_ok=True) From 63d5011acad1df66de076adb3ad6947a176a0e88 Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Thu, 5 Jun 2025 13:37:49 +0530 Subject: [PATCH 04/12] Save authors cache during contributor updates and post-build process --- mkdocs_git_committers_plugin_2/plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index b12a831..fa52661 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -281,6 +281,7 @@ def list_contributors(self, path): if path not in self.cache_page_authors or self.cache_page_authors[path] != {'last_commit_date': last_commit_date, 'authors': authors}: self.should_save_cache = True self.cache_page_authors[path] = {'last_commit_date': last_commit_date, 'authors': authors} + self.save_cache() return authors, last_commit_date @@ -308,6 +309,9 @@ def on_page_context(self, context, page, config, nav): return context def on_post_build(self, config): + self.save_cache() + + def save_cache(self): if not self.should_save_cache: return LOG.info("git-committers: saving page authors cache file") From 57a6a6ced2070ab414c6c025342faf880acbbf4a Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Thu, 5 Jun 2025 13:50:44 +0530 Subject: [PATCH 05/12] Remove logging statement for saving page authors cache --- mkdocs_git_committers_plugin_2/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index fa52661..e96e19e 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -314,7 +314,7 @@ def on_post_build(self, config): def save_cache(self): if not self.should_save_cache: return - LOG.info("git-committers: saving page authors cache file") + # LOG.info("git-committers: saving page authors cache file") json_data = json.dumps({'cache_date': datetime.now().strftime("%Y-%m-%d"), 'page_authors': self.cache_page_authors}) os.makedirs(self.config['cache_dir'], exist_ok=True) f = open(self.config['cache_dir'] + "/page-authors.json", "w") From 881b4a0b513541a26a11afcd85ae5ae372bcdf6d Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Thu, 5 Jun 2025 21:32:24 +0530 Subject: [PATCH 06/12] Fix author name retrieval in contributors list --- mkdocs_git_committers_plugin_2/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index e96e19e..4866dca 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -119,13 +119,13 @@ def get_contributors_to_file(self, path, submodule_repo=None): # GitHub if commit['author'] and commit['author']['login'] and commit['author']['login'] not in [author['login'] for author in authors]: authors.append({'login': commit['author']['login'], - 'name': commit['author']['name'], + 'name': commit['author'].get('name') or commit['author']['login'], 'url': commit['author']['html_url'], 'avatar': commit['author']['avatar_url'] if commit['author']['avatar_url'] is not None else '' }) if commit['committer'] and commit['committer']['login'] and commit['committer']['login'] not in [author['login'] for author in authors]: authors.append({'login': commit['committer']['login'], - 'name': commit['committer']['name'], + 'name': commit['author'].get('name') or commit['author']['login'], 'url': commit['committer']['html_url'], 'avatar': commit['committer']['avatar_url'] if commit['committer']['avatar_url'] is not None else '' }) From 9cceef00d72d082b645769fb02b1a9872909a4ff Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Fri, 6 Jun 2025 12:00:34 +0530 Subject: [PATCH 07/12] Enable logging for saving page authors cache --- mkdocs_git_committers_plugin_2/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 4866dca..7767f41 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -314,7 +314,7 @@ def on_post_build(self, config): def save_cache(self): if not self.should_save_cache: return - # LOG.info("git-committers: saving page authors cache file") + LOG.info("git-committers: saving page authors cache file") json_data = json.dumps({'cache_date': datetime.now().strftime("%Y-%m-%d"), 'page_authors': self.cache_page_authors}) os.makedirs(self.config['cache_dir'], exist_ok=True) f = open(self.config['cache_dir'] + "/page-authors.json", "w") From 73c2c594c3ad9397671f27bef05836f60a33cea1 Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Fri, 6 Jun 2025 18:40:11 +0530 Subject: [PATCH 08/12] Log cached authors usage in get_contributors_to_file method --- mkdocs_git_committers_plugin_2/plugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 7767f41..20672c5 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -263,7 +263,8 @@ def list_contributors(self, path): if self.cache_date and time.strptime(last_commit_date, "%Y-%m-%d") < time.strptime(self.cache_date, "%Y-%m-%d"): # If page_autors in cache is not empty, return it if self.cache_page_authors[path]['authors']: - return self.cache_page_authors[path]['authors'], self.cache_page_authors[path]['last_commit_date'] + LOG.info(f"git-committers: using cached authors for {path}") + self.cache_page_authors[path]['authors'], self.cache_page_authors[path]['last_commit_date'] authors=[] if not submodule_repo: From fc4ffbd708e6c125f2d756c05b29e8adc9d90f74 Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Fri, 6 Jun 2025 21:13:48 +0530 Subject: [PATCH 09/12] Add logging for plugin configuration status --- mkdocs_git_committers_plugin_2/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 20672c5..47737bb 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -51,6 +51,7 @@ def __init__(self): self.should_save_cache = False def on_config(self, config): + LOG.info("git-committers plugin - custom build") self.enabled = self.config['enabled'] if not self.enabled: LOG.info("git-committers plugin DISABLED") From eee5d3d75d5865215f2454855f7a82ceed2898bd Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Fri, 6 Jun 2025 21:24:57 +0530 Subject: [PATCH 10/12] Bump version to 2.5.2 in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a55f9cc..40eb174 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="mkdocs-git-committers-plugin-2", - version="2.5.0", + version="2.5.2", description="An MkDocs plugin to create a list of contributors on the page. The git-committers plugin will seed the template context with a list of GitHub or GitLab committers and other useful GIT info such as last modified date", long_description=long_description, long_description_content_type="text/markdown", From 5826bcf7e4c376d5ad19fd26ee1816656d2c6791 Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Fri, 6 Jun 2025 21:29:33 +0530 Subject: [PATCH 11/12] Enhance logging to include full path of the page authors cache file when loading --- mkdocs_git_committers_plugin_2/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 47737bb..a8c87c2 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -325,7 +325,7 @@ def save_cache(self): def on_pre_build(self, config): if os.path.exists(self.config['cache_dir'] + "/page-authors.json"): - LOG.info("git-committers: found page authors cache file - loading it") + LOG.info(f"git-committers: found page authors cache file at {self.config['cache_dir'] + '/page-authors.json'} - loading it") f = open(self.config['cache_dir'] + "/page-authors.json", "r") cache = json.loads(f.read()) self.cache_date = cache['cache_date'] From 0a5c21b2423d00224b28bdb5c96c43d3dbd7ffdc Mon Sep 17 00:00:00 2001 From: Renjith Pillai Date: Fri, 6 Jun 2025 21:36:39 +0530 Subject: [PATCH 12/12] Fix return statement in get_contributors_to_file method to properly return cached authors and last commit date --- mkdocs_git_committers_plugin_2/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index a8c87c2..f2f896e 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -265,7 +265,7 @@ def list_contributors(self, path): # If page_autors in cache is not empty, return it if self.cache_page_authors[path]['authors']: LOG.info(f"git-committers: using cached authors for {path}") - self.cache_page_authors[path]['authors'], self.cache_page_authors[path]['last_commit_date'] + return self.cache_page_authors[path]['authors'], self.cache_page_authors[path]['last_commit_date'] authors=[] if not submodule_repo: