summaryrefslogtreecommitdiff
path: root/docs/gl_objects
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-08-09 16:07:25 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-08-09 16:07:25 +0200
commit71a2a4fb84321e73418fda1ce4e4d47177af928c (patch)
tree95a83c11f7199b7e1b68bef65cafe550c9f64a82 /docs/gl_objects
parent74119073dae18214df1dd67ded6cd57abda335d4 (diff)
downloadgitlab-71a2a4fb84321e73418fda1ce4e4d47177af928c.tar.gz
docs: project repository API
Diffstat (limited to 'docs/gl_objects')
-rw-r--r--docs/gl_objects/projects.py44
-rw-r--r--docs/gl_objects/projects.rst51
2 files changed, 95 insertions, 0 deletions
diff --git a/docs/gl_objects/projects.py b/docs/gl_objects/projects.py
index 6898282..6a7cb6d 100644
--- a/docs/gl_objects/projects.py
+++ b/docs/gl_objects/projects.py
@@ -150,3 +150,47 @@ project.hooks.delete(1)
# or
hook.delete()
# end hook delete
+
+# repository tree
+# list the content of the root directory for the default branch
+items = project.repository_tree()
+
+# list the content of a subdirectory on a specific branch
+items = project.repository_tree(path='docs', ref='branch1')
+# end repository tree
+
+# repository blob
+file_content = p.repository_blob('master', 'README.rst')
+# end repository blob
+
+# repository raw_blob
+# find the id for the blob (simple search)
+id = [d['id'] for d in p.repository_tree() if d['name'] == 'README.rst'][0]
+
+# get the content
+file_content = p.repository_raw_blob(id)
+# end repository raw_blob
+
+# repository compare
+result = project.repository_compare('master', 'branch1')
+
+# get the commits
+for i in commit:
+ print(result.commits)
+
+# get the diffs
+for file_diff in commit.diffs:
+ print(file_diff)
+# end repository compare
+
+# repository archive
+# get the archive for the default branch
+tgz = project.repository_archive()
+
+# get the archive for a branch/tag/commit
+tgz = project.repository_archive(sha='4567abc')
+# end repository archive
+
+# repository contributors
+contributors = project.repository_contributors()
+# end repository contributors
diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst
index 294c3f2..ee55e74 100644
--- a/docs/gl_objects/projects.rst
+++ b/docs/gl_objects/projects.rst
@@ -88,6 +88,57 @@ Archive/unarchive a project:
conflict with a previous misuse of the ``archive`` method (deprecated but
not yet removed).
+Repository
+----------
+
+The following examples show how you can manipulate the project code repository.
+
+List the repository tree:
+
+.. literalinclude:: projects.py
+ :start-after: # repository tree
+ :end-before: # end repository tree
+
+Get the content of a file for a commit:
+
+.. literalinclude:: projects.py
+ :start-after: # repository blob
+ :end-before: # end repository blob
+
+Get the repository archive:
+
+.. literalinclude:: projects.py
+ :start-after: # repository archive
+ :end-before: # end repository archive
+
+.. warning::
+
+ Archives are entirely stored in memory unless you use the streaming feature.
+ See :ref:`the artifacts example <streaming_example>`.
+
+Get the content of a file using the blob id:
+
+.. literalinclude:: projects.py
+ :start-after: # repository raw_blob
+ :end-before: # end repository raw_blob
+
+.. warning::
+
+ Blobs are entirely stored in memory unless you use the streaming feature.
+ See :ref:`the artifacts example <streaming_example>`.
+
+Compare two branches, tags or commits:
+
+.. literalinclude:: projects.py
+ :start-after: # repository compare
+ :end-before: # end repository compare
+
+Get a list of contributors for the repository:
+
+.. literalinclude:: projects.py
+ :start-after: # repository contributors
+ :end-before: # end repository contributors
+
Events
------