Class: Neetob::CLI::FetchorupdateRepos::Execute
- Defined in:
- lib/neetob/cli/fetchorupdate_repos/execute.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#all_neeto_repos ⇒ Object
Returns the value of attribute all_neeto_repos.
-
#apps ⇒ Object
Returns the value of attribute apps.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Attributes inherited from Base
Instance Method Summary collapse
- #checkout_to_main_and_fetch_commits(app_name) ⇒ Object
- #clone_repo(app_name) ⇒ Object
- #directory_exists(app_name) ⇒ Object
-
#initialize(sandbox = false, all_neeto_repos = false, apps = ["*"]) ⇒ Execute
constructor
A new instance of Execute.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(sandbox = false, all_neeto_repos = false, apps = ["*"]) ⇒ Execute
Returns a new instance of Execute.
11 12 13 14 15 16 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 11 def initialize(sandbox = false, all_neeto_repos = false, apps = ["*"]) super() @sandbox = sandbox @apps = apps @all_neeto_repos = all_neeto_repos end |
Instance Attribute Details
#all_neeto_repos ⇒ Object
Returns the value of attribute all_neeto_repos.
9 10 11 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 9 def all_neeto_repos @all_neeto_repos end |
#apps ⇒ Object
Returns the value of attribute apps.
9 10 11 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 9 def apps @apps end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
9 10 11 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 9 def sandbox @sandbox end |
Instance Method Details
#checkout_to_main_and_fetch_commits(app_name) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 35 def checkout_to_main_and_fetch_commits(app_name) %x[ cd #{app_name} && git checkout main && git pull origin main ] if $?.success? puts "------Successfully pulled main branch of #{app_name}------" else puts "------Unable to pull the main branch of #{app_name} due to conflicts------" end end |
#clone_repo(app_name) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 44 def clone_repo(app_name) `git clone [email protected]:bigbinary/#{app_name}.git` if $?.success? puts "------Done cloning #{app_name}------" else puts "------Failed cloning #{app_name}------" end end |
#directory_exists(app_name) ⇒ Object
31 32 33 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 31 def directory_exists(app_name) File.directory?(app_name) end |
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 18 def run neeto_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos) neeto_apps.each do |app| app_name = app.split("/").last ui.info("\nWorking on #{app_name}\n") if directory_exists(app_name) checkout_to_main_and_fetch_commits(app_name) else clone_repo(app_name) end end end |