module GitCli::GitCore

Public Instance Methods

exe_path() click to toggle source

extend Antrapol::ToolRack::ConditionUtils

# File lib/git_cli/git_core.rb, line 28
def exe_path
  if @gitPath.nil? or @gitPath.empty?
    st, path = is_installed?
    @gitPath = path.strip if st
  end

  @gitPath
end
version() click to toggle source
# File lib/git_cli/git_core.rb, line 37
def version
  
  if @version.nil? or @version.empty?
    path = exe_path
    cmd = "#{path} version"
    log_debug "version : #{cmd}"
    os_exec(cmd) do |st, res|
      # as current dev version
      if st.success?
        res.strip!
        # based on version 2.25.1
        @version = res.split(" ")[-1]
        [true,@version]
      else
        [false,""]
      end
    end
  else
    [true, @version]
  end

end

Private Instance Methods

is_installed?() click to toggle source
# File lib/git_cli/git_core.rb, line 61
def is_installed?

  gpath = File.which('git')
  if is_empty?(gpath) 
    [false, ""]
  else
    [true, gpath]
  end

end