summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Forbes <tom.forbes@onfido.com>2022-07-28 17:34:49 +0100
committerTom Forbes <tom.forbes@onfido.com>2022-07-29 11:59:12 +0100
commitcadb0e55347cdac149e49f611c99b9d53a105520 (patch)
tree623998a6223e2490857072497f311b38acf0cd47
parent8ba97aa459420ec5ae824d9299d6564656841559 (diff)
downloadgitlab-cadb0e55347cdac149e49f611c99b9d53a105520.tar.gz
feat: Support downloading archive subpaths
-rw-r--r--gitlab/v4/objects/repositories.py10
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)