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

Commit12d195a

Browse files
jarodwilsonJohnVillalovos
authored andcommitted
feat: more usernames support for MR approvals
I don't think commita2b8c8c went far enough to enable usernamessupport. We create and edit a lot of approval rules based on an externalservice (similar to CODE_OWNERS), but only have the usernames available,and currently, have to look up each user to get their user ID to populateuser_ids for .set_approvers() calls. Would very much like to skip thelookup and just send the usernames, which this change should allow.See:https://docs.gitlab.com/ee/api/merge_request_approvals.html#create-project-level-ruleSigned-off-by: Jarod Wilson <jarod@redhat.com>
1 parent58d50f2 commit12d195a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎gitlab/v4/objects/merge_request_approvals.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def set_approvers(
8989
approver_ids:Optional[List[int]]=None,
9090
approver_group_ids:Optional[List[int]]=None,
9191
approval_rule_name:str="name",
92+
*,
93+
approver_usernames:Optional[List[str]]=None,
9294
**kwargs:Any,
9395
)->RESTObject:
9496
"""Change MR-level allowed approvers and approver groups.
@@ -104,13 +106,15 @@ def set_approvers(
104106
"""
105107
approver_ids=approver_idsor []
106108
approver_group_ids=approver_group_idsor []
109+
approver_usernames=approver_usernamesor []
107110

108111
data= {
109112
"name":approval_rule_name,
110113
"approvals_required":approvals_required,
111114
"rule_type":"regular",
112115
"user_ids":approver_ids,
113116
"group_ids":approver_group_ids,
117+
"usernames":approver_usernames,
114118
}
115119
ifTYPE_CHECKING:
116120
assertself._parentisnotNone
@@ -124,6 +128,7 @@ def set_approvers(
124128
ar.user_ids=data["user_ids"]
125129
ar.approvals_required=data["approvals_required"]
126130
ar.group_ids=data["group_ids"]
131+
ar.usernames=data["usernames"]
127132
ar.save()
128133
returnar
129134
# if there was no rule matching the rule name, create a new one
@@ -145,14 +150,14 @@ class ProjectMergeRequestApprovalRuleManager(CRUDMixin, RESTManager):
145150
"name",
146151
"approvals_required",
147152
),
148-
optional=("user_ids","group_ids"),
153+
optional=("user_ids","group_ids","usernames"),
149154
)
150155
# Important: When approval_project_rule_id is set, the name, users and
151156
# groups of project-level rule will be copied. The approvals_required
152157
# specified will be used.
153158
_create_attrs=RequiredOptional(
154159
required=("name","approvals_required"),
155-
optional=("approval_project_rule_id","user_ids","group_ids"),
160+
optional=("approval_project_rule_id","user_ids","group_ids","usernames"),
156161
)
157162

158163
defget(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp