From e5ee36ba43a80554aceb04d6b6c4504c6d21e3fb Mon Sep 17 00:00:00 2001 From: dklawren Date: Fri, 11 Aug 2017 16:02:16 -0400 Subject: Bug 1382225 - Missing code from PhabBugz extension such as http basic auth support and other minor improvements --- extensions/Push/lib/Connector/Phabricator.pm | 26 +++++++++++--------------- 1 file changed, 11 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 d72009708..2571c6d37 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -16,17 +16,16 @@ use base 'Bugzilla::Extension::Push::Connector::Base'; use Bugzilla::Bug; use Bugzilla::Constants; use Bugzilla::Error; -use Bugzilla::Extension::PhabBugz::Util qw(add_comment_to_revision - create_private_revision_policy edit_revision_policy get_bug_role_phids - get_revisions_by_ids intersect make_revision_public make_revision_private); -use Bugzilla::Extension::Push::Constants; -use Bugzilla::Extension::Push::Util qw(is_public); use Bugzilla::User; -use List::Util qw(any); -use constant PHAB_CONTENT_TYPE => 'text/x-phabricator-request'; -use constant PHAB_ATTACHMENT_PATTERN => qr/^phabricator-D(\d+)/; -use constant PHAB_BMO_USER_EMAIL => 'phab-bot@bmo.tld'; +use Bugzilla::Extension::PhabBugz::Constants; +use Bugzilla::Extension::PhabBugz::Util qw( + add_comment_to_revision create_private_revision_policy + edit_revision_policy get_bug_role_phids get_revisions_by_ids + intersect is_attachment_phab_revision make_revision_public + make_revision_private); +use Bugzilla::Extension::Push::Constants; +use Bugzilla::Extension::Push::Util qw(is_public); sub options { return ( @@ -91,7 +90,7 @@ sub send { : 'One revision was' ) . ' made private due to unknown Bugzilla groups.'; - my $user = Bugzilla::User->new( { name => PHAB_BMO_USER_EMAIL } ); + my $user = Bugzilla::User->new( { name => PHAB_AUTOMATION_USER } ); $user->{groups} = [ Bugzilla::Group->get_all ]; $user->{bless_groups} = [ Bugzilla::Group->get_all ]; Bugzilla->set_user($user); @@ -131,11 +130,8 @@ sub _get_attachment_revisions() { my @revisions; - my @attachments = grep { - $_->isobsolete == 0 - && $_->contenttype eq PHAB_CONTENT_TYPE - && $_->attacher->login eq PHAB_BMO_USER_EMAIL - } @{ $bug->attachments() }; + my @attachments = + grep { is_attachment_phab_revision($_) } @{ $bug->attachments() }; if (@attachments) { my @revision_ids; -- cgit v1.2.3-24-g4f1b