diff options
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/PhabBugz/lib/Feed.pm | 19 | ||||
-rw-r--r-- | extensions/PhabBugz/lib/Project.pm | 6 |
2 files changed, 16 insertions, 9 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index c46d36c13..1f9824ed9 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -12,7 +12,7 @@ use 5.10.1; use IO::Async::Timer::Periodic; use IO::Async::Loop; use List::Util qw(first); -use List::MoreUtils qw(any); +use List::MoreUtils qw(any uniq); use Moo; use Scalar::Util qw(blessed); use Try::Tiny; @@ -323,10 +323,19 @@ sub group_query { # Make sure phab-bot also a member of the new project group so that it can # make policy changes to the private revisions INFO("Setting project members for " . $project->name); - my $set_members = $self->get_group_members( $group ); - push @$set_members, $phab_user unless grep $_->phid eq $phab_user->phid, @$set_members; - $project->set_members( $set_members ); - $project->update(); + my $set_members = $self->get_group_members( $group ); + my @set_member_phids = uniq map { $_->phid } (@$set_members, $phab_user); + my @current_member_phids = uniq map { $_->phid } @{ $project->members }; + my ($added, $removed) = diff_arrays(\@set_member_phids, \@current_member_phids); + + INFO('Adding members: ' . join( ',', @$added )); + $project->add_member( $_ ) foreach @$added; + INFO('Removing members: ' . join( ',', @$removed )); + $project->remove_member( $_ ) foreach @$removed; + + my $result = $project->update(); + local Bugzilla::Logging->fields->{api_result} = $result; + INFO("Project " . $project->name . " updated"); } } diff --git a/extensions/PhabBugz/lib/Project.pm b/extensions/PhabBugz/lib/Project.pm index c52e1a661..3d93e2f04 100644 --- a/extensions/PhabBugz/lib/Project.pm +++ b/extensions/PhabBugz/lib/Project.pm @@ -307,7 +307,7 @@ sub set_policy { ############ sub _build_members { - my ($self) = @_; + my ( $self ) = @_; return [] unless $self->members_raw; my @phids; @@ -317,13 +317,11 @@ sub _build_members { return [] if !@phids; - my $users = Bugzilla::Extension::PhabBugz::User->match( + return Bugzilla::Extension::PhabBugz::User->match( { phids => \@phids } ); - - return [ map { $_->bugzilla_user } @$users ]; } 1; |