From 71df9bf1411c04e2f7dae7e9f0352180664b9365 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 10 Jun 2016 08:43:13 -0400 Subject: Only display old version warning once This uses the env variable as a global store for variables. It's not the cleanest thing, but it sounded nicer than pdicts. --- src/rebar_config.erl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 828c45d..9e13d46 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -58,6 +58,9 @@ consult_lock_file(File) -> [Locks] when is_list(Locks) -> % beta lock file read_attrs(beta, Locks, []); [{Vsn, Locks}|Attrs] when is_list(Locks) -> % versioned lock file + %% Because this is the first version of rebar3 to introduce a lock + %% file, all versionned lock files with a different versions have + %% to be newer. case Vsn of ?CONFIG_VERSION -> ok; @@ -65,14 +68,24 @@ consult_lock_file(File) -> %% Make sure the warning below is to be shown whenever a version %% newer than the current one is being used, as we can't parse %% all the contents of the lock file properly. - ?WARN("Rebar3 detected a lock file from a newer version. " - "It will be loaded in compatibility mode, but important " - "information may be missing or lost. It is recommended to " - "upgrade Rebar3.", []) + warn_vsn_once() end, read_attrs(Vsn, Locks, Attrs) end. +warn_vsn_once() -> + Warn = application:get_env(rebar, warn_config_vsn) =/= {ok, false}, + application:set_env(rebar, warn_config_vsn, false), + case Warn of + false -> ok; + true -> + ?WARN("Rebar3 detected a lock file from a newer version. " + "It will be loaded in compatibility mode, but important " + "information may be missing or lost. It is recommended to " + "upgrade Rebar3.", []) + end. + + write_lock_file(LockFile, Locks) -> {NewLocks, Attrs} = write_attrs(Locks), %% Write locks in the beta format, at least until it's been long -- cgit v1.1