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

Commit802c144

Browse files
author
Gauvain Pocentek
committed
Fix the update/delete CLI subcommands
Also update the testing tool to test these features.Closes#62
1 parente57b779 commit802c144

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

‎gitlab/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,11 @@ class GitlabObject(object):
643643
requiredCreateAttrs= []
644644
#: Attributes that are optional when creating a new object
645645
optionalCreateAttrs= []
646+
#: Attributes that are required when updating an object
647+
requiredUpdateAttrs=None
648+
#: Attributes that are optional when updating an object
649+
optionalUpdateAttrs=None
650+
646651
idAttr='id'
647652
shortPrintAttr=None
648653

@@ -1086,6 +1091,7 @@ class ProjectLabel(GitlabObject):
10861091
idAttr='name'
10871092
requiredDeleteAttrs= ['name']
10881093
requiredCreateAttrs= ['name','color']
1094+
requiredUpdateAttrs= []
10891095
# FIXME: new_name is only valid with update
10901096
optionalCreateAttrs= ['new_name']
10911097

@@ -1157,6 +1163,7 @@ class Project(GitlabObject):
11571163
_url='/projects'
11581164
_constructorTypes= {'owner':'User','namespace':'Group'}
11591165
requiredCreateAttrs= ['name']
1166+
requiredUpdateAttrs= []
11601167
optionalCreateAttrs= ['default_branch','issues_enabled','wall_enabled',
11611168
'merge_requests_enabled','wiki_enabled',
11621169
'snippets_enabled','public','visibility_level',

‎gitlab/cli.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,23 @@ def populate_sub_parser_by_class(cls, sub_parser):
103103
forxincls.optionalCreateAttrs]
104104

105105
elifaction_name==UPDATE:
106+
id_attr=cls.idAttr.replace('_','-')
107+
sub_parser_action.add_argument("--%s"%id_attr,
108+
required=True)
109+
110+
attrs= (cls.requiredUpdateAttrs
111+
ifcls.requiredUpdateAttrsisnotNone
112+
elsecls.requiredCreateAttrs)
106113
[sub_parser_action.add_argument("--%s"%x.replace('_','-'),
107114
required=True)
108-
forxincls.requiredCreateAttrs]
115+
forxinattrs]
116+
117+
attrs= (cls.optionalUpdateAttrs
118+
ifcls.optionalUpdateAttrsisnotNone
119+
elsecls.optionalCreateAttrs)
109120
[sub_parser_action.add_argument("--%s"%x.replace('_','-'),
110121
required=False)
111-
forxincls.optionalCreateAttrs]
122+
forxinattrs]
112123

113124
ifclsinextra_actions:
114125
foraction_nameinsorted(extra_actions[cls]):
@@ -182,7 +193,7 @@ def do_delete(cls, gl, what, args):
182193
ifnotcls.canDelete:
183194
die("%s objects can't be deleted"%what)
184195

185-
o=do_get(cls,args,what,args)
196+
o=do_get(cls,gl,what,args)
186197
try:
187198
o.delete()
188199
exceptExceptionase:
@@ -193,7 +204,7 @@ def do_update(cls, gl, what, args):
193204
ifnotcls.canUpdate:
194205
die("%s objects can't be updated"%what)
195206

196-
o=do_get(cls,args,what,args)
207+
o=do_get(cls,gl,what,args)
197208
try:
198209
fork,vinargs.items():
199210
o.__dict__[k]=v

‎tools/functional_tests.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cleanup() {
2323
}
2424
trap cleanup EXIT
2525

26-
docker run --name gitlab-test --detach --publish 8080:80 --publish 2222:22sytse/gitlab-ce:7.10.1>/dev/null2>&1
26+
docker run --name gitlab-test --detach --publish 8080:80 --publish 2222:22genezys/gitlab:latest>/dev/null2>&1
2727

2828
LOGIN='root'
2929
PASSWORD='5iveL!fe'
@@ -80,6 +80,14 @@ PROJECT_ID=$($GITLAB project create --name test-project1 | grep ^id: | cut -d' '
8080
$GITLAB project list| grep -q test-project1
8181
$OK
8282

83+
echo -n"Testing project update..."
84+
$GITLAB project update --id$PROJECT_ID --description"My New Description"
85+
$OK
86+
87+
echo -n"Testing project deletion..."
88+
$GITLAB project delete --id$PROJECT_ID
89+
$OK
90+
8391
echo -n"Testing user creation..."
8492
USER_ID=$($GITLAB user create --email fake@email.com --username user1 --name"User One" --password fakepassword| grep ^id:| cut -d'' -f2)
8593
$OK

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp