Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub (Enterprise) fixes #18

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions mkdocs_git_committers_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from mkdocs.plugins import BasePlugin

from github import Github
from github import Auth

LOG = logging.getLogger("mkdocs.plugins." + __name__)

Expand All @@ -34,10 +35,11 @@ def on_config(self, config):
if self.config['token'] and self.config['token'] != '':
LOG.info("git-committers plugin ENABLED")
self.enabled = True
auth = Auth.Token(self.config['token'])
if self.config['enterprise_hostname'] and self.config['enterprise_hostname'] != '':
self.github = Github( base_url="https://" + self.config['enterprise_hostname'] + "/api/v3", login_or_token=self.config['token'] )
self.github = Github( base_url="https://" + self.config['enterprise_hostname'] + "/api/v3", auth=auth )
else:
self.github = Github( self.config['token'] )
self.github = Github( auth=auth )
self.repo = self.github.get_repo( self.config['repository'] )
self.branch = self.config['branch']
else:
Expand All @@ -62,10 +64,10 @@ def get_committers(self, path):
unique_committers.append({
"name": c.author.name,
"login": c.author.login,
"url": f"https://github.com/{c.author.login}",
"url": f"https://{self.config['enterprise_hostname'] or 'github.com'}/{c.author.login}",
"avatar": c.author.avatar_url,
"last_commit": c.author.avatar_url,
"repos": 'https://' + (self.config['enterprise_hostname'] or 'github.com') + '/' + c.author.login
"repos": f"https://{self.config['enterprise_hostname'] or 'github.com'}/{c.author.login}"
})
return unique_committers

Expand All @@ -74,10 +76,10 @@ def get_github_user(self, username):
contrib = {
"name": user.name,
"login": user.login,
"url": f"https://github.com/{user.login}",
"url": f"https://{self.config['enterprise_hostname'] or 'github.com'}/{user.login}",
"avatar": user.avatar_url,
"last_commit": user.avatar_url,
"repos": 'https://' + (self.config['enterprise_hostname'] or 'github.com') + '/' + user.login
"repos": f"https://{self.config['enterprise_hostname'] or 'github.com'}/{user.login}"
}
return contrib

Expand Down