debian-mirror-gitlab/lib/gitlab/danger/changelog.rb

43 lines
954 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
module Gitlab
module Danger
module Changelog
2020-07-28 23:09:34 +05:30
NO_CHANGELOG_LABELS = [
'tooling',
'tooling::pipelines',
'tooling::workflow',
'ci-build',
'meta'
].freeze
2020-01-01 13:55:28 +05:30
NO_CHANGELOG_CATEGORIES = %i[docs none].freeze
def needed?
2020-07-28 23:09:34 +05:30
categories_need_changelog? && without_no_changelog_label?
2020-01-01 13:55:28 +05:30
end
def found
2020-04-22 19:07:51 +05:30
@found ||= git.added_files.find { |path| path =~ %r{\A(ee/)?(changelogs/unreleased)(-ee)?/} }
2020-01-01 13:55:28 +05:30
end
def sanitized_mr_title
gitlab.mr_json["title"].gsub(/^WIP: */, '').gsub(/`/, '\\\`')
end
2020-04-22 19:07:51 +05:30
def ee_changelog?
found.start_with?('ee/')
2020-01-01 13:55:28 +05:30
end
private
def categories_need_changelog?
(helper.changes_by_category.keys - NO_CHANGELOG_CATEGORIES).any?
end
2020-07-28 23:09:34 +05:30
def without_no_changelog_label?
(gitlab.mr_labels & NO_CHANGELOG_LABELS).empty?
end
2020-01-01 13:55:28 +05:30
end
end
end