diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-03-17 21:37:35 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-03-17 21:37:35 -0400 |
commit | cafd62e10185e2fc05490c387484dfdb2b615803 (patch) | |
tree | b7976bbf2671ee8f30d91c669bfeec349116f059 | |
parent | a7d70074ffdbe802655d0cf471ae05b4a3d4f55f (diff) | |
parent | e4bf78a96aa95b612ba0ae29d631018d8a6639d5 (diff) |
Merge pull request #284 from tsloughter/master
update hg username and email match in templates
-rw-r--r-- | src/rebar_templater.erl | 2 | ||||
-rw-r--r-- | test/rebar_new_SUITE.erl | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index 143c28b..75cbb87 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -156,7 +156,7 @@ default_author_and_email() -> %% Ok, try mecurial case rebar_utils:sh("hg showconfig ui.username", [return_on_error]) of {ok, NameEmail} -> - case re:run(NameEmail, [{capture, [1,2], list}]) of + case re:run(NameEmail, "^(.*) <(.*)>$", [{capture, [1,2], list}]) of {match, [Name, Email]} -> {Name, Email}; _ -> diff --git a/test/rebar_new_SUITE.erl b/test/rebar_new_SUITE.erl index e382ae4..3cee6f2 100644 --- a/test/rebar_new_SUITE.erl +++ b/test/rebar_new_SUITE.erl @@ -6,7 +6,7 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). -all() -> [app, app_with_fallbacks]. +all() -> [app_git_user, app_hg_user, app_with_fallbacks]. init_per_testcase(Case, Config0) -> @@ -31,7 +31,7 @@ mock_empty_escript_templates() -> meck:new(rebar_utils, [passthrough]), meck:expect(rebar_utils, escript_foldl, fun(_,_,_) -> {ok, []} end). -app(Config) -> +app_git_user(Config) -> meck:expect(rebar_utils, sh, fun("git config --global user.name", _) -> {ok, "gitname"}; ("git config --global user.email", _) -> {ok, "git@email.com"} end), @@ -73,6 +73,28 @@ app_with_fallbacks(Config) -> {filename:join(["src", Name++"_app.erl"]), [Name]} ]). +app_hg_user(Config) -> + meck:expect(rebar_utils, sh, fun("hg showconfig ui.username", _) -> {ok, "hgname <hg@email.com>"}; + (_, _) -> {error, fallback} + end), + + Name = ?config(name, Config), + rebar_test_utils:run_and_check( + Config, [], + ["new", "test_app", Name], + {ok, []} + ), + validate_files( + Config, Name, + [{"LICENSE", ["hgname", "hg@email.com"]}, + {"README.md", [Name]}, + {".gitignore", []}, + {"rebar.config", []}, + {filename:join(["src", Name++".app.src"]), [Name]}, + {filename:join(["src", Name++"_sup.erl"]), [Name]}, + {filename:join(["src", Name++"_app.erl"]), [Name]} + ]). + validate_files(_Config, Name, Checks) -> [begin Path = filename:join([Name, File]), |