Skip to content

Commit

Permalink
Merge pull request #122 from paulo-ferraz-oliveira/fix/protocol_for_d…
Browse files Browse the repository at this point in the history
…eps_rebar_ignore

Allow use of rebar_raw_resource in rebar3 -oriented projects
  • Loading branch information
elbrujohalcon authored Aug 7, 2020
2 parents f0ffd9a + 75e284e commit c4b4442
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/elvis_project.erl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ is_rebar_master_dep({_AppName, {_SCM, _Location, "master"}}) ->
true;
is_rebar_master_dep({_AppName, {_SCM, _Location, {branch, "master"}}}) ->
true;
is_rebar_master_dep({AppName, {raw, DepResourceSpecification}}) ->
is_rebar_master_dep({AppName, DepResourceSpecification});
%% Rebar2
is_rebar_master_dep({_AppName, _Vsn, {_SCM, _Location, "master"}}) ->
true;
Expand All @@ -182,6 +184,8 @@ is_rebar_not_git_dep({_AppName, {pkg, _OtherName}}, _Regex) ->
false;
is_rebar_not_git_dep({_AppName, {_SCM, Url, _Branch}}, Regex) ->
nomatch == re:run(Url, Regex, []);
is_rebar_not_git_dep({AppName, {raw, DepResourceSpecification}}, Regex) ->
is_rebar_not_git_dep({AppName, DepResourceSpecification}, Regex);
is_rebar_not_git_dep({_AppName, {_SCM, Url}}, Regex) ->
nomatch == re:run(Url, Regex, []);
is_rebar_not_git_dep({_AppName, _Vsn, {_SCM, Url}}, Regex) ->
Expand Down
4 changes: 3 additions & 1 deletion test/examples/rebar.config.fail
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
{jiffy, "0.*", {git, "[email protected]:davisp/jiffy.git"}},
{ibrowse, "4.*", {git, "https://github.com/cmullaparthi/ibrowse.git", "v4.1.1"}},
{aleppo, "0.*", {git, "https://github.com/inaka/aleppo.git", "master"}},
{jsx, {raw, {git, "[email protected]:talentdeficit.git", {branch, "develop"}}}},

{lager, {git, "git://github.com/basho/lager.git", "2.0.0"}},
{getopt, {git, "[email protected]:jcomellas/getopt.git", {branch, "master"}}},
{meck, {git, "https://github.com/eproxus/meck.git", "0.8.2"}},
{jiffy, {git, "https://github.com/davisp/jiffy.git", "0.11.3"}},
{jiffy, {git, "[email protected]:davisp/jiffy.git"}},
{ibrowse, {git, "https://github.com/cmullaparthi/ibrowse.git", "v4.1.1"}},
{aleppo, {git, "https://github.com/inaka/aleppo.git", "master"}}
{aleppo, {git, "https://github.com/inaka/aleppo.git", "master"}},
{jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "master"}}}}
]
}.
{escript_name, "elvis"}.
Expand Down
3 changes: 2 additions & 1 deletion test/examples/rebar3.config.success
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
{uuid, "1.7.0", {pkg, uuid_erl}},
{meck, "0.8.2", {git, "https://github.com/basho/meck.git", {tag, "0.8.2"}}},
{jiffy, {git, "https://github.com/davisp/jiffy.git"}},
recon
recon,
{jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "develop"}}}}
]}.
25 changes: 14 additions & 11 deletions test/project_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ verify_no_deps_master_rebar(_Config) ->
Filename = "rebar.config.fail",
{ok, File} = elvis_test_utils:find_file(SrcDirs, Filename),

[_, _, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, #{}),
[_, _, _, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, #{}),

RuleConfig = #{ignore => [aleppo]},
[_, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig),
[_, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig),

RuleConfig1 = #{ignore => [aleppo, getopt]},
[] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig1).
[_] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig1),

RuleConfig2 = #{ignore => [jsx]},
[_, _, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig2).


-spec verify_git_for_deps_erlang_mk(config()) -> any().
Expand Down Expand Up @@ -148,15 +151,15 @@ verify_git_for_deps_rebar(_Config) ->
Filename = "rebar.config.fail",
{ok, File} = elvis_test_utils:find_file(SrcDirs, Filename),

[_, _, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, #{}),
[_, _, _, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, #{}),

RuleConfig = #{ignore => [getopt]},
[_, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig),
[_, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig),

RuleConfig1 = #{ignore => [getopt, lager]},
[_, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig1),
[_, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig1),

RuleConfig2 = #{ignore => [meck], regex => "git@.*"},
RuleConfig2 = #{ignore => [meck, jsx], regex => "git@.*"},
[_, _, _, _, _, _, _, _] =
elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig2).

Expand All @@ -168,16 +171,16 @@ verify_protocol_for_deps_rebar(_Config) ->
Filename = "rebar.config.fail",
{ok, File} = elvis_test_utils:find_file(SrcDirs, Filename),

[_, _, _, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, #{}),
[_, _, _, _, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, #{}),

RuleConfig = #{ignore => [getopt]},
RuleConfig = #{ignore => [getopt, jsx]},
[_, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig),

RuleConfig1 = #{ignore => [getopt, lager]},
[_, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig1),
[_, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig1),

RuleConfig2 = #{ignore => [meck], regex => "git@.*"},
[_, _, _, _, _, _, _, _] =
[_, _, _, _, _, _, _, _, _] =
elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig2).

-spec verify_hex_dep_rebar(config()) -> any().
Expand Down

0 comments on commit c4b4442

Please sign in to comment.