替换thank_contribution.rb
frozen_string_literal: true
require_relative 'community_processor'
require_relative '../../strings/thanks'
module Triage class ThankContribution < CommunityProcessor include Strings::Thanks
GitLab.org / Professional Services Automation / Tools / Migration / Congregate incoming+f788b07907f3b3a16b53556a3c2cb09c@incoming.gitlab.com
react_to 'merge_request.open'
def applicable?
event.wider_community_author? &&
(event.from_gitlab_org? || event.from_www_gitlab_com?) &&
EXCLUDED_PATH_PREFIXES.none? { |prefix| event.project_path_with_namespace.start_with?(prefix) }
end
def process
post_thank_you_message
end
def documentation
<<~TEXT
This processor posts a thank you message to www.gitlab.com merge requests created by community contributors.
TEXT
end
private
def post_thank_you_message
thank_you_message = project_thanks
body = format(thank_you_message, author_username: event.event_actor_username)
add_comment(body, append_source_link: true)
end
def project_thanks
case event.project_id
when GITLAB_RUNNER_PROJECT_ID
runner_thanks
when WWW_GITLAB_COM_PROJECT_ID
www_gitlab_com_thanks
when GITLAB_FOSS_PROJECT_ID
gitlab_foss_thanks
else
default_thanks
end
end
def default_thanks
<<~MARKDOWN.chomp
#{intro_thanks}
#{READY_FOR_REVIEW}
#{REQUEST_HELP}
#{GROUP_LABEL}
#{SIGNOFF_THANKS}
MARKDOWN
end
def gitlab_foss_thanks
<<~MARKDOWN.chomp
#{GITLAB_FOSS_BODY}
#{SIGNOFF_THANKS}
MARKDOWN
end
def runner_thanks
<<~MARKDOWN.chomp
#{intro_thanks}
#{READY_FOR_REVIEW}
#{REQUEST_HELP}
#{RUNNER_BODY}
#{SIGNOFF_THANKS}
MARKDOWN
end
def www_gitlab_com_thanks
<<~MARKDOWN.chomp
#{intro_thanks}
#{READY_FOR_REVIEW}
#{WWW_GITLAB_COM_BODY}
#{SIGNOFF_THANKS}
MARKDOWN
end
def intro_thanks
event.from_community_fork? ? INTRO_THANKS_FOR_COMMUNITY_FORK : INTRO_THANKS_DEFAULT
end
end end