Verified Commit f71dd382 authored by Levente Polyak's avatar Levente Polyak 🚀
Browse files

fix(gitlab): match gitlab members by gitlab-id istead of username

parent 3d400885
......@@ -250,18 +250,25 @@ impl GitLabGlue {
let mut summary = PlanSummary::new("GitLab 'Arch Linux' group members");
let state = self.state.lock().await;
let gitlab_group_member_names = archlinux_group_members
let gitlab_group_members = archlinux_group_members
.iter()
.map(|e| e.username.clone())
.map(|e| e.id)
.collect::<Vec<_>>();
for staff in state.staff() {
if !gitlab_group_member_names.contains(&staff.username)
&& self
.add_group_member(action, staff, group, DEFAULT_ARCH_LINUX_GROUP_ACCESS_LEVEL)
.await?
{
summary.add += 1;
if let Some(gitlab_id) = staff.gitlab_id {
if !gitlab_group_members.contains(&gitlab_id)
&& self
.add_group_member(
action,
staff,
group,
DEFAULT_ARCH_LINUX_GROUP_ACCESS_LEVEL,
)
.await?
{
summary.add += 1;
}
}
}
......@@ -308,18 +315,20 @@ impl GitLabGlue {
let mut summary = PlanSummary::new("GitLab 'Arch Linux/Teams/Staff' group members");
let state = self.state.lock().await;
let gitlab_group_member_names = archlinux_group_members
let gitlab_group_members = archlinux_group_members
.iter()
.map(|e| e.username.clone())
.map(|e| e.id)
.collect::<Vec<_>>();
for staff in state.staff() {
if !gitlab_group_member_names.contains(&staff.username)
&& self
.add_group_member(action, staff, group, DEFAULT_STAFF_GROUP_ACCESS_LEVEL)
.await?
{
summary.add += 1;
if let Some(gitlab_id) = staff.gitlab_id {
if !gitlab_group_members.contains(&gitlab_id)
&& self
.add_group_member(action, staff, group, DEFAULT_STAFF_GROUP_ACCESS_LEVEL)
.await?
{
summary.add += 1;
}
}
}
......@@ -364,24 +373,23 @@ impl GitLabGlue {
let devops_group = "archlinux/teams/devops";
let group_members = self.get_group_members(devops_group).await?;
let group_member_names = group_members
.iter()
.map(|e| e.username.clone())
.collect::<Vec<_>>();
let group_member_ids = group_members.iter().map(|e| e.id).collect::<Vec<_>>();
let state = self.state.lock().await;
for staff in state.devops() {
if !group_member_names.contains(&staff.username)
&& self
.add_group_member(
action,
staff,
devops_group,
DEVOPS_INFRASTRUCTURE_ACCESS_LEVEL,
)
.await?
{
summary.add += 1;
if let Some(gitlab_id) = staff.gitlab_id {
if !group_member_ids.contains(&gitlab_id)
&& self
.add_group_member(
action,
staff,
devops_group,
DEVOPS_INFRASTRUCTURE_ACCESS_LEVEL,
)
.await?
{
summary.add += 1;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment