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

Commit58433d2

Browse files
author
Gauvain Pocentek
committed
CI: implement user get-by-username
fixes#95
1 parent7260684 commit58433d2

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

‎docs/cli.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ Get a specific project (id 2):
150150
151151
$ gitlab project get --id 2
152152
153+
Get a specific user by id or by username:
154+
155+
..code-block::console
156+
157+
$ gitlab user get --id 3
158+
$ gitlab user get-by-username --query jdoe
159+
153160
Get a list of snippets for this project:
154161

155162
..code-block::console

‎gitlab/cli.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
'all': {}},
4848
gitlab.User: {'block': {'required': ['id']},
4949
'unblock': {'required': ['id']},
50-
'search': {'required': ['query']}},
50+
'search': {'required': ['query']},
51+
'get-by-username': {'required': ['query']}},
5152
}
5253

5354

@@ -229,6 +230,12 @@ def do_user_search(self, cls, gl, what, args):
229230
exceptExceptionase:
230231
_die("Impossible to search users (%s)"%str(e))
231232

233+
defdo_user_getbyusername(self,cls,gl,what,args):
234+
try:
235+
returngl.users.search(args['query'])
236+
exceptExceptionase:
237+
_die("Impossible to get user %s (%s)"% (args['query'],str(e)))
238+
232239

233240
def_populate_sub_parser_by_class(cls,sub_parser):
234241
foraction_namein ['list','get','create','update','delete']:
@@ -370,7 +377,7 @@ def main():
370377
cli=GitlabCLI()
371378
method=None
372379
what=what.replace('-','_')
373-
action=action.lower()
380+
action=action.lower().replace('-','')
374381
fortestin ["do_%s_%s"% (what,action),
375382
"do_%s"%action]:
376383
ifhasattr(cli,test):

‎tools/functional_tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ testcase "user creation" '
3535
'
3636
USER_ID=$(pecho"${OUTPUT}"| grep ^id:| cut -d'' -f2)
3737

38+
testcase"user get (by id)"'
39+
GITLAB user get --id $USER_ID >/dev/null 2>&1
40+
'
41+
42+
testcase"user get (by username)"'
43+
GITLAB user get-by-username --query user1 >/dev/null 2>&1
44+
'
45+
3846
testcase"verbose output"'
3947
OUTPUT=$(try GITLAB -v user list) || exit 1
4048
pecho "${OUTPUT}" | grep -q avatar-url

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp