-
Notifications
You must be signed in to change notification settings - Fork 668
Support downloading archive subpaths #2199
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
Conversation
@orf Thanks for the contribution! |
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.
Looks like conflict with the pre-existing path
variable.
@JohnVillalovos for later: we could potentially also prefix these internal python-gitlab variables in the mixins and custom methods to always avoid clashes with GitLab API attributes. So this would be @orf sometimes our variables happen to overlap with upstream API attributes hence the suggestion. diff --git a/gitlab/v4/objects/repositories.py b/gitlab/v4/objects/repositories.py
index 8f99e5d..b8dbdd8 100644
--- a/gitlab/v4/objects/repositories.py
+++ b/gitlab/v4/objects/repositories.py
@@ -229,16 +229,16 @@ class RepositoryMixin(_RestObjectBase):
Returns:
The binary data of the archive
"""
- path = f"/projects/{self.encoded_id}/repository/archive"
+ url_path = f"/projects/{self.encoded_id}/repository/archive"
if format:
- path += "." + format
+ url_path += "." + format
query_data = {}
if sha:
query_data["sha"] = sha
if path is not None:
query_data["path"] = path
result = self.manager.gitlab.http_get(
- path, query_data=query_data, raw=True, streamed=streamed, **kwargs
+ url_path, query_data=query_data, raw=True, streamed=streamed, **kwargs
)
if TYPE_CHECKING:
assert isinstance(result, requests.Response) |
Thank you both! I've applied your suggestions 🙏 |
I guess we can get this one in, I hope you don't mind @JohnVillalovos ;) @orf thanks again! I think I recognized your username from the loguru saga, fun popcorn material. :) |
Thanks for reviewing it @nejch ! |
https://docs.gitlab.com/ee/api/repositories.html#get-file-archive
The archive endpoint supports a
path
argument. This change adds support for it.