diff --git a/README.md b/README.md index 557a08b..4c817da 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,10 @@ unless you access private repositories. unless you access private repositories. For GitLab, create a token at [gitlab.com/-/profile/personal_access_tokens](https://gitlab.com/-/profile/personal_access_tokens). - `enterprise_hostname` - For GitHub enterprise: the GitHub enterprise hostname. -- `gitlab_hostname` - For GitLab: the GitLab hostname if different from +- `gitlab_hostname` - For GitLab: the GitLab hostname if different from gitlab.com (self-hosted). +- `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 diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 48f0b66..76577d0 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -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" + 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")