Class: MRuby::Command::Git
- Inherits:
-
MRuby::Command
- Object
- MRuby::Command
- MRuby::Command::Git
- Defined in:
- ext/enterprise_script_service/mruby/lib/mruby/build/command.rb
Constant Summary
Constants inherited from MRuby::Command
Instance Attribute Summary collapse
-
#checkout_options ⇒ Object
Returns the value of attribute checkout_options.
-
#clone_options ⇒ Object
Returns the value of attribute clone_options.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#pull_options ⇒ Object
Returns the value of attribute pull_options.
-
#reset_options ⇒ Object
Returns the value of attribute reset_options.
Attributes inherited from MRuby::Command
Instance Method Summary collapse
- #commit_hash(dir) ⇒ Object
- #current_branch(dir) ⇒ Object
-
#initialize(build) ⇒ Git
constructor
A new instance of Git.
- #run_checkout(dir, checksum_hash) ⇒ Object
- #run_clone(dir, url, _flags = []) ⇒ Object
- #run_pull(dir, url) ⇒ Object
- #run_reset_hard(dir, checksum_hash) ⇒ Object
Methods inherited from MRuby::Command
Constructor Details
#initialize(build) ⇒ Git
Returns a new instance of Git.
284 285 286 287 288 289 290 291 292 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 284 def initialize(build) super @command = 'git' @flags = %w[] = "clone %{flags} %{url} %{dir}" = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} pull" = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} checkout %{checksum_hash}" = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} reset %{checksum_hash}" end |
Instance Attribute Details
#checkout_options ⇒ Object
Returns the value of attribute checkout_options.
282 283 284 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 282 def end |
#clone_options ⇒ Object
Returns the value of attribute clone_options.
282 283 284 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 282 def end |
#flags ⇒ Object
Returns the value of attribute flags.
281 282 283 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 281 def flags @flags end |
#pull_options ⇒ Object
Returns the value of attribute pull_options.
282 283 284 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 282 def end |
#reset_options ⇒ Object
Returns the value of attribute reset_options.
282 283 284 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 282 def end |
Instance Method Details
#commit_hash(dir) ⇒ Object
314 315 316 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 314 def commit_hash(dir) `#{@command} --git-dir #{shellquote(dir +'/.git')} --work-tree #{shellquote(dir)} rev-parse --verify HEAD`.strip end |
#current_branch(dir) ⇒ Object
318 319 320 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 318 def current_branch(dir) `#{@command} --git-dir #{shellquote(dir + '/.git')} --work-tree #{shellquote(dir)} rev-parse --abbrev-ref HEAD`.strip end |
#run_checkout(dir, checksum_hash) ⇒ Object
304 305 306 307 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 304 def run_checkout(dir, checksum_hash) _pp "GIT CHECKOUT", checksum_hash _run , { :checksum_hash => checksum_hash, :repo_dir => dir } end |
#run_clone(dir, url, _flags = []) ⇒ Object
294 295 296 297 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 294 def run_clone(dir, url, _flags = []) _pp "GIT", url, dir.relative_path _run , { :flags => [flags, _flags].flatten.join(' '), :url => url, :dir => filename(dir) } end |
#run_pull(dir, url) ⇒ Object
299 300 301 302 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 299 def run_pull(dir, url) _pp "GIT PULL", url, dir.relative_path _run , { :repo_dir => dir } end |
#run_reset_hard(dir, checksum_hash) ⇒ Object
309 310 311 312 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 309 def run_reset_hard(dir, checksum_hash) _pp "GIT RESET", checksum_hash _run , { :checksum_hash => checksum_hash, :repo_dir => dir } end |