Class: MRuby::Command::Git

Inherits:
MRuby::Command show all
Defined in:
ext/enterprise_script_service/mruby/lib/mruby/build/command.rb

Constant Summary

Constants inherited from MRuby::Command

NotFoundCommands

Instance Attribute Summary collapse

Attributes inherited from MRuby::Command

#build, #command

Instance Method Summary collapse

Methods inherited from MRuby::Command

#clone

Constructor Details

#initialize(build) ⇒ Git

Returns a new instance of Git.



248
249
250
251
252
253
254
255
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 248

def initialize(build)
  super
  @command = 'git'
  @flags = %w[]
  @clone_options = "clone %{flags} %{url} %{dir}"
  @pull_options = "pull"
  @checkout_options = "checkout %{checksum_hash}"
end

Instance Attribute Details

#checkout_optionsObject

Returns the value of attribute checkout_options.



246
247
248
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 246

def checkout_options
  @checkout_options
end

#clone_optionsObject

Returns the value of attribute clone_options.



246
247
248
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 246

def clone_options
  @clone_options
end

#flagsObject

Returns the value of attribute flags.



245
246
247
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 245

def flags
  @flags
end

#pull_optionsObject

Returns the value of attribute pull_options.



246
247
248
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 246

def pull_options
  @pull_options
end

Instance Method Details

#run_checkout(dir, checksum_hash) ⇒ Object



270
271
272
273
274
275
276
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 270

def run_checkout(dir, checksum_hash)
  root = Dir.pwd
  Dir.chdir dir
  _pp "GIT CHECKOUT", checksum_hash
  _run checkout_options, { :checksum_hash => checksum_hash }
  Dir.chdir root
end

#run_clone(dir, url, _flags = []) ⇒ Object



257
258
259
260
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 257

def run_clone(dir, url, _flags = [])
  _pp "GIT", url, dir.relative_path
  _run clone_options, { :flags => [flags, _flags].flatten.join(' '), :url => url, :dir => filename(dir) }
end

#run_pull(dir, url) ⇒ Object



262
263
264
265
266
267
268
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 262

def run_pull(dir, url)
  root = Dir.pwd
  Dir.chdir dir
  _pp "GIT PULL", url, dir.relative_path
  _run pull_options
  Dir.chdir root
end