Skip to content

Commit 9d594d3

Browse files
committed
Add Issue.close() and Issue.reopen() functions
1 parent c4afa44 commit 9d594d3

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ project.delete_member('user_id')
8282
# Issues
8383
issues = project.issues(limit=10)
8484
issue = project.add_issue('title', description='description')
85-
issue.create_note('note body')
85+
issue.add_note('note body')
86+
issue.close()
87+
issue.reopen()
8688

8789
# Snippets
8890
snippet = project.add_snippet('title', 'file_name', 'code')

gitlab3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _add_api(definition, parent):
263263
cls = type(cls_name, (_GitLabAPI,), cls_attrs)
264264

265265
if _LIST in definition.actions:
266-
list_fn = _add_list_fn(cls, definition, parent)
266+
_add_list_fn(cls, definition, parent)
267267
_add_find_fn(cls, name, parent)
268268
if _GET in definition.actions:
269269
_add_get_fn(cls, name, parent)

gitlab3/_api_definition.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ class Issue(APIDefinition):
243243
'state_event',
244244
]
245245
sub_apis = [ Note ]
246+
class CloseAction(ExtraActionDefinition):
247+
"""gl.Project.Issue.close()"""
248+
method = _HTTP_PUT
249+
required_params = [ 'state_event' ]
250+
_state_after = 'closed'
251+
@classmethod
252+
def wrapper(cls, extra_action_fn, parent):
253+
def wrapped(self):
254+
extra_action_fn(self, state_event=cls.name())
255+
setattr(self, 'state', cls._state_after)
256+
return wrapped
257+
class ReopenAction(CloseAction):
258+
_state_after = 'reopened'
259+
260+
extra_actions = [ CloseAction, ReopenAction ]
261+
246262

247263
class Branch(APIDefinition):
248264
url = '/repository/branches/:branch'
@@ -438,7 +454,6 @@ class AddProjectForUserAction(ExtraActionDefinition):
438454
'snippets_enabled',
439455
'public',
440456
]
441-
442457
@staticmethod
443458
def wrapper(extra_action_fn, parent):
444459
def wrapped(*args, **kwargs):

0 commit comments

Comments
 (0)