Class: Danger::CommonReleaseChecker
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::CommonReleaseChecker
- Defined in:
- lib/dangermattic/plugins/common/common_release_checker.rb
Overview
Plugin to perform generic checks related to releases.
It can be used directly or via the specialised plugins AndroidReleaseChecker and IosReleaseChecker.
Constant Summary collapse
- DEFAULT_INTERNAL_RELEASE_NOTES =
'RELEASE-NOTES.txt'- MESSAGE_STORE_FILE_NOT_CHANGED =
'The `%s` file should be updated if the editorialized release notes file `%s` is being changed.'- MESSAGE_INTERNAL_RELEASE_NOTES_CHANGED =
<<~WARNING This PR contains changes to `%s`. Note that these changes won't affect the final version of the release notes as this version is in code freeze. Please, get in touch with a release manager if you want to update the final release notes. WARNING
Instance Method Summary collapse
-
#check_file_changed(file_comparison:, message:, on_release_branch:, report_type: :warning) ⇒ void
Check if certain files have been modified, returning a warning or failure message based on the branch type.
-
#check_internal_release_notes_changed(release_notes_file: DEFAULT_INTERNAL_RELEASE_NOTES, report_type: :warning) ⇒ void
Check if there are changes to the internal release notes file in the release branch and emit a warning if that's the case.
-
#check_release_notes_and_store_strings(release_notes_file:, po_file:) ⇒ void
Check if the release notes and store strings files are correctly updated after a modification to the release notes.
Instance Method Details
#check_file_changed(file_comparison:, message:, on_release_branch:, report_type: :warning) ⇒ void
This method returns an undefined value.
Check if certain files have been modified, returning a warning or failure message based on the branch type.
61 62 63 64 65 66 67 68 |
# File 'lib/dangermattic/plugins/common/common_release_checker.rb', line 61 def check_file_changed(file_comparison:, message:, on_release_branch:, report_type: :warning) has_modified_file = git_utils.all_changed_files.any?(&file_comparison) should_be_changed = (on_release_branch == github_utils.release_branch?) return unless should_be_changed && has_modified_file reporter.report(message: , type: report_type) end |
#check_internal_release_notes_changed(release_notes_file: DEFAULT_INTERNAL_RELEASE_NOTES, report_type: :warning) ⇒ void
This method returns an undefined value.
Check if there are changes to the internal release notes file in the release branch and emit a warning if that's the case.
104 105 106 107 108 109 110 111 |
# File 'lib/dangermattic/plugins/common/common_release_checker.rb', line 104 def check_internal_release_notes_changed(release_notes_file: DEFAULT_INTERNAL_RELEASE_NOTES, report_type: :warning) check_file_changed( file_comparison: ->(path) { path == release_notes_file }, message: format(MESSAGE_INTERNAL_RELEASE_NOTES_CHANGED, release_notes_file), on_release_branch: true, report_type: report_type ) end |
#check_release_notes_and_store_strings(release_notes_file:, po_file:) ⇒ void
This method returns an undefined value.
Check if the release notes and store strings files are correctly updated after a modification to the release notes.
82 83 84 85 86 87 88 89 |
# File 'lib/dangermattic/plugins/common/common_release_checker.rb', line 82 def check_release_notes_and_store_strings(release_notes_file:, po_file:) has_modified_release_notes = danger.git.modified_files.any? { |f| f == release_notes_file } has_modified_app_store_strings = danger.git.modified_files.any? { |f| f == po_file } return unless has_modified_release_notes && !has_modified_app_store_strings (format(MESSAGE_STORE_FILE_NOT_CHANGED, po_file, release_notes_file)) end |