From 5b0812a368b9e646f393ccbf62186ed1b2b535d2 Mon Sep 17 00:00:00 2001 From: dklawren Date: Fri, 20 Apr 2018 12:57:40 -0400 Subject: Code Pull requests 33 Insights Settings Bug 1452531 - PhabBugz code should add allow visibility to reviewers when creating custom policies --- extensions/Push/lib/Connector/Phabricator.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extensions/Push/lib/Connector') diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm index 5da64901a..1878834a9 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -128,7 +128,7 @@ sub send { $revision->{id}, $bug->id )); - my $policy_phid = create_private_revision_policy( $bug, \@set_groups ); + my $policy_phid = create_private_revision_policy( \@set_groups ); edit_revision_policy( $revision_phid, $policy_phid, $subscribers ); $rev_obj->add_project($secure_project_phid); $revision_updated = 1; -- cgit v1.2.3-24-g4f1b 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/Push/lib/Connector/Phabricator.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'extensions/Push/lib/Connector') diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm index 1878834a9..cea73f410 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -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 -- cgit v1.2.3-24-g4f1b From 5460e9be3a80d353f7c49ca94833c08455440ce8 Mon Sep 17 00:00:00 2001 From: dklawren Date: Wed, 30 May 2018 22:12:59 -0400 Subject: Bug 1430905 - Remove legacy phabbugz code that is no longer needed --- extensions/Push/lib/Connector/Phabricator.pm | 97 ++++++++++++---------------- 1 file changed, 42 insertions(+), 55 deletions(-) (limited to 'extensions/Push/lib/Connector') diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm index cea73f410..aeef32ab4 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -15,23 +15,18 @@ use base 'Bugzilla::Extension::Push::Connector::Base'; use Bugzilla::Bug; use Bugzilla::Constants; -use Bugzilla::Error; -use Bugzilla::User; use Bugzilla::Extension::PhabBugz::Constants; +use Bugzilla::Extension::PhabBugz::Policy; +use Bugzilla::Extension::PhabBugz::Project; +use Bugzilla::Extension::PhabBugz::Revision; use Bugzilla::Extension::PhabBugz::Util qw( - add_comment_to_revision add_security_sync_comments - create_private_revision_policy - edit_revision_policy get_attachment_revisions get_bug_role_phids - get_project_phid get_security_sync_groups - make_revision_public - make_revision_private - set_revision_subscribers ); + use Bugzilla::Extension::Push::Constants; use Bugzilla::Extension::Push::Util qw(is_public); @@ -75,72 +70,64 @@ sub send { my @set_groups = get_security_sync_groups($bug); - my @revisions = get_attachment_revisions($bug); - - if (!$is_public && !@set_groups) { - foreach my $revision (@revisions) { - Bugzilla->audit(sprintf( - 'Making revision %s for bug %s private due to unkown Bugzilla groups: %s', - $revision->{id}, - $bug->id, - join(', ', @set_groups) - )); - make_revision_private( $revision->{phid} ); - } - - add_security_sync_comments(\@revisions, $bug); - - return PUSH_RESULT_OK; - } + my $revisions = get_attachment_revisions($bug); my $group_change = ($message->routing_key =~ /^(?:attachment|bug)\.modify:.*\bbug_group\b/) ? 1 : 0; - my $subscribers; - if ( !$is_public ) { - $subscribers = get_bug_role_phids($bug); - } - - my $secure_project_phid = get_project_phid('secure-revision'); - - foreach my $revision (@revisions) { - my $revision_phid = $revision->{phid}; - - my $rev_obj = Bugzilla::Extension::PhabBugz::Revision->new_from_query({ phids => [ $revision_phid ] }); - my $revision_updated; + foreach my $revision (@$revisions) { + my $secure_revision = Bugzilla::Extension::PhabBugz::Project->new_from_query({ + name => 'secure-revision' + }); if ( $is_public && $group_change ) { Bugzilla->audit(sprintf( 'Making revision %s public for bug %s', - $revision->{id}, + $revision->id, $bug->id )); - make_revision_public($revision_phid); - $rev_obj->remove_project($secure_project_phid); - $revision_updated = 1; + $revision->set_policy('view', 'public'); + $revision->set_policy('edit', 'users'); + $revision->remove_project($secure_revision->phid); } - elsif ( !$is_public && $group_change ) { + elsif ( !$is_public && !@set_groups ) { Bugzilla->audit(sprintf( - 'Giving revision %s a custom policy for bug %s', - $revision->{id}, - $bug->id + 'Making revision %s for bug %s private due to unkown Bugzilla groups: %s', + $revision->id, + $bug->id, + join(', ', @set_groups) )); - my $policy_phid = create_private_revision_policy( \@set_groups ); - edit_revision_policy( $revision_phid, $policy_phid, $subscribers ); - $rev_obj->add_project($secure_project_phid); - $revision_updated = 1; + $revision->set_policy('view', $secure_revision->phid); + $revision->set_policy('edit', $secure_revision->phid); + $revision->add_project($secure_revision->phid); + add_security_sync_comments([$revision], $bug); } - elsif ( !$is_public && !$group_change ) { + elsif ( !$is_public && $group_change ) { Bugzilla->audit(sprintf( - 'Updating subscribers for %s for bug %s', - $revision->{id}, + 'Giving revision %s a custom policy for bug %s', + $revision->id, $bug->id )); - set_revision_subscribers( $revision_phid, $subscribers ); + my @set_projects = map { "bmo-" . $_ } @set_groups; + my $new_policy = Bugzilla::Extension::PhabBugz::Policy->create(\@set_projects); + $revision->set_policy('view', $new_policy->phid); + $revision->set_policy('edit', $new_policy->phid); + $revision->add_project($secure_revision->phid); } - $rev_obj->update() if $revision_updated; + + # Subscriber list of the private revision should always match + # the bug roles such as assignee, qa contact, and cc members. + Bugzilla->audit(sprintf( + 'Updating subscribers for %s for bug %s', + $revision->id, + $bug->id + )); + my $subscribers = get_bug_role_phids($bug); + $revision->set_subscribers($subscribers) if $subscribers; + + $revision->update(); } return PUSH_RESULT_OK; -- cgit v1.2.3-24-g4f1b From e83b95790d29393e9711aedeccfd63353bbc3cde Mon Sep 17 00:00:00 2001 From: dklawren Date: Mon, 25 Jun 2018 17:26:53 -0400 Subject: Bug 1457900 - When restricting a revision to a bugzilla group we should tag the revision with the project --- extensions/Push/lib/Connector/Phabricator.pm | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'extensions/Push/lib/Connector') diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm index aeef32ab4..5d5e4e639 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -78,19 +78,13 @@ sub send { : 0; foreach my $revision (@$revisions) { - my $secure_revision = Bugzilla::Extension::PhabBugz::Project->new_from_query({ - name => 'secure-revision' - }); - if ( $is_public && $group_change ) { Bugzilla->audit(sprintf( 'Making revision %s public for bug %s', $revision->id, $bug->id )); - $revision->set_policy('view', 'public'); - $revision->set_policy('edit', 'users'); - $revision->remove_project($secure_revision->phid); + $revision->make_public(); } elsif ( !$is_public && !@set_groups ) { Bugzilla->audit(sprintf( @@ -99,9 +93,7 @@ sub send { $bug->id, join(', ', @set_groups) )); - $revision->set_policy('view', $secure_revision->phid); - $revision->set_policy('edit', $secure_revision->phid); - $revision->add_project($secure_revision->phid); + $revision->make_private(['secure-revision']); add_security_sync_comments([$revision], $bug); } elsif ( !$is_public && $group_change ) { @@ -110,11 +102,8 @@ sub send { $revision->id, $bug->id )); - my @set_projects = map { "bmo-" . $_ } @set_groups; - my $new_policy = Bugzilla::Extension::PhabBugz::Policy->create(\@set_projects); - $revision->set_policy('view', $new_policy->phid); - $revision->set_policy('edit', $new_policy->phid); - $revision->add_project($secure_revision->phid); + my @set_project_names = map { "bmo-" . $_ } @set_groups; + $revision->make_private(\@set_project_names); } # Subscriber list of the private revision should always match -- cgit v1.2.3-24-g4f1b From f63319ac7da3fc3f9107c21ad715b8af9566fde4 Mon Sep 17 00:00:00 2001 From: dklawren Date: Thu, 28 Jun 2018 13:30:34 -0400 Subject: Bug 1469378 - Update feed daemon to only manage subscribers on a revision if the bug is private, otherwise leave it alone --- extensions/Push/lib/Connector/Phabricator.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'extensions/Push/lib/Connector') diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm index 5d5e4e639..e59ba6c0d 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -108,13 +108,15 @@ sub send { # Subscriber list of the private revision should always match # the bug roles such as assignee, qa contact, and cc members. - Bugzilla->audit(sprintf( - 'Updating subscribers for %s for bug %s', - $revision->id, - $bug->id - )); - my $subscribers = get_bug_role_phids($bug); - $revision->set_subscribers($subscribers) if $subscribers; + if (!$is_public) { + Bugzilla->audit(sprintf( + 'Updating subscribers for %s for bug %s', + $revision->id, + $bug->id + )); + my $subscribers = get_bug_role_phids($bug); + $revision->set_subscribers($subscribers) if $subscribers; + } $revision->update(); } -- cgit v1.2.3-24-g4f1b