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

Commit9dd410f

Browse files
author
Gauvain Pocentek
committed
Fix the CLI for objects without ID (API v4)
Fixes#319
1 parentd415cc0 commit9dd410f

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

‎gitlab/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get(self, id, lazy=False, **kwargs):
5151

5252
classGetWithoutIdMixin(object):
5353
@exc.on_http_error(exc.GitlabGetError)
54-
defget(self,**kwargs):
54+
defget(self,id=None,**kwargs):
5555
"""Retrieve a single object.
5656
5757
Args:

‎gitlab/v4/cli.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def do_list(self):
8383

8484
defdo_get(self):
8585
id=None
86-
ifgitlab.mixins.GetWithoutIdMixinnotininspect.getmro(self.cls):
86+
ifgitlab.mixins.GetWithoutIdMixinnotininspect.getmro(self.mgr_cls):
8787
id=self.args.pop(self.cls._id_attr)
8888

8989
try:
@@ -99,7 +99,9 @@ def do_delete(self):
9999
cli.die("Impossible to destroy object",e)
100100

101101
defdo_update(self):
102-
id=self.args.pop(self.cls._id_attr)
102+
id=None
103+
ifgitlab.mixins.GetWithoutIdMixinnotininspect.getmro(self.mgr_cls):
104+
id=self.args.pop(self.cls._id_attr)
103105
try:
104106
returnself.mgr.update(id,self.args)
105107
exceptExceptionase:
@@ -282,15 +284,18 @@ def display_dict(d, padding):
282284
return
283285

284286
# not a dict, we assume it's a RESTObject
285-
id=getattr(obj,obj._id_attr,None)
286-
print('%s: %s'% (obj._id_attr,id))
287+
ifobj._id_attr:
288+
id=getattr(obj,obj._id_attr,None)
289+
print('%s: %s'% (obj._id_attr,id))
287290
attrs=obj.attributes
288-
attrs.pop(obj._id_attr)
291+
ifobj._id_attr:
292+
attrs.pop(obj._id_attr)
289293
display_dict(attrs,padding)
290294

291295
else:
292-
id=getattr(obj,obj._id_attr)
293-
print('%s: %s'% (obj._id_attr.replace('_','-'),id))
296+
ifobj._id_attr:
297+
id=getattr(obj,obj._id_attr)
298+
print('%s: %s'% (obj._id_attr.replace('_','-'),id))
294299
ifhasattr(obj,'_short_print_attr'):
295300
value=getattr(obj,obj._short_print_attr)
296301
print('%s: %s'% (obj._short_print_attr,value))

‎tools/cli_test_v4.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,18 @@ testcase "branch deletion" '
9595
'
9696

9797
testcase"project upload"'
98-
GITLAB project upload --id "$PROJECT_ID" --filename'$(basename$0)' --filepath'$0'
98+
GITLAB project upload --id "$PROJECT_ID" \
99+
--filename'$(basename$0)' --filepath'$0' >/dev/null 2>&1
99100
'
100101

101102
testcase"project deletion"'
102103
GITLAB project delete --id "$PROJECT_ID"
103104
'
105+
106+
testcase"application settings get"'
107+
GITLAB application-settings get >/dev/null 2>&1
108+
'
109+
110+
testcase"application settings update"'
111+
GITLAB application-settings update --signup-enabled false
112+
'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp