-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add GitLab fetcher #649
base: develop
Are you sure you want to change the base?
Add GitLab fetcher #649
Conversation
Hey, thanks for this PR! 🙏🏻 |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
cadbe62
to
e19728a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now at least the build is fixed.
For reference, here is the last build of lines with missing coverage.
We can try to mimic how GitHub was tested.
@@ -42,6 +42,9 @@ Remote style | |||
|
|||
Use the URL of the remote file. | |||
|
|||
Github |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a capital "H". 😅
Github | |
GitHub |
Please fix it everywhere if there are other places.
@@ -111,6 +114,85 @@ Or you can use an environment variable to avoid keeping secrets in plain text. | |||
A literal token cannot start with a ``$``. | |||
All tokens must not contain any ``@`` or ``:`` characters. | |||
|
|||
Gitlab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, capital "L". 😄
Gitlab | |
GitLab |
@@ -1,3 +1,4 @@ | |||
# pylint: disable=too-many-lines # TODO: refactor: break this into separate modules in a follow-up PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this and will fix it later on another PR, so this one stays small.
A literal token cannot start with a ``$``. | ||
All tokens must not contain any ``@`` or ``:`` characters. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read this far.
Good docs, thanks a lot. 👍🏻 👏🏻
I will try it out on some GitLab repo from gitlab.com (I don't have a self-hosted or paid versions).
def raise_gitlab_incorrect_url_error(url: furl) -> NoReturn: | ||
"""Raise an error if the URL is not a valid GitLab URL.""" | ||
message = f"Invalid GitLab URL: {url}" | ||
raise ValueError(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a private method on the GitLabURL
below since it's only used there.
if token is not None and token.startswith("$"): | ||
token = os.getenv(token[1:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this works, I haven't tried.
if token is not None and token.startswith("$"): | |
token = os.getenv(token[1:]) | |
if not token and token.startswith("$"): | |
token = os.getenv(token[1:]) |
@property | ||
def authorization_header(self) -> dict[Literal["PRIVATE-TOKEN"], str] | None: | ||
"""Authorization header encoded in this URL.""" | ||
return {"PRIVATE-TOKEN": self.token} if self.token else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could a constant in constants.py
:
GITLAB_TOKEN_KEY = "PRIVATE-TOKEN"
Or some similar name.
host=self.host, | ||
path=[*self.project, "-", "raw", self.git_reference, *self.path], | ||
query_params=self.query_params, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed this far, will continue later.
Thanks for the review! |
Just recently discovered nitpick and would love to get it added to my own team's setup, but we are also on a self-hosted GitLab instance. Is there still work being done on this by anyone? If not, I would be happy to try to make any changes to get it over the finish line. |
Hi, in fact, everything is ready here, we used this version on our project, you just need to add one test. |
Proposed changes
Hello Augusto,
Thank you for developing such a fantastic library!
I've been working on incorporating the ability to store style files on a self-hosted GitLab instance, which I noticed was missing from the library, so I took the initiative to add this feature.
I've made an effort to thoroughly document the nuances of interfacing with GitLab's API in the method docstrings. Unlike GitHub, GitLab's API relies on project IDs, while the GitLab website uses project paths. This distinction necessitated implementing functionality to support both behaviors.
I faced some challenges setting up the project, as I was unfamiliar with tox.
Currently, I've managed to write tests only for the URL generation, not for the Fetcher itself. I'm unsure which existing tests cover similar functionality.
If you could provide some guidance, I would be eager to fully complete the merge request. I'm relatively new to contributing to open source and would appreciate your help.
Checklist
make
locally before pushing commitsflake8
plugin (normal mode)flake8
plugin (offline mode)