FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support downloading archive subpaths by orf · Pull Request #2199 · python-gitlab/python-gitlab · GitHub

Repository navigation

Support downloading archive subpaths - #2199

Merged
nejch merged 1 commit into
python-gitlab:mainfrom
orf:patch-1
Jul 29, 2022
Merged

nejch merged 1 commit into
python-gitlab:mainfrom
orf:patch-1

Conversation

orf commented Jul 28, 2022

Copy link
Copy Markdown

https://docs.gitlab.com/ee/api/repositories.html#get-file-archive

The archive endpoint supports a path argument. This change adds support for it.

Comment thread gitlab/v4/objects/repositories.py Outdated
Comment thread gitlab/v4/objects/repositories.py Outdated
JohnVillalovos enabled auto-merge (rebase) July 28, 2022 17:22

Copy link
Copy Markdown
Member

@orf Thanks for the contribution!

JohnVillalovos disabled auto-merge July 28, 2022 17:31

JohnVillalovos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks like conflict with the pre-existing path variable.

nejch commented Jul 29, 2022

Copy link
Copy Markdown
Member

@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 _path here for example. Not sure how ugly that would get.

@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)

orf commented Jul 29, 2022

Copy link
Copy Markdown
Author

Thank you both! I've applied your suggestions 🙏

nejch commented Jul 29, 2022

Copy link
Copy Markdown
Member

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. :)

nejch merged commit 5e1df65 into python-gitlab:main Jul 29, 2022
orf deleted the patch-1 branch July 29, 2022 12:50

Copy link
Copy Markdown
Member

I guess we can get this one in, I hope you don't mind @JohnVillalovos ;)

Thanks for reviewing it @nejch !

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL