]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1454647 - Mirror all BMO groups as Phabricator projects and keep them in sync
authordklawren <dklawren@users.noreply.github.com>
Thu, 26 Apr 2018 17:41:27 +0000 (13:41 -0400)
committerGitHub <noreply@github.com>
Thu, 26 Apr 2018 17:41:27 +0000 (13:41 -0400)
extensions/PhabBugz/lib/Config.pm
extensions/PhabBugz/lib/Feed.pm
extensions/PhabBugz/lib/Policy.pm
extensions/PhabBugz/lib/Util.pm
extensions/PhabBugz/lib/WebService.pm
extensions/PhabBugz/template/en/default/admin/params/phabbugz.html.tmpl
extensions/PhabBugz/template/en/default/hook/global/user-error-errors.html.tmpl
extensions/Push/lib/Connector/Phabricator.pm
scripts/generate_conduit_data.pl

index 85ba37e74ba5a0d4a12b748d9c33b7e2d49ea806..d4b71430b2c75eb825cd75d4d5b731aeb872fd40 100644 (file)
@@ -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',
index 4c7fe54a5a0112f515a67eb51751d637dbd75dd9..c35eeba4d5ca5667ddfbc9a779986becf492d403 100644 (file)
@@ -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) {
 
index 0beecc8e1347f720cd13ee651fa759a2fd97d5c1..3ad6f284c33ad609cb658fefc8881e4352d9aa77 100644 (file)
@@ -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',
index 0f9351285164fafc224564ea2e6b3bc45c9bbaea..42da79c39de510f91f165bd24feca4e974ac76a6 100644 (file)
@@ -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 ];
index adf127a1f17b65c5351c27e3e819a59024864bbb..32cea1b510ceaa4d37ceef79b410cd236986b482 100644 (file)
@@ -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
index d67839cc8d5ce992ae1078541e821dc3529a20cd..1b5bdda4bfaad35a351a7c2b5b11a782c81cf68e 100644 (file)
@@ -16,7 +16,6 @@
      phabricator_enabled     => 'Enable Phabricator Integration',
      phabricator_base_uri    => 'Phabricator Base URI',
      phabricator_api_key     => 'Phabricator User API Key',
-     phabricator_sync_groups => 'Comma delimited list of Bugzilla groups to sync to Phabricator projects',
      phabricator_auth_callback_url => 'Phabricator Auth Delegation URL',
      phabricator_app_id      => 'app_id for API Keys delegated to Phabricator',
    }
index 1457e352553224544a5c859c22d54fd6dbd6012e..f1366e7b6e7d5493ecf268a46952420aa6140fbd 100644 (file)
   [% title = "Invalid Phabricator API Key" %]
   You must provide a valid Phabricator API Key.
 
-[% ELSIF error == "invalid_phabricator_sync_groups" %]
-  [% title = "Invalid Phabricator Sync Groups" %]
-  You must provide a comma delimited list of security groups
-  to sync with Phabricator.
+[% ELSIF error == "invalid_phabricator_projects" %]
+  [% title = "Invalid Phabricator Projects" %]
+  One or more Phabricator projects selected are invalid.
 
 [% ELSIF error == "invalid_phabricator_revision_id" %]
   [% title = "Invalid Phabricator Revision ID" %]
index 1878834a921e183ba485e92fdd8f0fced4adf09b..cea73f4104591878b17ebd006ecf5ab742656ba0 100644 (file)
@@ -28,7 +28,6 @@ use Bugzilla::Extension::PhabBugz::Util qw(
   get_bug_role_phids
   get_project_phid
   get_security_sync_groups
-  intersect
   make_revision_public
   make_revision_private
   set_revision_subscribers
index 50a7379f45dd6c129042fa80d0abc87b77419f2a..541afb52a81501d85db427c66409635879c3d66d 100755 (executable)
@@ -133,7 +133,6 @@ set_params(
     password_check_on_login => 0,
     phabricator_base_uri    => 'http://phabricator.test/',
     phabricator_enabled     => 1,
-    phabricator_sync_groups => 'core-security',
 );
 set_push_connector_options();