-
Notifications
You must be signed in to change notification settings - Fork 204
Bug 2066252 - Prevent save if keyword checkin-needed-tb exists without target milestone #2734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+62
−0
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
extensions/MozChangeField/lib/Post/CheckinNeededTbMilestone.pm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # 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; | ||
|
|
||
| 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 the two fields, so bugs | ||
| # already in this state don't block unrelated edits. | ||
|
dklawren marked this conversation as resolved.
Outdated
|
||
| return if !exists $changes->{keywords} && !exists $changes->{target_milestone}; | ||
|
dklawren marked this conversation as resolved.
Outdated
|
||
|
|
||
| _check_milestone($args->{bug}); | ||
| } | ||
|
|
||
| 1; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.