Anonymous avatar Anonymous committed 15db8be

First pass at updating dependencies (svn, hg, bzr untested)

Comments (0)

Files changed (1)

src/rebar_deps.erl

-
 %% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
 %% ex: ts=4 sw=4 et
 %% -------------------------------------------------------------------
 'get-deps'(Config, _) ->
     %% Determine what deps are available and missing
     Deps = rebar_config:get_local(Config, deps, []),
-    {_AvailableDeps, MissingDeps} = find_deps(Deps),
+    {AvailableDeps, MissingDeps} = find_deps(Deps),
 
     %% For each missing dep with a specified source, try to pull it.
-    PulledDeps = [use_source(D) || D <- MissingDeps, D#dep.source /= undefined],
+    PulledDeps0 = [use_source(D) || D <- MissingDeps, D#dep.source /= undefined],
+
+    %% For each available dep try to update the source to the specified
+    %% version.
+    PulledDeps1 = [update_source(D) || D <- AvailableDeps,
+                                       D#dep.source /= undefined],
 
     %% Add each pulled dep to our list of dirs for post-processing. This yields
     %% the necessary transitivity of the deps
-    erlang:put(?MODULE, [D#dep.dir || D <- PulledDeps]),
+    erlang:put(?MODULE, [D#dep.dir || D <- PulledDeps0 ++ PulledDeps1]),
     ok.
 
 'delete-deps'(Config, _) ->
     ok.
 
 
-
 %% ===================================================================
 %% Internal functions
 %% ===================================================================
                         [Rev, Url, filename:basename(AppDir)]), [],
                    filename:dirname(AppDir)).
 
+update_source(Dep) ->
+    ?CONSOLE("Updating ~p from ~p\n", [Dep#dep.app, Dep#dep.source]),
+    require_source_engine(Dep#dep.source),
+    update_source(filename:join(get_deps_dir(), Dep#dep.app),
+                  Dep#dep.source),
+    Dep.
+
+update_source(AppDir, {git, _Url, {Type, Refspec}})
+  when Type =:= branch orelse
+       Type =:= tag ->
+    rebar_utils:sh(?FMT("git pull origin ~s", [Refspec]), [], AppDir);
+update_source(AppDir, {git, Url, Refspec}) ->
+    update_source(AppDir, {git, Url, {branch, Refspec}});
+update_source(AppDir, {svn, _Url, Rev}) ->
+    rebar_utils:sh(?FMT("svn up -r ~s", [Rev]), [], AppDir);
+update_source(AppDir, {hg, _Url, Rev}) ->
+    rebar_utils:sh(?FMT("hg pull -u -r ~s", [Rev]), [], AppDir);
+update_source(AppDir, {bzr, _Url, Rev}) ->
+    rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [], AppDir).
+
+
 
 %% ===================================================================
 %% Source helper functions
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.