Class: Neetob::CLI::Github::Search
- Inherits:
-
MakePr::Base
- Object
- Base
- Base
- MakePr::Base
- Neetob::CLI::Github::Search
- Defined in:
- lib/neetob/cli/github/search.rb
Constant Summary
Constants inherited from MakePr::Base
MakePr::Base::BRANCH_NAME, MakePr::Base::PR_TITLE
Constants inherited from Base
Instance Attribute Summary collapse
-
#key_to_search ⇒ Object
Returns the value of attribute key_to_search.
-
#replacement_term ⇒ Object
Returns the value of attribute replacement_term.
-
#repos ⇒ Object
Returns the value of attribute repos.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#search_file_path ⇒ Object
Returns the value of attribute search_file_path.
Attributes inherited from MakePr::Base
Attributes inherited from Base
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(repos, key_to_search, search_file_path, replacement_term, sandbox = false) ⇒ Search
constructor
A new instance of Search.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(repos, key_to_search, search_file_path, replacement_term, sandbox = false) ⇒ Search
Returns a new instance of Search.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/neetob/cli/github/search.rb', line 11 def initialize(repos, key_to_search, search_file_path, replacement_term, sandbox = false) @key_to_search = key_to_search @replacement_term = replacement_term branch_name = build_branch_name pr_title = build_pr_title super(pr_title, branch_name) @search_file_path = search_file_path @repos = repos @sandbox = sandbox end |
Instance Attribute Details
#key_to_search ⇒ Object
Returns the value of attribute key_to_search.
9 10 11 |
# File 'lib/neetob/cli/github/search.rb', line 9 def key_to_search @key_to_search end |
#replacement_term ⇒ Object
Returns the value of attribute replacement_term.
9 10 11 |
# File 'lib/neetob/cli/github/search.rb', line 9 def replacement_term @replacement_term end |
#repos ⇒ Object
Returns the value of attribute repos.
9 10 11 |
# File 'lib/neetob/cli/github/search.rb', line 9 def repos @repos end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
9 10 11 |
# File 'lib/neetob/cli/github/search.rb', line 9 def sandbox @sandbox end |
#search_file_path ⇒ Object
Returns the value of attribute search_file_path.
9 10 11 |
# File 'lib/neetob/cli/github/search.rb', line 9 def search_file_path @search_file_path end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/neetob/cli/github/search.rb', line 22 def run matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox) matching_repos.each do |repo| ui.info("\nSearching in #{repo}") clone_repo_in_tmp_dir(repo) begin if replacement_term.nil? find_and_print_matching_lines(repo) else check_and_delete_remote_branch(repo) find_and_replace_keyword(repo) ui.say("No changes were made to #{repo}, check if keyword exists.") and next if !are_changes_made?(repo) ui.info(add_commmit_and_push_changes!(repo)) delete_local_feature_branch(repo) pull_request = client.create_pull_request(repo, "main", branch_name, pr_title) ui.success("Successfully replaced \"#{key_to_search}\" with \"#{replacement_term}\" in #{repo}") ui.success("PR Link:- #{pull_request.html_url}") end rescue StandardError => e ExceptionHandler.new(e).process end end `rm -rf /tmp/neetob` end |