1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix: GitLab API searches always return first found match (#3400) (#3449)

* fix: return correct group id
match only full_path or name

* chore: add changelog fragment

* fix: indentation multiple of four

* refactor: use two loops

* fix: typo of group id

* fix: changelog fragment

(cherry picked from commit b6b7601615)

Co-authored-by: Chris Frage <chris.frage@cancom.de>
This commit is contained in:
patchback[bot] 2021-09-26 19:49:02 +02:00 committed by GitHub
parent b610b654cc
commit 745da8e325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- gitlab_group_members - ``get_group_id`` return the group ID by matching ``full_path``, ``path`` or ``name`` (https://github.com/ansible-collections/community.general/pull/3400).

View file

@ -102,9 +102,13 @@ class GitLabGroup(object):
# get group id if group exists
def get_group_id(self, gitlab_group):
group_exists = self._gitlab.groups.list(search=gitlab_group)
if group_exists:
return group_exists[0].id
groups = self._gitlab.groups.list(search=gitlab_group)
for group in groups:
if group.full_path == gitlab_group:
return group.id
for group in groups:
if group.path == gitlab_group or group.name == gitlab_group:
return group.id
# get all members in a group
def get_members_in_a_group(self, gitlab_group_id):