summaryrefslogtreecommitdiffstats
path: root/extensions/Push/lib/Connector/Phabricator.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-08 06:59:55 +0200
committerDylan William Hardison <dylan@hardison.net>2018-07-08 06:59:55 +0200
commitbe1f92450788dc89280c9e04a4bf983b5d7fac54 (patch)
treeb5513fd846597fe5f152177dbbda88dca08fdf5f /extensions/Push/lib/Connector/Phabricator.pm
parent9bbd8d368598046c47964ee043620621b6c3634b (diff)
parent446a08b30b0dbaac9f2b88e0a5cad410f0446140 (diff)
downloadbugzilla-be1f92450788dc89280c9e04a4bf983b5d7fac54.tar.gz
bugzilla-be1f92450788dc89280c9e04a4bf983b5d7fac54.tar.xz
Merge remote-tracking branch 'bmo/master'
Diffstat (limited to 'extensions/Push/lib/Connector/Phabricator.pm')
-rw-r--r--extensions/Push/lib/Connector/Phabricator.pm83
1 files changed, 30 insertions, 53 deletions
diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm
index 5da64901a..e59ba6c0d 100644
--- a/extensions/Push/lib/Connector/Phabricator.pm
+++ b/extensions/Push/lib/Connector/Phabricator.pm
@@ -15,24 +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
- intersect
- make_revision_public
- make_revision_private
- set_revision_subscribers
);
+
use Bugzilla::Extension::Push::Constants;
use Bugzilla::Extension::Push::Util qw(is_public);
@@ -76,72 +70,55 @@ 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) {
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->make_public();
+ }
+ elsif ( !$is_public && !@set_groups ) {
+ Bugzilla->audit(sprintf(
+ 'Making revision %s for bug %s private due to unkown Bugzilla groups: %s',
+ $revision->id,
+ $bug->id,
+ join(', ', @set_groups)
+ ));
+ $revision->make_private(['secure-revision']);
+ add_security_sync_comments([$revision], $bug);
}
elsif ( !$is_public && $group_change ) {
Bugzilla->audit(sprintf(
'Giving revision %s a custom policy for bug %s',
- $revision->{id},
+ $revision->id,
$bug->id
));
- my $policy_phid = create_private_revision_policy( $bug, \@set_groups );
- edit_revision_policy( $revision_phid, $policy_phid, $subscribers );
- $rev_obj->add_project($secure_project_phid);
- $revision_updated = 1;
+ my @set_project_names = map { "bmo-" . $_ } @set_groups;
+ $revision->make_private(\@set_project_names);
}
- elsif ( !$is_public && !$group_change ) {
+
+ # Subscriber list of the private revision should always match
+ # the bug roles such as assignee, qa contact, and cc members.
+ if (!$is_public) {
Bugzilla->audit(sprintf(
'Updating subscribers for %s for bug %s',
- $revision->{id},
+ $revision->id,
$bug->id
));
- set_revision_subscribers( $revision_phid, $subscribers );
+ my $subscribers = get_bug_role_phids($bug);
+ $revision->set_subscribers($subscribers) if $subscribers;
}
- $rev_obj->update() if $revision_updated;
+
+ $revision->update();
}
return PUSH_RESULT_OK;