Browse Source

simplify. make sure we are faster that rebar3 in fetching deps

Namdak Tonpa 6 years ago
parent
commit
da6e25ec81
4 changed files with 7 additions and 12 deletions
  1. 1 1
      include/mad.hrl
  2. BIN
      mad
  3. 5 10
      src/mad_git.erl
  4. 1 1
      src/mad_utils.erl

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"ceb8d1").
+-define(VERSION,"df551e").

BIN
mad


+ 5 - 10
src/mad_git.erl

@@ -47,14 +47,9 @@ get_repo([Name|_]) ->
          {ok,N,Uri} -> fetch_dep(Cwd,Conf,File,N,"git",Uri,[],deps_fetch,[])
          {ok,N,Uri} -> fetch_dep(Cwd,Conf,File,N,"git",Uri,[],deps_fetch,[])
     end end.
     end end.
 
 
-git_clone(Uri,Fast,TrunkPath,Rev) when Rev == "head"   orelse Rev == "HEAD"
-                                orelse Rev == "master" orelse Rev == [] ->
-    {["git clone ",Fast,Uri," ",TrunkPath],Rev};
-
-git_clone(Uri,_Fast,TrunkPath,Rev) ->
-    {["git clone ",Uri," ",TrunkPath,
-      " && cd ",TrunkPath,
-      " && git checkout \"",Rev,"\"" ],Rev}.
+git_clone(Uri,Fast,TrunkPath,[]) -> git_clone(Uri,Fast,TrunkPath,"master");
+git_clone(Uri,Fast,TrunkPath,Rev) ->
+    {["git clone --single-branch --branch ",Rev," ",Fast,Uri," ",TrunkPath],Rev}.
 
 
 fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache) ->
 fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache) ->
     fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache, deep).
     fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache, deep).
@@ -67,7 +62,7 @@ fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache, Deep) ->
     mad:info("==> dependency: ~p tag: ~p~n", [Uri,Co]),
     mad:info("==> dependency: ~p tag: ~p~n", [Uri,Co]),
 
 
     Fast = case mad_utils:get_value(fetch_depth,Config,1) of
     Fast = case mad_utils:get_value(fetch_depth,Config,1) of
-                1 -> " --depth=1 ";
+                1 -> " --depth 1 ";
                     _  -> "" end,
                     _  -> "" end,
 
 
     {R,Co1} = case Co of
     {R,Co1} = case Co of
@@ -75,7 +70,7 @@ fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache, Deep) ->
         {_,Rev} -> git_clone(Uri,Fast,TrunkPath,Rev);
         {_,Rev} -> git_clone(Uri,Fast,TrunkPath,Rev);
         Master  -> git_clone(Uri,Fast,TrunkPath,Master) end,
         Master  -> git_clone(Uri,Fast,TrunkPath,Master) end,
 
 
-    %mad:info("Fetch: ~s~n",[R]),
+%    mad:info("Fetch: ~s~n",[R]),
 
 
     FetchStatus = case filelib:is_dir(TrunkPath) of
     FetchStatus = case filelib:is_dir(TrunkPath) of
                        true -> {skip,0,list_to_binary("Directory "++TrunkPath++" exists.")};
                        true -> {skip,0,list_to_binary("Directory "++TrunkPath++" exists.")};

+ 1 - 1
src/mad_utils.erl

@@ -52,7 +52,7 @@ sub_dirs(Cwd, ConfigFile, [Dir|T], Acc) ->
              Acc1 = sub_dirs(SubDir, ConfigFile, get_value(sub_dirs, Conf1, []),
              Acc1 = sub_dirs(SubDir, ConfigFile, get_value(sub_dirs, Conf1, []),
                     Acc ++ [SubDir]),
                     Acc ++ [SubDir]),
              sub_dirs(Cwd, ConfigFile, T, Acc1);
              sub_dirs(Cwd, ConfigFile, T, Acc1);
-         {error,E} -> [] end.
+         {error,_E} -> [] end.
 
 
 lib_dirs(Cwd, Conf) -> lib_dirs(Cwd, get_value(lib_dirs, Conf, []), []).
 lib_dirs(Cwd, Conf) -> lib_dirs(Cwd, get_value(lib_dirs, Conf, []), []).