Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified elixir/github_repo_cloner
Binary file not shown.
6 changes: 3 additions & 3 deletions elixir/lib/cloner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule GithubRepoCloner.Cloner do
username
|> request_repo_info
|> parse_response
|> clone_repos
|> clone_repos(username)
end

def clone, do: true
Expand All @@ -23,9 +23,9 @@ defmodule GithubRepoCloner.Cloner do

defp parse_response({:ok, %Tesla.Env{status: _}}), do: []

defp clone_repos(repo_info) do
defp clone_repos(repo_info, username) do
repo_info
|> Enum.map(fn(item) -> "git clone #{item["clone_url"]}" end)
|> Enum.map(fn(%{"clone_url" => clone_url, "name" => name}) -> "git clone #{clone_url} #{username}/#{name}" end)
|> Enum.join(" & ")
|> run_command
end
Expand Down
11 changes: 8 additions & 3 deletions elixir/test/cloner_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ defmodule GithubRepoCloner.ClonerTest do
username = "murjax"
clone_url1 = "https://github.com/murjax/spring_engine.git"
clone_url2 = "https://github.com/murjax/burger_bot.git"
repo_info = [%{"clone_url" => clone_url1}, %{"clone_url" => clone_url2}]
command1 = "git clone #{clone_url1}"
command2 = "git clone #{clone_url2}"
name1 = "spring_engine"
name2 = "burger_bot"
repo_info = [
%{"name" => name1, "clone_url" => clone_url1},
%{"name" => name2, "clone_url" => clone_url2}
]
command1 = "git clone #{clone_url1} #{username}/#{name1}"
command2 = "git clone #{clone_url2} #{username}/#{name2}"
final_command = "#{command1} & #{command2}"
expected_result = {:ok, "Command executed: #{final_command}"}

Expand Down