Browse Source

Rename clone to fetch

Sina Samavati 11 years ago
parent
commit
7dc3cf7896
2 changed files with 18 additions and 18 deletions
  1. 14 14
      src/mad_deps.erl
  2. 4 4
      test/mad_deps_SUITE.erl

+ 14 - 14
src/mad_deps.erl

@@ -2,7 +2,7 @@
 
 -export([repos_path/0]).
 -export([path/2]).
--export([clone/2]).
+-export([fetch/2]).
 -export([name_and_repo/1]).
 -export([checkout_to/1]).
 -export([get_publisher/1]).
@@ -27,12 +27,12 @@ path(Publisher, Repo) ->
     %% ~/.mad/repos/Publisher/Repo
     filename:join([?REPOS_PATH, Publisher, Repo]).
 
--spec clone(directory(), [dependency()]) -> ok.
-clone(_, []) ->
+-spec fetch(directory(), [dependency()]) -> ok.
+fetch(_, []) ->
     ok;
-clone(Cwd, [H|T]) when is_tuple(H) =:= false ->
-    clone(Cwd, T);
-clone(Cwd, [H|T]) ->
+fetch(Cwd, [H|T]) when is_tuple(H) =:= false ->
+    fetch(Cwd, T);
+fetch(Cwd, [H|T]) ->
     {Name, Repo} = name_and_repo(H),
     {Cmd, Uri, Co} = case Repo of
                          V={_, _, _} ->
@@ -44,27 +44,27 @@ clone(Cwd, [H|T]) ->
     Co1 = checkout_to(Co),
     Publisher = get_publisher(Uri),
     case get(Name) of
-        cloned ->
+        fetched ->
             ok;
         _ ->
-            clone_dep(Cwd, Publisher, Name, Cmd1, Uri),
+            fetch_dep(Cwd, Publisher, Name, Cmd1, Uri),
             build_dep(Cwd, Publisher, Name, Cmd1, Co1)
     end,
-    clone(Cwd, T).
+    fetch(Cwd, T).
 
--spec clone_dep(directory(), string(), string(), string(), uri()) -> ok.
-clone_dep(Cwd, Publisher, Name, Cmd, Uri) ->
+-spec fetch_dep(directory(), string(), string(), string(), uri()) -> ok.
+fetch_dep(Cwd, Publisher, Name, Cmd, Uri) ->
     TrunkPath = path(Publisher, Name),
     Opts = ["clone", Uri, TrunkPath],
     io:format("dependency: ~s~n", [Name]),
-    %% clone
+    %% fetch
     mad_utils:exec(Cmd, Opts),
-    put(Name, cloned),
+    put(Name, fetched),
 
     %% check dependencies of the dependency
     Conf = mad_utils:rebar_conf(TrunkPath),
     Conf1 = mad_utils:script(TrunkPath, Conf),
-    clone(Cwd, mad_utils:get_value(deps, Conf1, [])).
+    fetch(Cwd, mad_utils:get_value(deps, Conf1, [])).
 
 %% build dependency based on branch/tag/commit
 -spec build_dep(directory(), string(), string(), string(), string()) -> ok.

+ 4 - 4
test/mad_deps_SUITE.erl

@@ -6,13 +6,13 @@
 -export([name_and_repo/1]).
 -export([checkout_to/1]).
 -export([get_publisher/1]).
--export([clone/1]).
+-export([fetch/1]).
 
 -import(helper, [get_value/2]).
 
 
 all() ->
-    [repos_path, path, name_and_repo, checkout_to, get_publisher, clone].
+    [repos_path, path, name_and_repo, checkout_to, get_publisher, fetch].
 
 repos_path(_) ->
     Path = filename:join([os:cmd("echo -n $HOME"), ".mad", "repos"]),
@@ -36,7 +36,7 @@ get_publisher(_) ->
     "s1n4" = mad_deps:get_publisher("https://github.com/s1n4/mad"),
     "xyz" = mad_deps:get_publisher("https://bitbucket.org/xyz/repo").
 
-clone(Config) ->
+fetch(Config) ->
     DataDir = get_value(data_dir, Config),
     DepsDir = filename:join(DataDir, "deps"),
     os:cmd("rm -rf " ++ DepsDir),
@@ -46,6 +46,6 @@ clone(Config) ->
     Deps = [{mad, ".*",
              {git, "git://github.com/s1n4/mad.git", {branch, "master"}}
             }],
-    mad_deps:clone(DataDir, Deps),
+    mad_deps:fetch(DataDir, Deps),
     {ok, _} = file:list_dir(filename:join(DepsDir, "mad")),
     os:cmd("rm -rf " ++ DepsDir).