Skip to content

Commit

Permalink
Add support for both GitHub and GitLab self-hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
ojacques committed Feb 24, 2024
1 parent f961a0a commit b3d1a6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ unless you access private repositories.
- `enterprise_hostname` - For GitHub enterprise: the GitHub enterprise hostname.
- `gitlab_hostname` - For GitLab: the GitLab hostname if different from
gitlab.com (self-hosted).
- `api_version` - For GitHub Enterprise: The version part that needs to be appended to the URL. E.g. `/v3`
- `api_version` - For GitHub and GitLab self-hosted, the API version part that needs to be appended to the URL.
Defaults to v4 for GitLab, and nothing for GitHub Enterprise (you may need `v3`).
- `docs_path` - the path to the documentation folder. Defaults to `docs`.
- `cache_dir` - The path which holds the authors cache file to speed up
documentation builds. Defaults to `.cache/plugin/git-committers/`. The cache
Expand Down
10 changes: 8 additions & 2 deletions mkdocs_git_committers_plugin_2/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ def on_config(self, config):
LOG.error("git-committers plugin: repository not specified")
return config
if self.config['enterprise_hostname'] and self.config['enterprise_hostname'] != '':
self.githuburl = "https://" + self.config['enterprise_hostname'] + "/api" + self.config['api_version']
if not self.config['api_version']:
self.githuburl = "https://" + self.config['enterprise_hostname'] + "/api"
else:
self.githuburl = "https://" + self.config['enterprise_hostname'] + "/api/" + self.config['api_version']
if self.config['gitlab_hostname'] and self.config['gitlab_hostname'] != '':
self.gitlaburl = "https://" + self.config['gitlab_hostname'] + "/api/v4"
if not self.config['api_version']:
self.gitlaburl = "https://" + self.config['gitlab_hostname'] + "/api/v4"
else:
self.gitlaburl = "https://" + self.config['gitlab_hostname'] + "/api/" + self.config['api_version']
# gitlab_repository must be set
if not self.config['gitlab_repository']:
LOG.error("git-committers plugin: gitlab_repository must be set, with the GitLab project ID")
Expand Down

0 comments on commit b3d1a6c

Please sign in to comment.