Namdak Tonpa 6 лет назад
Родитель
Сommit
ad426ab116
5 измененных файлов с 24 добавлено и 5 удалено
  1. 1 1
      include/mad.hrl
  2. BIN
      mad
  3. 1 0
      src/mad.erl
  4. 1 0
      src/profile/mad_local.erl
  5. 21 4
      src/sources/mad_git.erl

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"69bcc3").
+-define(VERSION,"2b8e56").


+ 1 - 0
src/mad.erl

@@ -35,6 +35,7 @@ atomize("cle"++_) -> 'clean';
 atomize("com"++_) -> 'compile';
 atomize("eunit")  -> 'eunit';
 atomize("up")     -> 'up';
+atomize("get")    -> 'get';
 atomize("rel"++_) -> 'release';
 atomize("bun"++_) -> 'release';
 atomize("sta"++_) -> 'start';

+ 1 - 0
src/profile/mad_local.erl

@@ -3,6 +3,7 @@
 
 compile(Params)   -> mad_compile:compile(Params).
 app(Params)       -> mad_static:app(Params).
+get(Params)       -> mad_git:get_repo(Params).
 release(Params)   -> mad_release:release(Params).
 resolve(Params)   -> mad_resolve:main(Params).
 clean(Params)     -> mad_run:clean(Params).

+ 21 - 4
src/sources/mad_git.erl

@@ -30,10 +30,26 @@ fetch(Cwd, Config, ConfigFile, [H|T]) ->
          {error,E} -> {error,E};
          {ok,_} -> fetch(Cwd, Config, ConfigFile, T) end.
 
-git_clone(Uri,Fast,TrunkPath,Rev) when Rev == "head" orelse Rev == "HEAD" orelse Rev == "master" orelse Rev == [] ->
+get_repo([Name|_]) ->
+    { Cwd, File, Conf } = mad_utils:configs(),
+    Res = case string:tokens(Name,"/") of
+         [Org, Rep] -> {ok,Rep,lists:concat(["https://github.com/",Org,"/",Rep])};
+         [Rep] -> {ok,Rep,lists:concat(["https://github.com/synrc/",Rep])};
+         [] -> {error,"Repository unspecified."}
+    end,
+    case Res of
+         {error,X} -> {error,X};
+         {ok,N,Uri} -> fetch_dep(Cwd,Conf,File,N,"git",Uri,[],deps_fetch), {ok,N}
+    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," ",TrunkPath,
+      " && cd ",TrunkPath,
+      " && git checkout \"",Rev,"\"" ],Rev}.
 
 fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache) ->
 
@@ -85,13 +101,14 @@ build_dep(Cwd, Conf, _ConfFile, Publisher, Name, _Cmd, _Co, Dir) ->
 
 %% internal
 name_and_repo(X) -> mad_utils:name_and_repo(X).
-get_publisher(Uri) -> case string:tokens(Uri,"@:/") of [_Proto,_Server,Publisher|_RepoPath] -> Publisher; _ -> core end.
+get_publisher(Uri) -> case string:tokens(Uri,"@:/") of
+   [_Proto,_Server,Publisher|_RepoPath] -> Publisher; _ -> core end.
 
 pull(_,[])         -> {ok,[]};
 pull(Config,[F|T]) ->
     mad:info("==> up: ~p~n", [F]),
     {_,Status,Message} = sh:run(lists:concat(["cd ",F," && git pull && cd -"])),
-    %io:format("status: ~p~n",[{Status,Message}]),
+    %mad:info("status: ~p~n",[{Status,Message}]),
     case Status of
          0 -> mad_utils:verbose(Config,Message), pull(Config,T);
          _ -> case binary:match(Message,[<<"You are not currently on a branch">>]) of