Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (function_clause) to support git_subdir in protocol_for_deps_rebar #343

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"}}
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
]
}.
{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"}}
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
]}.
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, _]}] =
Comment on lines +63 to +70
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more exhaustive in this initial pattern match so that we can easily spot where the expected issue is. Otherwise it'd be [_, _, _, _, _, _, _, _] 😄

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