10000 fix(api): use ID instead of name for GroupLabel & ProjectLabel _id_attr · python-gitlab/python-gitlab@2cbd674 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cbd674

Browse files
ptalbertnejch
authored andcommitted
fix(api): use ID instead of name for GroupLabel & ProjectLabel _id_attr
_id_attr is used when comparing RESTObject objects. Labels will be seen as equal when they have the same name even if they are from different groups or projects. Instead, use the label's ID as the _id_attr so that comparisions will only be equal if they truly represent the same gitlab label object. Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
1 parent c378817 commit 2cbd674

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gitlab/v4/objects/labels.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424

2525
class GroupLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
26-
_id_attr = "name"
26+
_id_attr = "id"
27+
_repr_attr = "name"
2728
manager: "GroupLabelManager"
2829

2930
# Update without ID, but we need an ID to get from list.
@@ -87,7 +88,8 @@ def update( # type: ignore
8788
class ProjectLabel(
8889
PromoteMixin, SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject
8990
):
90-
_id_attr = "name"
91+
_id_attr = "id"
92+
_repr_attr = "name"
9193
manager: "ProjectLabelManager"
9294

9395
# Update without ID, but we need an ID to get from list.

0 commit comments

Comments
 (0)
0