Sha256: d3fe4af9103794d0b1046a6e4e8a6c7f0780d97ba348c328de3942704100bcae

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require_relative '../../command'
require_relative '../../utils/table'

module Dri
  module Commands
    class Fetch
      class Quarantines < Dri::Command
        include Dri::Utils::Table
        using Refinements

        def initialize(options, search: '[QUARANTINE]')
          @options = options
          @search = search

          @today_iso_format = Time.now.strftime('%Y-%m-%dT00:00:00Z')
        end

        def execute(input: $stdin, output: $stdout)
          verify_config_exists
          title = add_color('Example name', :bright_yellow)
          url = add_color('URL', :bright_yellow)

          headers = [title, url]
          mrs = []

          logger.info "Fetching #{@search} MRs..."

          spinner.run do
            response = api_client.fetch_mrs(
              project_id: 'gitlab-org/gitlab',
              labels: 'QA,Quality',
              search: @search,
              in: :title,
              state: :opened
            )

            mrs = response.each_with_object([]) do |mr, found_mrs|
              title = mr['title'][13..].truncate(60) # remove the "[QUARANTINE] " prefix
              url = mr['web_url']

              found_mrs << [title, url]
            end
          end

          print_table(headers, mrs, alignments: [:left, :left])
          output.puts "Found #{mrs.size} open #{@search} MRs"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dri-0.3.1 lib/dri/commands/fetch/quarantines.rb
dri-0.3.0 lib/dri/commands/fetch/quarantines.rb
dri-0.2.0 lib/dri/commands/fetch/quarantines.rb