Sha256: 56fc3db48dff7fba01b1cd0ae09f0b156268a8552d4f04d30abc1567d9970c45

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require_relative 'base'

module Gitlab
  module Triage
    module Action
      class Summarize < Base
        class Dry < Summarize
          private

          def perform
            puts "The following issue would be created for the rule **#{policy.name}**:\n\n"
            puts ">>>"
            puts "* Title: #{issue.title}"
            puts "* Description: #{issue.description}"
            puts ">>>"
          end
        end

        def act
          perform if policy.resources.any? && issue.valid?
        end

        private

        def perform
          network.post_api(post_issue_url, post_issue_body)
        end

        def issue
          @issue ||= policy.build_issue
        end

        def post_issue_url
          # POST /projects/:id/issues
          # https://docs.gitlab.com/ee/api/issues.html#new-issue
          post_url = UrlBuilders::UrlBuilder.new(
            network_options: network.options,
            source_id: network.options.project_id,
            resource_type: 'issues'
          ).build

          puts Gitlab::Triage::UI.debug "post_issue_url: #{post_url}" if network.options.debug

          post_url
        end

        def post_issue_body
          {
            title: issue.title,
            description: issue.description
          }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab-triage-0.15.0 lib/gitlab/triage/action/summarize.rb