         version
       :error ->
         version = 
-          System.cmd("git",["--version"])
-          |> elem(0)
-          |> String.strip
+          run_system("git", ["--version"])
           |> parse_version
 
         Mix.State.put(:git_version, version)


  defp do_checkout(opts) do
    ref = get_lock_rev(opts[:lock]) || get_opts_rev(opts)
    run_cmd_or_raise "git --git-dir=.git checkout --quiet #{ref}"

    if opts[:submodules] do
      run_cmd_or_raise "git --git-dir=.git submodule update --init --recursive"
    end

    get_lock(opts)

    location = opts[:git]

    _ = File.rm_rf!(path)
    cmd = "git"
    args = ~w( clone --no-checkout --progress )
    args = args ++ [location, path]

    run_cmd_or_raise(cmd, args)
    File.cd! path, fn -> do_checkout(opts) end
  end

