| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -170,6 +170,14 @@ Get the repository archive:: | |||
| 170 | 170 | # get the archive for a branch/tag/commit | |
| 171 | 171 | tgz = project.repository_archive(sha='4567abc') | |
| 172 | 172 | ||
| 173 | + # get the archive in a different format | ||
| 174 | + zip = project.repository_archive(format='zip') | ||
| 175 | + | ||
| 176 | + .. note:: | ||
| 177 | + | ||
| 178 | + For the formats available, refer to | ||
| 179 | + https://docs.gitlab.com/ce/api/repositories.html#get-file-archive | ||
| 180 | + | ||
| 173 | 181 | .. warning:: | |
| 174 | 182 | ||
| 175 | 183 | Archives are entirely stored in memory unless you use the streaming feature. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,12 +158,18 @@ def repository_contributors(self, **kwargs): | |||
| 158 | 158 | path = "/projects/%s/repository/contributors" % self.get_id() | |
| 159 | 159 | return self.manager.gitlab.http_list(path, **kwargs) | |
| 160 | 160 | ||
| 161 | - @cli.register_custom_action("Project", tuple(), ("sha",)) | ||
| 161 | + @cli.register_custom_action("Project", tuple(), ("sha", "format")) | ||
| 162 | 162 | @exc.on_http_error(exc.GitlabListError) | |
| 163 | 163 | def repository_archive( | |
| 164 | - self, sha=None, streamed=False, action=None, chunk_size=1024, **kwargs | ||
| 164 | + self, | ||
| 165 | + sha=None, | ||
| 166 | + streamed=False, | ||
| 167 | + action=None, | ||
| 168 | + chunk_size=1024, | ||
| 169 | + format=None, | ||
| 170 | + **kwargs | ||
| 165 | 171 | ): | |
| 166 | - """Return a tarball of the repository. | ||
| 172 | + """Return an archive of the repository. | ||
| 167 | 173 | ||
| 168 | 174 | Args: | |
| 169 | 175 | sha (str): ID of the commit (default branch by default) | |
@@ -173,6 +179,7 @@ def repository_archive( | |||
| 173 | 179 | action (callable): Callable responsible of dealing with chunk of | |
| 174 | 180 | data | |
| 175 | 181 | chunk_size (int): Size of each chunk | |
| 182 | + format (str): file format (tar.gz by default) | ||
| 176 | 183 | **kwargs: Extra options to send to the server (e.g. sudo) | |
| 177 | 184 | ||
| 178 | 185 | Raises: | |
@@ -183,6 +190,8 @@ def repository_archive( | |||
| 183 | 190 | str: The binary data of the archive | |
| 184 | 191 | """ | |
| 185 | 192 | path = "/projects/%s/repository/archive" % self.get_id() | |
| 193 | + if format: | ||
| 194 | + path += "." + format | ||
| 186 | 195 | query_data = {} | |
| 187 | 196 | if sha: | |
| 188 | 197 | query_data["sha"] = sha | |
| Back | FazBrowse Home | New Git URL |
0 commit comments