Francois Gouget : testbot: Add User::AddRole().
Alexandre Julliard
julliard at winehq.org
Mon Apr 18 15:53:31 CDT 2022
Module: tools
Branch: master
Commit: eb3a8541027bbec95f2e1dd3b86616fcb9c3e021
URL: https://source.winehq.org/git/tools.git/?a=commit;h=eb3a8541027bbec95f2e1dd3b86616fcb9c3e021
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Mon Apr 18 10:32:52 2022 +0200
testbot: Add User::AddRole().
This simplifies adding a role to a user, particularly with regards to
making sure the user's Roles collection is up to date.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/lib/WineTestBot/Users.pm | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/testbot/lib/WineTestBot/Users.pm b/testbot/lib/WineTestBot/Users.pm
index bd9cf35..f2f2a19 100644
--- a/testbot/lib/WineTestBot/Users.pm
+++ b/testbot/lib/WineTestBot/Users.pm
@@ -106,22 +106,25 @@ sub GenerateResetCode($)
}
}
+sub AddRole($$)
+{
+ my ($self, $Role) = @_;
+
+ my $UserRole = $self->Roles->Add();
+ my $OldKey = $UserRole->GetKey();
+ $UserRole->Role($Role);
+ $self->Roles->KeyChanged($OldKey, $Role->GetKey());
+}
+
sub AddDefaultRoles($)
{
my ($self) = @_;
- my $UserRoles = $self->Roles;
my $DefaultRoles = CreateRoles();
$DefaultRoles->AddFilter("IsDefaultRole", [1]);
- foreach my $RoleKey (@{$DefaultRoles->GetKeys()})
+ foreach my $Role (@{$DefaultRoles->GetItems()})
{
- if (! defined($UserRoles->GetItem($RoleKey)))
- {
- my $NewRole = $UserRoles->Add();
- my $OldKey = $NewRole->GetKey();
- $NewRole->Role($DefaultRoles->GetItem($RoleKey));
- $UserRoles->KeyChanged($OldKey, $RoleKey);
- }
+ $self->AddRole($Role) if (!$self->Roles->GetItem($Role->Name));
}
}
More information about the wine-cvs
mailing list