Sha256: 2591c39b4ec842e0ce98a8b75b9c96f1296e66528d15d4ace3ccd62f7043f704

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "base"

module Neetob
  class CLI
    module Github
      module MakePr
        class ComplianceFix < Base
          attr_accessor :repos, :sandbox, :should_fix_nanos

          def initialize(repos, should_fix_nanos = false, sandbox = false)
            super()
            @repos = repos
            @sandbox = sandbox
            @should_fix_nanos = should_fix_nanos
          end

          def run
            matching_repos = should_fix_nanos ?
              add_org_suffix(find_all_matching_gems) :
              find_all_matching_apps_or_repos(repos, :github, sandbox)
            delete_and_create_temp_neetob_dir
            matching_repos.each do |repo|
              ui.info("\nWorking on #{repo}\n")
              begin
                clone_repo_in_tmp_dir(repo)
                check_and_delete_remote_branch(repo)
                bundle_install(repo)
                fix_neeto_audit(repo)
                ui.info(add_commmit_and_push_changes(repo))
                delete_local_feature_branch(repo)
                res = client.create_pull_request(repo, "main", BRANCH_NAME, PR_TITLE)
                ui.success("PR created in \"#{repo}\" project successfully.")
              rescue StandardError => e
                ExceptionHandler.new(e).process
              end
            end
            `rm -rf /tmp/neetob`
          end

          private

            def bundle_install(repo)
              `#{cd_to_repo_in_tmp_dir(repo)} && bundle install`
            end

            def fix_neeto_audit(repo)
              `#{cd_to_repo_in_tmp_dir(repo)} && bundle exec neeto-audit -a`
            end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
neetob-0.2.7 lib/neetob/cli/github/make_pr/compliance_fix.rb
neetob-0.2.6 lib/neetob/cli/github/make_pr/compliance_fix.rb
neetob-0.2.5 lib/neetob/cli/github/make_pr/compliance_fix.rb
neetob-0.2.4 lib/neetob/cli/github/make_pr/compliance_fix.rb
neetob-0.2.3 lib/neetob/cli/github/make_pr/compliance_fix.rb