Skip to content

Commit

Permalink
Add committers-source github/gitlab in page context, remove it from a…
Browse files Browse the repository at this point in the history
…uthor
  • Loading branch information
ojacques committed Nov 3, 2023
1 parent 1c1ff87 commit e3d5474
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions mkdocs_git_committers_plugin_2/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def get_contributors_to_file(self, path):
authors.append({'login': commit['author']['login'],
'name': commit['author']['login'],
'url': commit['author']['html_url'],
'avatar': commit['author']['avatar_url'],
'source': 'github'})
'avatar': commit['author']['avatar_url']
})
else:
# GitLab
if commit['author_name']:
Expand All @@ -118,8 +118,8 @@ def get_contributors_to_file(self, path):
authors.append({'login': self.gitlabauthors_cache[commit['author_name']]['username'],
'name': commit['author_name'],
'url': self.gitlabauthors_cache[commit['author_name']]['web_url'],
'avatar': self.gitlabauthors_cache[commit['author_name']]['avatar_url'],
'source': 'gitlab'})
'avatar': self.gitlabauthors_cache[commit['author_name']]['avatar_url']
})
else:
# Fetch author from GitLab API
url = self.gitlaburl + "/users?search=" + requests.utils.quote(commit['author_name'])
Expand All @@ -135,8 +135,8 @@ def get_contributors_to_file(self, path):
authors.append({'login': user['username'],
'name': user['name'],
'url': user['web_url'],
'avatar': user['avatar_url'],
'source': 'gitlab'})
'avatar': user['avatar_url']
})
break
else:
LOG.error("git-committers: " + str(r.status_code) + " " + r.reason)
Expand Down Expand Up @@ -192,6 +192,10 @@ def on_page_context(self, context, page, config, nav):
context['committers'] = authors
if last_commit_date:
context['last_commit_date'] = last_commit_date
if not self.config['gitlab_repository']:
context['committers-source'] = 'github'
else:
context['committers-source'] = 'gitlab'
end = timer()
self.total_time += (end - start)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="mkdocs-git-committers-plugin-2",
version="2.2.0",
version="2.2.1",
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",
Expand Down

0 comments on commit e3d5474

Please sign in to comment.