diff options
-rw-r--r-- | src/rebar.erl | 3 | ||||
-rw-r--r-- | src/rebar_core.erl | 3 | ||||
-rw-r--r-- | src/rebar_utils.erl | 11 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/rebar.erl b/src/rebar.erl index 7ce409c..b7d977f 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -96,6 +96,9 @@ run_aux(Commands) -> %% Initialize logging system rebar_log:init(), + %% Initialize vsn cache + _VsnCacheTab = ets:new(rebar_vsn_cache,[named_table, public]), + %% Convert command strings to atoms CommandAtoms = [list_to_atom(C) || C <- Commands], diff --git a/src/rebar_core.erl b/src/rebar_core.erl index ceb3d3c..63e6d50 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -90,6 +90,9 @@ process_commands([Command | Rest], ParentConfig) -> _ -> ok end, + %% Wipe out vsn cache to avoid invalid hits when + %% dependencies are updated + ets:delete_all_objects(rebar_vsn_cache), process_commands(Rest, ParentConfig). diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 72e6efa..afb8c00 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -189,6 +189,17 @@ expand_env_variable(InStr, VarName, RawVarValue) -> end. vcs_vsn(Vcs, Dir) -> + Key = {Vcs, Dir}, + case ets:lookup(rebar_vsn_cache, Key) of + [{Key, VsnString}] -> + VsnString; + [] -> + VsnString = vcs_vsn_1(Vcs, Dir), + ets:insert(rebar_vsn_cache, {Key, VsnString}), + VsnString + end. + +vcs_vsn_1(Vcs, Dir) -> case vcs_vsn_cmd(Vcs) of {unknown, VsnString} -> ?DEBUG("vcs_vsn: Unknown VCS atom in vsn field: ~p\n", [Vcs]), |