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_detach_options ⇒ Object
Returns the value of attribute checkout_detach_options.
-
#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_checkout_detach(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.
259 260 261 262 263 264 265 266 267 268 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 259 def initialize(build) super @command = 'git' @flags = %w[] @clone_options = "clone %{flags} %{url} %{dir}" @pull_options = "--git-dir %{repo_dir}/.git --work-tree %{repo_dir} pull" @checkout_options = "--git-dir %{repo_dir}/.git --work-tree %{repo_dir} checkout %{checksum_hash}" @checkout_detach_options = "--git-dir %{repo_dir}/.git --work-tree %{repo_dir} checkout --detach %{checksum_hash}" @reset_options = "--git-dir %{repo_dir}/.git --work-tree %{repo_dir} reset %{checksum_hash}" end |
Instance Attribute Details
#checkout_detach_options ⇒ Object
Returns the value of attribute checkout_detach_options.
257 258 259 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 257 def @checkout_detach_options end |
#checkout_options ⇒ Object
Returns the value of attribute checkout_options.
257 258 259 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 257 def @checkout_options end |
#clone_options ⇒ Object
Returns the value of attribute clone_options.
257 258 259 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 257 def @clone_options end |
#flags ⇒ Object
Returns the value of attribute flags.
256 257 258 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 256 def flags @flags end |
#pull_options ⇒ Object
Returns the value of attribute pull_options.
257 258 259 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 257 def @pull_options end |
#reset_options ⇒ Object
Returns the value of attribute reset_options.
257 258 259 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 257 def @reset_options end |
Instance Method Details
#commit_hash(dir) ⇒ Object
295 296 297 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 295 def commit_hash(dir) `#{@command} --git-dir #{shellquote(dir +'/.git')} --work-tree #{shellquote(dir)} rev-parse --verify HEAD`.strip end |
#current_branch(dir) ⇒ Object
299 300 301 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 299 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
280 281 282 283 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 280 def run_checkout(dir, checksum_hash) _pp "GIT CHECKOUT", dir, checksum_hash _run , { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) } end |
#run_checkout_detach(dir, checksum_hash) ⇒ Object
285 286 287 288 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 285 def run_checkout_detach(dir, checksum_hash) _pp "GIT CHECKOUT DETACH", dir, checksum_hash _run , { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) } end |
#run_clone(dir, url, _flags = []) ⇒ Object
270 271 272 273 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 270 def run_clone(dir, url, _flags = []) _pp "GIT", url, dir.relative_path _run , { :flags => [flags, _flags].flatten.join(' '), :url => shellquote(url), :dir => shellquote(filename(dir)) } end |
#run_pull(dir, url) ⇒ Object
275 276 277 278 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 275 def run_pull(dir, url) _pp "GIT PULL", url, dir.relative_path _run , { :repo_dir => shellquote(dir) } end |
#run_reset_hard(dir, checksum_hash) ⇒ Object
290 291 292 293 |
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 290 def run_reset_hard(dir, checksum_hash) _pp "GIT RESET", dir, checksum_hash _run , { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) } end |