Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71a2a4f

Browse files
author
Gauvain Pocentek
committed
docs: project repository API
1 parent7411907 commit71a2a4f

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

‎docs/gl_objects/projects.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,47 @@
150150
# or
151151
hook.delete()
152152
# end hook delete
153+
154+
# repository tree
155+
# list the content of the root directory for the default branch
156+
items=project.repository_tree()
157+
158+
# list the content of a subdirectory on a specific branch
159+
items=project.repository_tree(path='docs',ref='branch1')
160+
# end repository tree
161+
162+
# repository blob
163+
file_content=p.repository_blob('master','README.rst')
164+
# end repository blob
165+
166+
# repository raw_blob
167+
# find the id for the blob (simple search)
168+
id= [d['id']fordinp.repository_tree()ifd['name']=='README.rst'][0]
169+
170+
# get the content
171+
file_content=p.repository_raw_blob(id)
172+
# end repository raw_blob
173+
174+
# repository compare
175+
result=project.repository_compare('master','branch1')
176+
177+
# get the commits
178+
foriincommit:
179+
print(result.commits)
180+
181+
# get the diffs
182+
forfile_diffincommit.diffs:
183+
print(file_diff)
184+
# end repository compare
185+
186+
# repository archive
187+
# get the archive for the default branch
188+
tgz=project.repository_archive()
189+
190+
# get the archive for a branch/tag/commit
191+
tgz=project.repository_archive(sha='4567abc')
192+
# end repository archive
193+
194+
# repository contributors
195+
contributors=project.repository_contributors()
196+
# end repository contributors

‎docs/gl_objects/projects.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,57 @@ Archive/unarchive a project:
8888
conflict with a previous misuse of the ``archive`` method (deprecated but
8989
not yet removed).
9090

91+
Repository
92+
----------
93+
94+
The following examples show how you can manipulate the project code repository.
95+
96+
List the repository tree:
97+
98+
..literalinclude::projects.py
99+
:start-after: # repository tree
100+
:end-before: # end repository tree
101+
102+
Get the content of a file for a commit:
103+
104+
..literalinclude::projects.py
105+
:start-after: # repository blob
106+
:end-before: # end repository blob
107+
108+
Get the repository archive:
109+
110+
..literalinclude::projects.py
111+
:start-after: # repository archive
112+
:end-before: # end repository archive
113+
114+
..warning::
115+
116+
Archives are entirely stored in memory unless you use the streaming feature.
117+
See:ref:`the artifacts example<streaming_example>`.
118+
119+
Get the content of a file using the blob id:
120+
121+
..literalinclude::projects.py
122+
:start-after: # repository raw_blob
123+
:end-before: # end repository raw_blob
124+
125+
..warning::
126+
127+
Blobs are entirely stored in memory unless you use the streaming feature.
128+
See:ref:`the artifacts example<streaming_example>`.
129+
130+
Compare two branches, tags or commits:
131+
132+
..literalinclude::projects.py
133+
:start-after: # repository compare
134+
:end-before: # end repository compare
135+
136+
Get a list of contributors for the repository:
137+
138+
..literalinclude::projects.py
139+
:start-after: # repository contributors
140+
:end-before: # end repository contributors
141+
91142
Events
92143
------
93144

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp