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

Commit67f9537

Browse files
author
Philipp Busch
committed
Convert response list to single data source for iid requests
1 parent5f444e4 commit67f9537

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎gitlab/objects.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,22 @@ def __init__(self, gl, data=None, **kwargs):
377377
data=self.gitlab.get(self.__class__,data,**kwargs)
378378
self._from_api=True
379379

380+
# the API returned a list because custom kwargs where used
381+
# instead of the id to request an object. Usually parameters
382+
# other than an id return ambiguous results. However in the
383+
# gitlab universe iids together with a project_id are
384+
# unambiguous for merge requests and issues, too.
385+
# So if there is only one element we can use it as our data
386+
# source.
387+
if'iid'inkwargsandisinstance(data,list):
388+
iflen(data)<1:
389+
raiseGitlabGetError('Not found')
390+
eliflen(data)==1:
391+
data=data[0]
392+
else:
393+
raiseGitlabGetError('Impossible! You found multiple'
394+
' elements with the same iid.')
395+
380396
self._set_from_dict(data)
381397

382398
ifkwargs:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp