From 6e06bb255acdf53d2bbed3911378bd6859a0e3f0 Mon Sep 17 00:00:00 2001 From: dklawren Date: Wed, 30 Aug 2017 11:15:14 -0400 Subject: Bug 1393023: Approving a revision creates an r+ flag on the revision attachment in the associated bug (#219) Approving a revision creates an r+ flag on the revision attachment in the associated bug * - Working version - Splits accepted_users on ':' instead of accepting a list (phab issue) --- extensions/PhabBugz/lib/Util.pm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'extensions/PhabBugz/lib/Util.pm') diff --git a/extensions/PhabBugz/lib/Util.pm b/extensions/PhabBugz/lib/Util.pm index 57dc1d7d0..5a8385d0c 100644 --- a/extensions/PhabBugz/lib/Util.pm +++ b/extensions/PhabBugz/lib/Util.pm @@ -27,6 +27,7 @@ our @EXPORT = qw( create_private_revision_policy create_project edit_revision_policy + get_attachment_revisions get_bug_role_phids get_members_by_bmo_id get_project_phid @@ -297,7 +298,32 @@ sub is_attachment_phab_revision { my ($attachment, $include_obsolete) = @_; return ($attachment->contenttype eq PHAB_CONTENT_TYPE && ($include_obsolete || !$attachment->isobsolete) - && $attachment->attacher->login eq 'phab-bot@bmo.tld') ? 1 : 0; + && $attachment->attacher->login eq PHAB_AUTOMATION_USER) ? 1 : 0; +} + +sub get_attachment_revisions { + my ($self, $bug) = @_; + + my @revisions; + + my @attachments = + grep { is_attachment_phab_revision($_) } @{ $bug->attachments() }; + + if (@attachments) { + my @revision_ids; + foreach my $attachment (@attachments) { + my ($revision_id) = + ( $attachment->filename =~ PHAB_ATTACHMENT_PATTERN ); + next if !$revision_id; + push( @revision_ids, int($revision_id) ); + } + + if (@revision_ids) { + @revisions = get_revisions_by_ids( \@revision_ids ); + } + } + + return @revisions; } sub request { -- cgit v1.2.3-24-g4f1b