Module: Recon::ReconData

Defined in:
lib/ds/recon/recon_data.rb

Class Method Summary collapse

Class Method Details

.local_dirObject



29
30
31
# File 'lib/ds/recon/recon_data.rb', line 29

def self.local_dir
  Settings.recon.local_dir
end

.repo_dirObject



32
33
34
# File 'lib/ds/recon/recon_data.rb', line 32

def self.repo_dir
  File.join DS.root, Settings.recon.git_local_name
end

.update!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ds/recon/recon_data.rb', line 6

def self.update!
  repo_name = Settings.recon.git_local_name
  url       = Settings.recon.git_repo
  branch    = Settings.recon.git_branch || 'main'
  logger    = DS.logger

  Dir.chdir local_dir do
    unless File.exist? repo_name
      puts Git.clone url, repo_name, branch: branch, remote: 'origin', log: logger
    end
    g = Git.open repo_name, log: logger
    begin
      puts g.fetch 'origin'
      puts g.checkout branch
      puts g.pull 'origin', branch
    rescue Git::GitExecuteError => e
      logger.warn { "Error executing git command" }
      logger.warn { e.message }
      STDERR.puts e.backtrace if ENV['DS_VERBOSE']
    end
  end
end