From ba5f2af68c6dd8639c6bd45d3e419741e1946134 Mon Sep 17 00:00:00 2001 From: dklawren Date: Thu, 26 Apr 2018 13:41:27 -0400 Subject: Bug 1454647 - Mirror all BMO groups as Phabricator projects and keep them in sync --- extensions/PhabBugz/lib/Config.pm | 5 ----- extensions/PhabBugz/lib/Feed.pm | 20 ++++++++------------ extensions/PhabBugz/lib/Policy.pm | 2 +- extensions/PhabBugz/lib/Util.pm | 7 +++---- extensions/PhabBugz/lib/WebService.pm | 1 - 5 files changed, 12 insertions(+), 23 deletions(-) (limited to 'extensions/PhabBugz/lib') diff --git a/extensions/PhabBugz/lib/Config.pm b/extensions/PhabBugz/lib/Config.pm index 85ba37e74..d4b71430b 100644 --- a/extensions/PhabBugz/lib/Config.pm +++ b/extensions/PhabBugz/lib/Config.pm @@ -30,11 +30,6 @@ sub get_param_list { default => '', checker => \&check_urlbase }, - { - name => 'phabricator_sync_groups', - type => 't', - default => '', - }, { name => 'phabricator_api_key', type => 't', diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index 4c7fe54a5..c35eeba4d 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -16,8 +16,9 @@ use List::MoreUtils qw(any); use Moo; use Try::Tiny; -use Bugzilla::Logging; use Bugzilla::Constants; +use Bugzilla::Field; +use Bugzilla::Logging; use Bugzilla::Search; use Bugzilla::Util qw(diff_arrays with_writable_database with_readonly_database); @@ -104,7 +105,7 @@ sub start { sub feed_query { my ($self) = @_; - Bugzilla::Logging->fields->{type} = 'FEED'; + local Bugzilla::Logging->fields->{type} = 'FEED'; # Ensure Phabricator syncing is enabled if (!Bugzilla->params->{phabricator_enabled}) { @@ -164,7 +165,7 @@ sub feed_query { sub user_query { my ( $self ) = @_; - Bugzilla::Logging->fields->{type} = 'USERS'; + local Bugzilla::Logging->fields->{type} = 'USERS'; # Ensure Phabricator syncing is enabled if (!Bugzilla->params->{phabricator_enabled}) { @@ -204,21 +205,17 @@ sub user_query { sub group_query { my ($self) = @_; + local Bugzilla::Logging->fields->{type} = 'GROUPS'; + # Ensure Phabricator syncing is enabled if ( !Bugzilla->params->{phabricator_enabled} ) { WARN("PHABRICATOR SYNC DISABLED"); return; } - my $phab_sync_groups = Bugzilla->params->{phabricator_sync_groups}; - if ( !$phab_sync_groups ) { - WARN('A comma delimited list of security groups was not provided.'); - return; - } - # PROCESS SECURITY GROUPS - INFO("GROUPS: Updating group memberships"); + INFO("Updating group memberships"); # Loop through each group and perform the following: # @@ -228,8 +225,7 @@ sub group_query { # 4. Set project members to exact list # 5. Profit - my $sync_groups = Bugzilla::Group->match( - { name => [ split( '[,\s]+', $phab_sync_groups ) ] } ); + my $sync_groups = Bugzilla::Group->match( { isactive => 1, isbuggroup => 1 } ); foreach my $group (@$sync_groups) { diff --git a/extensions/PhabBugz/lib/Policy.pm b/extensions/PhabBugz/lib/Policy.pm index 0beecc8e1..3ad6f284c 100644 --- a/extensions/PhabBugz/lib/Policy.pm +++ b/extensions/PhabBugz/lib/Policy.pm @@ -112,7 +112,7 @@ sub create { push @$project_phids, $project->phid if $project; } - ThrowUserError('invalid_phabricator_sync_groups') unless @$project_phids; + ThrowUserError('invalid_phabricator_projects') unless @$project_phids; push @{ $data->{policy} }, { action => 'allow', diff --git a/extensions/PhabBugz/lib/Util.pm b/extensions/PhabBugz/lib/Util.pm index 0f9351285..42da79c39 100644 --- a/extensions/PhabBugz/lib/Util.pm +++ b/extensions/PhabBugz/lib/Util.pm @@ -162,7 +162,7 @@ sub create_private_revision_policy { push(@$project_phids, $phid) if $phid; } - ThrowUserError('invalid_phabricator_sync_groups') unless @$project_phids; + ThrowUserError('invalid_phabricator_projects') unless @$project_phids; push(@{ $data->{policy} }, { @@ -512,9 +512,8 @@ sub request { sub get_security_sync_groups { my $bug = shift; - my $phab_sync_groups = Bugzilla->params->{phabricator_sync_groups} - || ThrowUserError('invalid_phabricator_sync_groups'); - my $sync_group_names = [ split('[,\s]+', $phab_sync_groups) ]; + my $sync_groups = Bugzilla::Group->match( { isactive => 1, isbuggroup => 1 } ); + my $sync_group_names = [ map { $_->name } @$sync_groups ]; my $bug_groups = $bug->groups_in; my $bug_group_names = [ map { $_->name } @$bug_groups ]; diff --git a/extensions/PhabBugz/lib/WebService.pm b/extensions/PhabBugz/lib/WebService.pm index adf127a1f..32cea1b51 100644 --- a/extensions/PhabBugz/lib/WebService.pm +++ b/extensions/PhabBugz/lib/WebService.pm @@ -35,7 +35,6 @@ use Bugzilla::Extension::PhabBugz::Util qw( get_project_phid get_revisions_by_ids get_security_sync_groups - intersect is_attachment_phab_revision make_revision_public request -- cgit v1.2.3-24-g4f1b