Sha256: 9d0ca40dc43023e29f2eb64a5005eb0bdd818ffc4172ca2be4e05c85dfeab302

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'thor'
require_relative '../lib/gitab_codeowners_checker'

class CLI < Thor
  desc 'check_codeowners', 'check codowners'
  method_option :files, aliases: '-f', type: :array, desc: 'a list of files to check'
  method_option :root_path, aliases: '-r', desc: 'path to application root folder', default: Dir.pwd
  method_option :file_ext, aliases: '-e', desc: 'a file extenstion to filter files (example - "rb")'
  method_option :paths, aliases: '-p', type: :array, desc: 'a list of paths to select'
  method_option :ignore_paths, aliases: '-i', type: :array, desc: 'a list of paths to ignore'
  def check_codeowners # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
    opts = {
      root_path: options.fetch(:root_path) || '.',
      paths: options[:paths],
      ignore_paths: options[:ignore_paths],
      file_ext: options[:file_ext] || ''
    }.compact

    project = GitlabCodeownersChecks::Project.new(opts)
    checker = GitlabCodeownersChecker::Checkers::NoOwner.new(
      files: options[:files] || project.file_paths,
      codeowners: project.codeowners
    )

    return if checker.files_without_owner.empty?

    warn('Files without codeowners:')
    checker.files_without_owner.each { |file| warn file }
    exit(1)
  end
end

CLI.start(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitab_codeowners_checker-0.1.0 exe/gitlab-codeowners-checker