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

insider: git-committers shows GitHub, even for GitLab repositories #6283

Closed
4 tasks done
ojacques opened this issue Nov 3, 2023 · 11 comments
Closed
4 tasks done

insider: git-committers shows GitHub, even for GitLab repositories #6283

ojacques opened this issue Nov 3, 2023 · 11 comments
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open

Comments

@ojacques
Copy link
Contributor

ojacques commented Nov 3, 2023

Context

No response

Bug description

When using the mkdocs-git-committers-plugin-2 v2.1.0, which now supports GitLab repositories, the contributors are next to a GitHub logo and text.

image

I expect this to be GitLab logo and text.

Related links

Reproduction

demo.zip

Steps to reproduce

  1. Start a new mkdocs material site on gitlab
  2. Activate the committers plugin:
plugins:
  - git-committers:
      gitlab_repository: 12345678
      token: !ENV ["GH_TOKEN"]
  1. Render the site
  2. At the bottom of the page, see GitHub logo and text

image

Browser

No response

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting. How can we distinguish this in the template? We need some way to decide what icon to show with a simple {% if %}...{% else %} condition. See the relevant section here (Insiders).

@squidfunk squidfunk added change request Issue requests a new feature or improvement needs input Issue needs further input by the reporter labels Nov 3, 2023
@ojacques
Copy link
Contributor Author

ojacques commented Nov 3, 2023

I was thinking that checking author.url for github or gitlab would work. But for self-hosted GitHub or GitLab, you can't be sure that the url will contain github or gitlab.
Is that OK for you if I add a source field (author.source) to the author object, and make it either github or gitlab?

@squidfunk
Copy link
Owner

squidfunk commented Nov 3, 2023

Is that OK for you if I add a source field (author.source) to the author object, and make it either github or gitlab?

Sounds perfect! Once that's implemented, we can directly make the necessary changes – it's just changing an icon and a description after all.

@ojacques
Copy link
Contributor Author

ojacques commented Nov 3, 2023

Done in mkdocs-git-committers-plugin-2 2.2.0.

@squidfunk
Copy link
Owner

squidfunk commented Nov 3, 2023

Thanks! I'm not sure how to use it. Is source defined per author? That's kind of weird, because we would need to hoist the value then, and it is the same for all authors, isn't it? Our templates are like this:

SOURCE
each AUTHOR of AUTHORS
  AUTHOR

Maybe I've misread ojacques/mkdocs-git-committers-plugin-2@1c1ff87, but that's how I understand it.

@ojacques
Copy link
Contributor Author

ojacques commented Nov 3, 2023

Hmmm. I thought it was easier for you to have source repeated for all authors (although, I agree it does not make sense, it is the same for all authors of a given repo).
I will hoist source up in the context, in committers-source (I don't want to override another potential source).

@ojacques
Copy link
Contributor Author

ojacques commented Nov 3, 2023

Done in https://github.com/ojacques/mkdocs-git-committers-plugin-2/releases/tag/2.2.1.
committers-source equals github or gitlab.

@squidfunk
Copy link
Owner

Sorry to bother again, but as far as I know, a variable cannot include - in its name. At least I don't know how to reference them in templates. I would recommend switching to _. I've never seen variables using - 😉 Error:

...
    {% if committers-source == "gitlab" %}
^^^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'source' is undefined

@squidfunk
Copy link
Owner

I've made all changes, took the opportunity to modularize the template (to make it ready for more integrations with git-related plugins) and pushed everything in 3b7632a. If you switch committers-source to committers_source it should work right away. The default is that it falls back to GitHub, so it will also work with older versions of the plugin 🚀

@squidfunk squidfunk added resolved Issue is resolved, yet unreleased if open and removed needs input Issue needs further input by the reporter labels Nov 4, 2023
@ojacques
Copy link
Contributor Author

ojacques commented Nov 4, 2023

All set in 2.2.2.
Thanks!

@squidfunk
Copy link
Owner

Released as part of 9.4.8+insiders-4.43.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants