From 1103945ed4f3e430b8029b4a7893e214dfe289fb Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 14 Dec 2022 03:07:29 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- tooling/danger/user_types.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tooling/danger/user_types.rb (limited to 'tooling') diff --git a/tooling/danger/user_types.rb b/tooling/danger/user_types.rb new file mode 100644 index 00000000000..8320c43ae93 --- /dev/null +++ b/tooling/danger/user_types.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Tooling + module Danger + module UserTypes + FILE_PATH = "app/models/concerns/has_user_type.rb" + BOT_USER_TYPES_CHANGE_INDICATOR_REGEX = %r{BOT_USER_TYPES}.freeze + BOT_USER_TYPES_CHANGED_WARNING = <<~MSG + You are changing BOT_USER_TYPES in `app/models/concerns/has_user_type.rb`. + If you are adding or removing new bots, remember to update the `active_billable_users` index with the new value. + If the bot is not billable, remember to make sure that it's not counted as a billable user. + MSG + + def bot_user_types_change_warning + return unless impacted? + + warn BOT_USER_TYPES_CHANGED_WARNING if bot_user_types_impacted? + end + + private + + def impacted? + helper.modified_files.include?(FILE_PATH) + end + + def bot_user_types_impacted? + helper.changed_lines(FILE_PATH).any? { |change| change =~ BOT_USER_TYPES_CHANGE_INDICATOR_REGEX } + end + end + end +end -- cgit v1.2.1