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

Commit8703324

Browse files
nejchJohnVillalovos
authored andcommitted
feat(issues): add support for issue reorder API
1 parent4882cb2 commit8703324

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

‎docs/gl_objects/issues.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ Move an issue to another project::
153153

154154
issue.move(other_project_id)
155155

156+
Reorder an issue on a board::
157+
158+
issue.reorder(move_after_id=2, move_before_id=3)
159+
156160
Make an issue as todo::
157161

158162
issue.todo()

‎gitlab/v4/objects/issues.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fromtypingimportAny,cast,Dict,Tuple,TYPE_CHECKING,Union
1+
fromtypingimportAny,cast,Dict,Optional,Tuple,TYPE_CHECKING,Union
22

33
fromgitlabimportcli
44
fromgitlabimportexceptionsasexc
@@ -140,6 +140,38 @@ def move(self, to_project_id: int, **kwargs: Any) -> None:
140140
assertisinstance(server_data,dict)
141141
self._update_attrs(server_data)
142142

143+
@cli.register_custom_action("ProjectIssue", ("move_after_id","move_before_id"))
144+
@exc.on_http_error(exc.GitlabUpdateError)
145+
defreorder(
146+
self,
147+
move_after_id:Optional[int]=None,
148+
move_before_id:Optional[int]=None,
149+
**kwargs:Any,
150+
)->None:
151+
"""Reorder an issue on a board.
152+
153+
Args:
154+
move_after_id: ID of an issue that should be placed after this issue
155+
move_before_id: ID of an issue that should be placed before this issue
156+
**kwargs: Extra options to send to the server (e.g. sudo)
157+
158+
Raises:
159+
GitlabAuthenticationError: If authentication is not correct
160+
GitlabUpdateError: If the issue could not be reordered
161+
"""
162+
path=f"{self.manager.path}/{self.encoded_id}/reorder"
163+
data:Dict[str,Any]= {}
164+
165+
ifmove_after_idisnotNone:
166+
data["move_after_id"]=move_after_id
167+
ifmove_before_idisnotNone:
168+
data["move_before_id"]=move_before_id
169+
170+
server_data=self.manager.gitlab.http_put(path,post_data=data,**kwargs)
171+
ifTYPE_CHECKING:
172+
assertisinstance(server_data,dict)
173+
self._update_attrs(server_data)
174+
143175
@cli.register_custom_action("ProjectIssue")
144176
@exc.on_http_error(exc.GitlabGetError)
145177
defrelated_merge_requests(self,**kwargs:Any)->Dict[str,Any]:

‎tests/unit/objects/test_issues.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ def resp_get_issue():
4141
yieldrsps
4242

4343

44+
@pytest.fixture
45+
defresp_reorder_issue():
46+
match_params= {"move_after_id":2,"move_before_id":3}
47+
withresponses.RequestsMock()asrsps:
48+
rsps.add(
49+
method=responses.PUT,
50+
url="http://localhost/api/v4/projects/1/issues/1/reorder",
51+
json={"name":"name","id":1},
52+
content_type="application/json",
53+
status=200,
54+
match=[responses.matchers.json_params_matcher(match_params)],
55+
)
56+
yieldrsps
57+
58+
4459
@pytest.fixture
4560
defresp_issue_statistics():
4661
content= {"statistics": {"counts": {"all":20,"closed":5,"opened":15}}}
@@ -70,6 +85,11 @@ def test_get_issue(gl, resp_get_issue):
7085
assertissue.name=="name"
7186

7287

88+
deftest_reorder_issue(project,resp_reorder_issue):
89+
issue=project.issues.get(1,lazy=True)
90+
issue.reorder(move_after_id=2,move_before_id=3)
91+
92+
7393
deftest_get_issues_statistics(gl,resp_issue_statistics):
7494
statistics=gl.issues_statistics.get()
7595
assertisinstance(statistics,IssuesStatistics)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp