Sha256: 95db49035e9630fa18e524e01c1e361c20d9a0dcc255822e549900ecf2859a51

Contents?: true

Size: 1.63 KB

Versions: 20

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "base"

module Neetob
  class CLI
    module Github
      module MakePr
        class Script < Base
          attr_accessor :apps, :sandbox, :path_to_the_script_file

          def initialize(apps, path_to_the_script_file, pr_title, branch_name, sandbox = false)
            super(pr_title, branch_name)
            @apps = apps
            @sandbox = sandbox
            @path_to_the_script_file = path_to_the_script_file
          end

          def run
            matching_apps = find_all_matching_apps(apps, :github, sandbox)
            delete_and_create_temp_neetob_dir
            matching_apps.each do |app|
              ui.info("\n  Working on #{app}  \n")
              begin
                clone_app_in_tmp_dir(app)
                check_and_delete_remote_branch(app)
                update_script_file_permissions
                execute_script(app)
                ui.info(add_commmit_and_push_changes(app))
                delete_local_feature_branch(app)
                res = client.create_pull_request(app, "main", branch_name, pr_title)
                ui.success("PR created in \"#{app}\" project successfully.")
              rescue StandardError => e
                ExceptionHandler.new(e).process
              end
            end
            `rm -rf /tmp/neetob`
          end

          private

            def update_script_file_permissions
              `chmod +x #{path_to_the_script_file}`
            end

            def execute_script(app)
              `#{cd_to_app_in_tmp_dir(app)} && #{path_to_the_script_file}`
            end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
neetob-ud-1.0.59 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.8 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.6 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.4 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.3 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.2 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.1 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.0 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.1.3 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.1.2 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.1.1 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.1.0 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.14 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.13 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.11 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.9 lib/neetob/cli/github/make_pr/script.rb
neetob-ud-0.2.5 lib/neetob/cli/github/make_pr/script.rb
neetob-0.1.2 lib/neetob/cli/github/make_pr/script.rb
neetob-0.1.1 lib/neetob/cli/github/make_pr/script.rb
neetob-0.1.0 lib/neetob/cli/github/make_pr/script.rb