Sha256: 70fd986b09e5fae6ec6cb1c766e2c5189e6f3fd812670851bdcbf9ded130bab0

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 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
          net[:network].post_api(net[:token], 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(
            host_url: net[:host_url],
            api_version: net[:api_version],
            source_id: net[:source_id],
            resource_type: 'issues'
          ).build

          puts Gitlab::Triage::UI.debug "post_issue_url: #{post_url}" if net[:debug]

          post_url
        end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitlab-triage-0.14.1 lib/gitlab/triage/action/summarize.rb
gitlab-triage-0.14.0 lib/gitlab/triage/action/summarize.rb