|
194 | 194 | # repository contributors
|
195 | 195 | contributors = project.repository_contributors()
|
196 | 196 | # end repository contributors
|
| 197 | + |
| 198 | +# files get |
| 199 | +f = gl.project_files.get(file_path='README.rst', ref='master', |
| 200 | + project_id=1) |
| 201 | +# or |
| 202 | +f = project.files.get(file_path='README.rst', ref='master') |
| 203 | + |
| 204 | +# get the base64 encoded content |
| 205 | +print(f.content) |
| 206 | + |
| 207 | +# get the decoded content |
| 208 | +print(f.decode()) |
| 209 | +# end files get |
| 210 | + |
| 211 | +# files create |
| 212 | +f = gl.project_files.create({'file_path': 'testfile', |
| 213 | + 'branch_name': 'master', |
| 214 | + 'content': file_content, |
| 215 | + 'commit_message': 'Create testfile'}, |
| 216 | + project_id=1) |
| 217 | +# or |
| 218 | +f = project.files.create({'file_path': 'testfile', |
| 219 | + 'branch_name': 'master', |
| 220 | + 'content': file_content, |
| 221 | + 'commit_message': 'Create testfile'}) |
| 222 | +# end files create |
| 223 | + |
| 224 | +# files update |
| 225 | +f.content = 'new content' |
| 226 | +f.save(branch='master', commit_message='Update testfile') |
| 227 | + |
| 228 | +# or for binary data |
| 229 | +f.content = base64.b64encode(open('image.png').read()) |
| 230 | +f.save(branch='master', commit_message='Update testfile', encoding='base64') |
| 231 | +# end files update |
| 232 | + |
| 233 | +# files delete |
| 234 | +gl.project_files.delete({'file_path': 'testfile', |
| 235 | + 'branch_name': 'master', |
| 236 | + 'commit_message': 'Delete testfile'}, |
| 237 | + project_id=1) |
| 238 | +# or |
| 239 | +project.files.delete({'file_path': 'testfile', |
| 240 | + 'branch_name': 'master', |
| 241 | + 'commit_message': 'Delete testfile'}) |
| 242 | +# or |
| 243 | +f.delete(commit_message='Delete testfile') |
| 244 | +# end files delete |
0 commit comments