Browse Source

Merge pull request #2232 from ferd/tsloughter-lock-file-writes

only write lock file if locks have changed
pull/2237/head
Fred Hebert 5 years ago
committed by GitHub
parent
commit
c0d016dddd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions
  1. +16
    -0
      src/rebar_config.erl
  2. +1
    -1
      src/rebar_prv_lock.erl

+ 16
- 0
src/rebar_config.erl View File

@ -31,6 +31,7 @@
,consult_app_file/1 ,consult_app_file/1
,consult_file/1 ,consult_file/1
,consult_lock_file/1 ,consult_lock_file/1
,maybe_write_lock_file/3
,write_lock_file/2 ,write_lock_file/2
,verify_config_format/1 ,verify_config_format/1
,format_error/1 ,format_error/1
@ -110,6 +111,21 @@ warn_vsn_once() ->
"upgrade Rebar3.", []) "upgrade Rebar3.", [])
end. end.
%% Only call `write_lock_file/2' if the locks have changed.
maybe_write_lock_file(LockFile, Locks, OldLocks) when Locks =/= OldLocks ->
write_lock_file(LockFile, Locks);
maybe_write_lock_file(LockFile, Locks, Locks) ->
%% rewrite if the configured format would have changed
Terms = consult_file_(LockFile),
case Terms of
[] ->
ok;
[{?CONFIG_VERSION, FileLocks}|_] when is_list(FileLocks) ->
ok;
_ ->
write_lock_file(LockFile, Locks)
end.
%% @doc Converts the internal format for locks into the multi-version %% @doc Converts the internal format for locks into the multi-version
%% compatible one used within rebar3 lock files. %% compatible one used within rebar3 lock files.
%% @end %% @end

+ 1
- 1
src/rebar_prv_lock.erl View File

@ -35,7 +35,7 @@ do(State) ->
OldLocks = rebar_state:get(State, {locks, default}, []), OldLocks = rebar_state:get(State, {locks, default}, []),
Locks = lists:keysort(1, build_locks(State)), Locks = lists:keysort(1, build_locks(State)),
Dir = rebar_state:dir(State), Dir = rebar_state:dir(State),
rebar_config:write_lock_file(filename:join(Dir, ?LOCK_FILE), Locks),
rebar_config:maybe_write_lock_file(filename:join(Dir, ?LOCK_FILE), Locks, OldLocks),
State1 = rebar_state:set(State, {locks, default}, Locks), State1 = rebar_state:set(State, {locks, default}, Locks),
OldLockNames = [element(1,L) || L <- OldLocks], OldLockNames = [element(1,L) || L <- OldLocks],

Loading…
Cancel
Save