Class: Neetob::CLI::FetchorupdateRepos::Execute

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/fetchorupdate_repos/execute.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Base

#ui

Instance Method Summary collapse

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_reposObject

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

#appsObject

Returns the value of attribute apps.



9
10
11
# File 'lib/neetob/cli/fetchorupdate_repos/execute.rb', line 9

def apps
  @apps
end

#sandboxObject

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

#runObject



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