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

case_clause in dep_autopatch_rebar.erl when transforming git_subdir #1004

Open
rlipscombe opened this issue Sep 25, 2024 · 4 comments · May be fixed by #1005
Open

case_clause in dep_autopatch_rebar.erl when transforming git_subdir #1004

rlipscombe opened this issue Sep 25, 2024 · 4 comments · May be fixed by #1005

Comments

@rlipscombe
Copy link
Contributor

Rebar 3.14 added git_subdir to its supported dependency formats. See https://rebar3.org/docs/configuration/dependencies/. These have 4 elements. This causes dep_autopatch_rebar.erl to fail with the following error:

Runtime terminating during boot ({{case_clause,{git_subdir,"https://github.com/whatsapp/eqwalizer.git",{branch,"main"},"eqwalizer_support"}},...

rebar.config references eqWAlizer, following the instructions here: https://github.com/whatsapp/eqwalizer?tab=readme-ov-file#using-it-with-rebar3-projects

In the case of eqwalizer, because it's only used at build-time, I can probably work around this with a rebar profile that erlang.mk will ignore. But with other git_subdir dependencies, such as opentelemetry-erlang, this won't be feasible.

@essen
Copy link
Member

essen commented Sep 25, 2024

It should be straightforward to add support for git_subdir as we already have git-subfolder as a dependency fetch method. Would only need minor refactoring on top, if you want to do it. The action is here: https://github.com/ninenines/erlang.mk/blob/master/core/deps.mk#L463-L471

@essen
Copy link
Member

essen commented Sep 25, 2024

Probably best to add a clause immediately above https://github.com/ninenines/erlang.mk/blob/master/core/deps.mk#L462 that matches on git_subdir and does the corresponding write.

@rlipscombe
Copy link
Contributor Author

rlipscombe commented Sep 25, 2024

This is against erlang.mk, rather than deps.mk (I'll do it properly later), but you're thinking something like this...?

@@ -3988,6 +3988,12 @@ define dep_autopatch_rebar.erl
 			GetHexVsn3Common(N, NP, S0);
 		(N, NP, S) -> {N, {hex, NP, S}}
 	end,
+	ConvertCommit = fun
+		({branch, C}) -> C;
+		({ref, C}) -> C;
+		({tag, C}) -> C;
+		(C) -> C
+	end,
 	fun() ->
 		File = case lists:keyfind(deps, 1, Conf) of
 			false -> [];
@@ -4003,16 +4009,15 @@ define dep_autopatch_rebar.erl
 							_ -> false
 						end of
 					false -> ok;
+					{Name, {git_subdir, Repo, Commit, SubDir}} ->
+						Write(io_lib:format("DEPS += ~s\ndep_~s = git-subfolder ~s ~s ~s~n", [Name, Name, Repo, ConvertCommit(Commit), SubDir]));
 					{Name, Source} ->
 						{Method, Repo, Commit} = case Source of
 							{hex, NPV, V} -> {hex, V, NPV};
 							{git, R} -> {git, R, master};
-							{M, R, {branch, C}} -> {M, R, C};
-							{M, R, {ref, C}} -> {M, R, C};
-							{M, R, {tag, C}} -> {M, R, C};
 							{M, R, C} -> {M, R, C}
 						end,
-						Write(io_lib:format("DEPS += ~s\ndep_~s = ~s ~s ~s~n", [Name, Name, Method, Repo, Commit]))
+						Write(io_lib:format("DEPS += ~s\ndep_~s = ~s ~s ~s~n", [Name, Name, Method, Repo, ConvertCommit(Commit)]))
 				end end || Dep <- Deps]
 		end
 	end(),

@essen
Copy link
Member

essen commented Sep 25, 2024

Yes something like this.

rlipscombe added a commit to rlipscombe/erlang.mk that referenced this issue Sep 25, 2024
@rlipscombe rlipscombe linked a pull request Sep 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants