Skip to content

Commit d415cc0

Browse files
author
Gauvain Pocentek
committed
Update the repository_blob documentation
Fixes #312
1 parent 5082879 commit d415cc0

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docs/gl_objects/projects.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@
142142
# end repository tree
143143

144144
# repository blob
145-
file_content = p.repository_blob('master', 'README.rst')
145+
items = project.repository_tree(path='docs', ref='branch1')
146+
file_info = p.repository_blob(items[0]['id'])
147+
content = base64.b64decode(file_info['content'])
148+
size = file_info['size']
146149
# end repository blob
147150

148151
# repository raw_blob

docs/gl_objects/projects.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ List the repository tree:
120120
:start-after: # repository tree
121121
:end-before: # end repository tree
122122

123-
Get the content of a file for a commit:
123+
Get the content and metadata of a file for a commit, using a blob sha:
124124

125125
.. literalinclude:: projects.py
126126
:start-after: # repository blob

gitlab/v4/objects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ def repository_tree(self, path='', ref='', **kwargs):
20242024
@cli.register_custom_action('Project', ('sha', ))
20252025
@exc.on_http_error(exc.GitlabGetError)
20262026
def repository_blob(self, sha, **kwargs):
2027-
"""Return a blob by blob SHA.
2027+
"""Return a file by blob SHA.
20282028
20292029
Args:
20302030
sha(str): ID of the blob
@@ -2035,7 +2035,7 @@ def repository_blob(self, sha, **kwargs):
20352035
GitlabGetError: If the server failed to perform the request
20362036
20372037
Returns:
2038-
str: The blob metadata
2038+
dict: The blob content and metadata
20392039
"""
20402040

20412041
path = '/projects/%s/repository/blobs/%s' % (self.get_id(), sha)

0 commit comments

Comments
 (0)