Class: Danger::MilestoneChecker
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::MilestoneChecker
- Defined in:
- lib/dangermattic/plugins/milestone_checker.rb
Overview
This plugin checks whether a pull request is assigned to a milestone and whether the milestone's due date is approaching.
Instance Method Summary collapse
-
#check_milestone_due_date(days_before_due:, report_type: :warning, report_type_if_no_milestone: :warning) ⇒ void
Checks if the pull request's milestone is due to finish within a certain number of days.
-
#check_milestone_set(report_type: :warning) ⇒ void
Checks if the pull request is assigned to a milestone.
Instance Method Details
#check_milestone_due_date(days_before_due:, report_type: :warning, report_type_if_no_milestone: :warning) ⇒ void
This method returns an undefined value.
Checks if the pull request's milestone is due to finish within a certain number of days.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dangermattic/plugins/milestone_checker.rb', line 50 def check_milestone_due_date(days_before_due:, report_type: :warning, report_type_if_no_milestone: :warning) if milestone.nil? check_milestone_set(report_type: report_type_if_no_milestone) return end return unless pr_state != 'closed' && milestone_due_date today = DateTime.now seconds_threshold = days_before_due * 24 * 60 * 60 time_before_due_date = milestone_due_date.to_time.to_i - today.to_time.to_i return unless time_before_due_date <= seconds_threshold = "This PR is assigned to the milestone [#{milestone_title}](#{milestone_url}). " += if time_before_due_date.positive? "This milestone is due in less than #{days_before_due} days.\n" \ 'Please make sure to get it merged by then or assign it to a milestone with a later deadline.' else "The due date for this milestone has already passed.\n" \ 'Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.' end reporter.report(message: , type: report_type) end |
#check_milestone_set(report_type: :warning) ⇒ void
This method returns an undefined value.
Checks if the pull request is assigned to a milestone.
36 37 38 39 40 41 |
# File 'lib/dangermattic/plugins/milestone_checker.rb', line 36 def check_milestone_set(report_type: :warning) return unless milestone.nil? = 'PR is not assigned to a milestone.' reporter.report(message: , type: report_type) end |