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

    location = opts[:git]

    _ = File.rm_rf!(path)
    command  = ~s(git clone --no-checkout --progress "#{location}" "#{path}")

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


  end

  defp get_rev_info do
    origin = run_system("git", ["--git-dir=.git" , "config" , "remote.origin.url"])
    rev = run_system("git", ["--git-dir=.git" , "rev-parse" , "--verify", "--quiet", "HEAD"])
    [ origin: origin, rev: rev ]
  end

  defp update_origin(location) do
    _ = System.cmd("git", ["--git-dir=.git", "config" , "remote.origin.url", location])
    :ok
  end

  defp run_system(cmd, args) do
    System.cmd(cmd, args)
    |> elem(0)
    |> String.strip
  end 

  defp run_cmd_or_raise(cmd, args) do
    {_,status} = System.cmd(cmd, args)
    if status != 0 do
      Mix.raise "Command `#{cmd} #{Enum.join(args, " ")}` failed"
    end
    true
  end
