diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-29 13:31:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 13:31:31 +0200 |
commit | 5e1df653e22cfbd1a2c1054d1c9b684f90e8c283 (patch) | |
tree | 73d8acd26ba45200d97931b2f856bea4c66ab89d | |
parent | b8be32ae17fb59c5df080a9f7948fdff34b7d421 (diff) | |
parent | cadb0e55347cdac149e49f611c99b9d53a105520 (diff) | |
download | gitlab-5e1df653e22cfbd1a2c1054d1c9b684f90e8c283.tar.gz |
Merge pull request #2199 from orf/patch-1
Support downloading archive subpaths
-rw-r--r-- | gitlab/v4/objects/repositories.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gitlab/v4/objects/repositories.py b/gitlab/v4/objects/repositories.py index e968a6a..b8dbdd8 100644 --- a/gitlab/v4/objects/repositories.py +++ b/gitlab/v4/objects/repositories.py @@ -201,6 +201,7 @@ class RepositoryMixin(_RestObjectBase): action: Optional[Callable[..., Any]] = None, chunk_size: int = 1024, format: Optional[str] = None, + path: Optional[str] = None, *, iterator: bool = False, **kwargs: Any, @@ -218,6 +219,7 @@ class RepositoryMixin(_RestObjectBase): data chunk_size: Size of each chunk format: file format (tar.gz by default) + path: The subpath of the repository to download (all files by default) **kwargs: Extra options to send to the server (e.g. sudo) Raises: @@ -227,14 +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) |