From 42ca5ab5a974f4fa99195a6585c75834f158cb3f Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Fri, 17 Dec 2021 16:01:48 -0300 Subject: [PATCH] chore(update_appup): do not force appup render if contents are the same To avoid losing comments and/or manual indentation in appup files that are already up to date, we now check whether the contents have the exact same terms as those we are about to write to an existint .appup file. --- scripts/update_appup.escript | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/update_appup.escript b/scripts/update_appup.escript index 65be8239b..530f15072 100755 --- a/scripts/update_appup.escript +++ b/scripts/update_appup.escript @@ -368,7 +368,12 @@ update_appups(Changes) -> do_update_appup(App, Upgrade, Downgrade, OldUpgrade, OldDowngrade) -> case locate(src, App, ".appup.src") of {ok, AppupFile} -> - render_appfile(AppupFile, Upgrade, Downgrade); + case contains_contents(AppupFile, Upgrade, Downgrade) of + true -> + ok; + false -> + render_appfile(AppupFile, Upgrade, Downgrade) + end; undefined -> case create_stub(App) of {ok, AppupFile} -> @@ -408,6 +413,17 @@ create_stub(App) -> false end. +%% we check whether the destination file already has the contents we +%% want to write to avoid writing and losing indentation and comments. +contains_contents(File, Upgrade, Downgrade) -> + %% the file may contain the VSN variable, so it's a script + case file:script(File, [{'VSN', 'VSN'}]) of + {ok, {_, Upgrade, Downgrade}} -> + true; + _ -> + false + end. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% application and release indexing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%