diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_dialyzer.erl | 6 | ||||
-rw-r--r-- | src/rebar_templater.erl | 31 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 9d2c10a..cc53632 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -160,6 +160,8 @@ get_plt_files([AppName | DepApps], Apps, PltApps, Files) -> get_plt_files(DepApps, Apps, PltApps, Files); false -> {DepApps2, Files2} = app_name_to_info(AppName), + ?DEBUG("~s dependencies: ~p", [AppName, DepApps2]), + ?DEBUG("~s files: ~p", [AppName, Files2]), DepApps3 = DepApps2 ++ DepApps, Files3 = Files2 ++ Files, get_plt_files(DepApps3, Apps, [AppName | PltApps], Files3) @@ -208,6 +210,7 @@ search_ebin(AppName) -> ebin_to_info(EbinDir, AppName) -> AppFile = filename:join(EbinDir, atom_to_list(AppName) ++ ".app"), + ?DEBUG("Consulting app file ~p", [AppFile]), case file:consult(AppFile) of {ok, [{application, AppName, AppDetails}]} -> DepApps = proplists:get_value(applications, AppDetails, []), @@ -264,7 +267,6 @@ check_plt(State, Plt, OldList, FilesList) -> {CheckWarnings, State2} = check_plt(State1, Plt, sets:to_list(Check)), Add = sets:subtract(Files, Old), {AddWarnings, State3} = add_plt(State2, Plt, sets:to_list(Add)), - ?DEBUG("~p", [[RemWarnings, CheckWarnings, AddWarnings]]), {RemWarnings + CheckWarnings + AddWarnings, State3}. remove_plt(State, _Plt, []) -> @@ -383,6 +385,7 @@ run_dialyzer(State, Opts) -> Opts2 = [{warnings, WarningsList}, {check_plt, false} | Opts], + ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]), {Unknowns, Warnings} = format_warnings(dialyzer:run(Opts2)), _ = [?CONSOLE("~s", [Unknown]) || Unknown <- Unknowns], _ = [?CONSOLE("~s", [Warning]) || Warning <- Warnings], @@ -391,6 +394,7 @@ run_dialyzer(State, Opts) -> Opts2 = [{warnings, no_warnings()}, {check_plt, false} | Opts], + ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]), _ = dialyzer:run(Opts2), {0, State} end. diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index edfe3bd..588f5b2 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -132,14 +132,41 @@ override_vars([{Var, Default, Doc} | Rest], General) -> %% Default variables, generated dynamically. default_variables() -> + {DefaultAuthor, DefaultEmail} = default_author_and_email(), {{Y,M,D},{H,Min,S}} = calendar:universal_time(), [{date, lists:flatten(io_lib:format("~4..0w-~2..0w-~2..0w",[Y,M,D]))}, {datetime, lists:flatten(io_lib:format("~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w+00:00",[Y,M,D,H,Min,S]))}, - {author_name, "Anonymous"}, - {author_email, "anonymous@example.org"}, + {author_name, DefaultAuthor}, + {author_email, DefaultEmail}, {copyright_year, integer_to_list(Y)}, {apps_dir, "apps", "Directory where applications will be created if needed"}]. +default_author_and_email() -> + %% See if we can get a git user and email to use as defaults + case rebar_utils:sh("git config --global user.name", []) of + {ok, Name} -> + case rebar_utils:sh("git config --global user.email", []) of + {ok, Email} -> + {string:strip(Name, both, $\n), string:strip(Email, both, $\n)}; + {error, _} -> + %% Use neither if one doesn't exist + {"Anonymous", "anonymous@example.org"} + end; + {error, _} -> + %% Ok, try mecurial + case rebar_utils:sh("hg showconfig ui.username", []) of + {ok, NameEmail} -> + case re:run(NameEmail, [{capture, [1,2], list}]) of + {match, [Name, Email]} -> + {Name, Email}; + _ -> + {"Anonymous", "anonymous@example.org"} + end; + {error, _} -> + {"Anonymous", "anonymous@example.org"} + end + end. + %% Load variable definitions from the 'Globals' file in the home template %% directory global_variables(State) -> |