From 46780f06a6abe25488a3183ff490170141654090 Mon Sep 17 00:00:00 2001 From: vrenjith Date: Fri, 19 Jan 2024 23:39:55 +0530 Subject: [PATCH 1/3] Include API Version in the URL --- 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 00e3f44..26bf6f9 100644 --- a/mkdocs_git_committers_plugin_2/plugin.py +++ b/mkdocs_git_committers_plugin_2/plugin.py @@ -59,7 +59,7 @@ 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.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" # gitlab_repository must be set From d26cdd84f8bfe9d971a21fed9ceb7347a1dd49ee Mon Sep 17 00:00:00 2001 From: vrenjith Date: Fri, 19 Jan 2024 23:40:51 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 66c4d1a..5081dc2 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ unless you access private repositories. - `token` - A GitHub or GitLab personal access token for REST API calls. The token does not need any scope: uncheck everything when creating the GitHub Token at [github.com/settings/personal-access-tokens/new](https://github.com/settings/personal-access-tokens/new), 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.com (self-hosted). +- `api_version` - For GithHub Enterprise: The version part that needs to be appended to the URL. E.g. `/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 file is named `page-authors.json`. - `exclude` - Specify a list of page source paths (one per line) that should not have author(s) or last commit date included (excluded from processing by this plugin). Default is empty. Examples: From b3d1a6c09e4e6b5c94bc3ee49a1e73f01cfd2624 Mon Sep 17 00:00:00 2001 From: Olivier Jacques Date: Sat, 24 Feb 2024 09:48:53 +0100 Subject: [PATCH 3/3] Add support for both GitHub and GitLab self-hosted --- README.md | 3 ++- mkdocs_git_committers_plugin_2/plugin.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 573ec61..4c817da 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/mkdocs_git_committers_plugin_2/plugin.py b/mkdocs_git_committers_plugin_2/plugin.py index 60d915c..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" + 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")