Module: GitCli::Common

Includes:
Antrapol::ToolRack::ConditionUtils, Antrapol::ToolRack::ExceptionUtils
Included in:
Vcs, Workspace
Defined in:
lib/git_cli.rb

Instance Method Summary collapse

Instance Method Details

#dry_runObject



86
87
88
# File 'lib/git_cli.rb', line 86

def dry_run
  @dry_run.nil? ? false : @dry_run
end

#dry_run=(val) ⇒ Object



82
83
84
# File 'lib/git_cli.rb', line 82

def dry_run=(val)
  @dry_run = val if not_empty?(val) and is_bool?(val)
end

#log_debug(str) ⇒ Object



70
71
72
# File 'lib/git_cli.rb', line 70

def log_debug(str)
  GitCli::Global.instance.logger.debug(str)
end

#log_error(str) ⇒ Object



74
75
76
# File 'lib/git_cli.rb', line 74

def log_error(str)
  GitCli::Global.instance.logger.error(str)
end

#log_warn(str) ⇒ Object



78
79
80
# File 'lib/git_cli.rb', line 78

def log_warn(str)
  GitCli::Global.instance.logger.warn(str)
end

#os_exec(path, &block) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/git_cli.rb', line 48

def os_exec(path, &block)

  #Gvcs::Config.instance.command_output.puts("Git command : #{path}") if Gvcs::Config.instance.is_show_vcs_command?
  log_debug("Git command : #{path}")

  # redirect stderr to stdout
  path = "#{path} 2>&1"
  if dry_run
    block.call(:dry_run_command, path) if block
  else
    res = Antrapol::ToolRack::ProcessUtilsEngine.exec(path)
    if block
      # $?.exitstatus => error codes
      # $?.success? => true / false
      # $?.pid => child PID
      block.call($?, res)
    else
      res.strip
    end
  end
end