Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extensions/MozChangeField/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@ my @pre_instances = (

use Bugzilla::Extension::MozChangeField::Post::SeverityS1PriorityP1;
use Bugzilla::Extension::MozChangeField::Post::ClearTrackingPriorityS1;

#use Bugzilla::Extension::MozChangeField::Post::CommentOnSeverity;
use Bugzilla::Extension::MozChangeField::Post::SetTrackingSeverityS1;
use Bugzilla::Extension::MozChangeField::Post::TypePriSevEditbugs;
use Bugzilla::Extension::MozChangeField::Post::RegressedByTypeKeyword;
use Bugzilla::Extension::MozChangeField::Post::CheckinNeededTbMilestone;

my @post_instances = (
Bugzilla::Extension::MozChangeField::Post::SeverityS1PriorityP1->new,
Bugzilla::Extension::MozChangeField::Post::ClearTrackingPriorityS1->new,

#Bugzilla::Extension::MozChangeField::Post::CommentOnSeverity->new,
Bugzilla::Extension::MozChangeField::Post::SetTrackingSeverityS1->new,
Bugzilla::Extension::MozChangeField::Post::TypePriSevEditbugs->new,
Bugzilla::Extension::MozChangeField::Post::RegressedByTypeKeyword->new,
Bugzilla::Extension::MozChangeField::Post::CheckinNeededTbMilestone->new,
);

our $VERSION = '0.1';
Expand Down
53 changes: 53 additions & 0 deletions extensions/MozChangeField/lib/Post/CheckinNeededTbMilestone.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

package Bugzilla::Extension::MozChangeField::Post::CheckinNeededTbMilestone;

use 5.10.1;
use Moo;

use Bugzilla::Error;

use constant PRODUCTS =>
{map { $_ => 1 } ('Thunderbird', 'MailNews Core', 'Calendar')};

use constant KEYWORD => 'checkin-needed-tb';

sub _check_milestone {
my ($bug) = @_;
my $product = $bug->product_obj;

return if !PRODUCTS->{$product->name};
return if !$bug->has_keyword(KEYWORD);

# The product's default milestone (normally '---') means 'not set'.
return if $bug->target_milestone ne $product->default_milestone;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we compare with --- directly? Is there any risk in a silent pass if a product gets a real default milestone?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what silent pass means if it gets a real milestone. The products default milestone can be set to any valid milestone value and is what gets set if a user doesn't set anything for milestone.


ThrowUserError('mozchangefield_checkin_needed_tb_milestone',
{keyword => KEYWORD});
}

sub evaluate_create {
my ($self, $args) = @_;
_check_milestone($args->{bug});
}

sub evaluate_change {
my ($self, $args) = @_;
my $changes = $args->{changes};

# Only enforce on a save that touches one of three fields, so bugs
# already in this state don't block unrelated edits.
return
if !exists $changes->{keywords}
&& !exists $changes->{target_milestone}
&& !exists $changes->{product};

_check_milestone($args->{bug});
}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
[% title = "Invalid Change" %]
You need "editbugs" permissions to alter the '[% field FILTER html %]' field.

[% ELSIF error == "mozchangefield_checkin_needed_tb_milestone" %]
[% title = "Target Milestone Required" %]
The <b>[% keyword FILTER html %]</b> keyword requires a
<b>Target Milestone</b> to be set.

[% END %]