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

Commitfc8affd

Browse files
author
Gauvain Pocentek
committed
Fix Project.tree()
Add API tests for tree(), blob() and archive().
1 parent141f21a commitfc8affd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

‎gitlab/objects.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,14 +1207,20 @@ def Tag(self, id=None, **kwargs):
12071207
**kwargs)
12081208

12091209
deftree(self,path='',ref_name='',**kwargs):
1210-
url="%s/%s/repository/tree"% (self._url,self.id)
1211-
url+='?path=%s&ref_name=%s'% (path,ref_name)
1210+
url="/projects/%s/repository/tree"% (self.id)
1211+
params= []
1212+
ifpath:
1213+
params.append("path=%s"%path)
1214+
ifref_name:
1215+
params.append("ref_name=%s"%ref_name)
1216+
ifparams:
1217+
url+='?'+"&".join(params)
12121218
r=self.gitlab._raw_get(url,**kwargs)
12131219
raise_error_from_response(r,GitlabGetError)
12141220
returnr.json()
12151221

12161222
defblob(self,sha,filepath,**kwargs):
1217-
url="%s/%s/repository/blobs/%s"% (self._url,self.id,sha)
1223+
url="/projects/%s/repository/blobs/%s"% (self.id,sha)
12181224
url+='?filepath=%s'% (filepath)
12191225
r=self.gitlab._raw_get(url,**kwargs)
12201226
raise_error_from_response(r,GitlabGetError)

‎tools/python_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@
121121
readme=admin_project.files.get(file_path='README.rst',ref='master')
122122
assert(readme.decode()=='Initial content')
123123

124+
tree=admin_project.tree()
125+
assert(len(tree)==1)
126+
assert(tree[0]['name']=='README.rst')
127+
blob=admin_project.blob('master','README.rst')
128+
assert(blob=='Initial content')
129+
archive1=admin_project.archive()
130+
archive2=admin_project.archive('master')
131+
assert(archive1==archive2)
132+
124133
# labels
125134
label1=admin_project.labels.create({'name':'label1','color':'#778899'})
126135
label1=admin_project.labels.get('label1')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp