 
   def merge_branch!(token, repository_id, from, to, commit_message) when is_binary(token) do
     cfg = config()
-    raw = HTTPoison.patch!(
+    %{body: raw, status_code: 200} = HTTPoison.patch!(
       "#{cfg[:site]}/repositories/#{repository_id}/merges",
       Poison.encode!(%{
         "base": to,


  def synthesize_commit!(token, repository_id, branch, tree, parents, commit_message) when is_binary(token) do
    cfg = config()
    raw = HTTPoison.post!(
      "#{cfg[:site]}/repositories/#{repository_id}/git/commits",
      Poison.encode!(%{
        "parents": parents,

    %{body: raw, status_code: status_code} = HTTPoison.get!(
      "#{cfg[:site]}/repositories/#{repository_id}/branches/#{to}",
      [{"Authorization", "token #{token}"}, {"Accept", @content_type}])
    %{body: _, status_code: 200} = cond do
      status_code == 404 ->
        HTTPoison.post!(
          "#{cfg[:site]}/repositories/#{repository_id}/refs",
