 
   def import(conn, %{"family" => family_params}) do
     author = Session.current_author(conn)
-    result = with {:ok, repo} <- Git.clone([family_params["source"], family_params["path"]]),
-      repository = Repository.changeset(%Repository{}, family_params),
-      {:ok, repository} <- Repo.insert(repository),
-      family = Family.changeset(%Family{repository_id: repository.id, author_id: author.id}, family_params),
-      {:ok, family} <- Repo.insert(family),
-      do: {:ok, family}
+    result = with {:ok, _} <- Git.clone([family_params["source"], family_params["path"]]),
+    repository = Repository.changeset(%Repository{}, family_params),
+    {:ok, repository} <- Repo.insert(repository),
+    family = Family.changeset(%Family{repository_id: repository.id, author_id: author.id}, family_params),
+    {:ok, family} <- Repo.insert(family),
+    do: {:ok, family}
 
-    case result do
-      {:ok, family} ->
-        conn
-        |> put_flash(:info, "Repository imported successfully.")
-        |> render(conn, :import, family: family)
-      {:error, _} ->
-        conn
-        |> put_flash(:info, "Failed to import repository.")
-        |> redirect(to: github_path(conn, :index))
-    end
+  case result do
+    {:ok, family} ->
+      conn
+      |> put_flash(:info, "Repository imported successfully.")
+      |> render(conn, :import, family: family)
+    {:error, _} ->
+      conn
+      |> put_flash(:info, "Failed to import repository.")
+      |> redirect(to: github_path(conn, :index))
+  end
   end
 
   def sync(conn, %{"family" => family_params}) do

    family = if is_nil(family), do: %Family{author_id: author.id}, else: family
    family = Family.changeset(family, family_params)
    result = with {:ok, family} <- Repo.insert_or_update(family),
      {:ok, articles, failed_paths} <- download_articles(author, family),
      do: {:ok, articles, failed_paths}

    case result do
      {:ok, articles, failed_paths} ->
        message = if length(failed_paths) == 0 do
            "Repository synced successfully."
          else
            "Failed synced following files:\n#{failed_paths |> Enum.join("\n")}"
          end
        conn
        |> put_flash(:info, message)
        |> redirect(to: my_article_path(conn, :index))
      {:error, _} ->
        conn
        |> put_flash(:info, "Failed to sync repository.")
        |> redirect(to: github_path(conn, :index))
    end
  end

  def delete(conn, %{"id" => id}) do

    result = trees["tree"]
    |> Enum.filter(&(is_valid_file &1))
    |> Enum.filter(&(is_nil Repo.get_by(Article, family_id: family.id, path: &1["path"], sha: &1["sha"])))
    |> Enum.map(&(download_article author, family, &1["path"]))
    articles = result
    |> Enum.filter(&(elem(&1, 0) == :ok))
    |> Enum.map(&(elem(&1, 1)))
