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

Commit8dfed0c

Browse files
nejchJohnVillalovos
authored andcommitted
fix(cli): allow custom methods in managers
1 parente0a3a41 commit8dfed0c

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

‎gitlab/v4/cli.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __call__(self) -> Any:
9494
returnself.do_custom()
9595

9696
defdo_custom(self)->Any:
97+
class_instance:Union[gitlab.base.RESTManager,gitlab.base.RESTObject]
9798
in_obj=cli.custom_actions[self.cls_name][self.action][2]
9899

99100
# Get the object (lazy), then act
@@ -106,11 +107,12 @@ def do_custom(self) -> Any:
106107
ifTYPE_CHECKING:
107108
assertisinstance(self.cls._id_attr,str)
108109
data[self.cls._id_attr]=self.args.pop(self.cls._id_attr)
109-
obj=self.cls(self.mgr,data)
110-
method_name=self.action.replace("-","_")
111-
returngetattr(obj,method_name)(**self.args)
110+
class_instance=self.cls(self.mgr,data)
112111
else:
113-
returngetattr(self.mgr,self.action)(**self.args)
112+
class_instance=self.mgr
113+
114+
method_name=self.action.replace("-","_")
115+
returngetattr(class_instance,method_name)(**self.args)
114116

115117
defdo_project_export_download(self)->None:
116118
try:

‎tests/functional/cli/conftest.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ def resp_get_project():
3333
"content_type":"application/json",
3434
"status":200,
3535
}
36+
37+
38+
@pytest.fixture
39+
defresp_delete_registry_tags_in_bulk():
40+
return {
41+
"method":responses.DELETE,
42+
"url":f"{DEFAULT_URL}/api/v4/projects/1/registry/repositories/1/tags",
43+
"status":202,
44+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
importpytest
2+
importresponses
3+
4+
5+
@pytest.mark.script_launch_mode("inprocess")
6+
@responses.activate
7+
deftest_project_registry_delete_in_bulk(
8+
script_runner,resp_delete_registry_tags_in_bulk
9+
):
10+
responses.add(**resp_delete_registry_tags_in_bulk)
11+
cmd= [
12+
"gitlab",
13+
"project-registry-tag",
14+
"delete-in-bulk",
15+
"--project-id",
16+
"1",
17+
"--repository-id",
18+
"1",
19+
"--name-regex-delete",
20+
"^.*dev.*$",
21+
# TODO: remove `name` after deleting without ID is possible
22+
# See #849 and #1631
23+
"--name",
24+
".*",
25+
]
26+
ret=ret=script_runner.run(*cmd)
27+
assertret.success

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp