Skip to content

Commit

Permalink
Merge pull request #343 from inaka/fix/git_subdir-in-protocol_for_dep…
Browse files Browse the repository at this point in the history
…s_rebar

Fix (`function_clause`) to support `git_subdir` in `protocol_for_deps_rebar`
  • Loading branch information
elbrujohalcon authored May 23, 2024
2 parents 1c50c12 + 8571b87 commit 6923a83
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/elvis_project.erl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ is_not_git_dep({_AppName, {_SCM, Url}}, Regex) ->
is_not_git_dep({_AppName, _Vsn, {_SCM, Url}}, Regex) ->
nomatch == re:run(Url, Regex, []);
is_not_git_dep({_AppName, _Vsn, {_SCM, Url, _Branch}}, Regex) ->
nomatch == re:run(Url, Regex, []);
is_not_git_dep({_AppName, {git_subdir, Url, {branch, _Branch}, _SubDir}}, Regex) ->
nomatch == re:run(Url, Regex, []).

%% @private
Expand Down
3 changes: 2 additions & 1 deletion test/examples/rebar.config.fail
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
{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", "main"}},
{jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "main"}}}}
{jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "main"}}}},
{opentelemetry_api, {git_subdir, "http://github.com/open-telemetry/opentelemetry-erlang", {branch, "main"}, "apps/opentelemetry_api"}}
]
}.
{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 @@ -5,5 +5,6 @@
{meck, "0.8.2", {git, "https://github.com/basho/meck.git", {tag, "0.8.2"}}},
{jiffy, {git, "https://github.com/davisp/jiffy.git"}},
recon,
{jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "develop"}}}}
{jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "develop"}}}},
{opentelemetry_api, {git_subdir, "https://github.com/open-telemetry/opentelemetry-erlang", {branch, "main"}, "apps/opentelemetry_api"}}
]}.
16 changes: 12 additions & 4 deletions test/project_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,24 @@ verify_protocol_for_deps(_Config) ->
Filename = "rebar.config.fail",
{ok, File} = elvis_test_utils:find_file(SrcDirs, Filename),

[_, _, _, _, _, _, _] = elvis_project:protocol_for_deps(ElvisConfig, File, #{}),
[#{info := [lager, _]},
#{info := [getopt, _]},
#{info := [jiffy, _]},
#{info := [jsx, _]},
#{info := [lager, _]},
#{info := [getopt, _]},
#{info := [jiffy, _]},
#{info := [opentelemetry_api, _]}] =
elvis_project:protocol_for_deps(ElvisConfig, File, #{}),

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

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

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

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

0 comments on commit 6923a83

Please sign in to comment.