ninenines / erlang.mk

A build tool for Erlang that just works.
https://erlang.mk
ISC License
578 stars 241 forks source link

DTL templating fails when path contains percent character #957

Open artman41 opened 2 years ago

artman41 commented 2 years ago

Unsure whether this is an issue that you can fix through some path hacks @essen or whether you want to close this as a known issue

If your DTL template path contains a percentage character (%) then the path substitution doesn't work.

I encountered this because Jenkins was substituting %2F in place of a slash / in my git branch name.

Issue seems to be the path substitution at https://github.com/ninenines/erlang.mk/blob/bf7a194b0b473186d14193eefdab9b65fa927443/plugins/erlydtl.mk#L24

Jenkins logs with some debug $(info ...)s thrown into erlang.mk show the following info

DTL_PATH is /jenkins/thughes%2Fmybranch/myapp/templates
DTL_FILES is /jenkins/thughes%2Fmybranch/myapp/templates/status_page.dtl
zxz Make version: 13.82
zxz DTL_FILES w/ extension removed:: /jenkins/thughes%2Fmybranch/myapp/templates/status_page.dtl
zxz DTL_FILES suffixed:: /jenkins/thughes%2Fmybranch/myapp/templates/status_page.dtl_dtl
zxz DTL_FILES prefixed:: /jenkins/thughes%2mybranch/myapp/templates/status_page.dtl_dtl
DTL_NAMES is /jenkins/thughes%2Fmybranch/myapp/templates/status_page.dtl_dtl
DTL_MODULES is status_page.dtl_dtl

This causes the eunits to fail as they attempt to load status_page.dtl_dtl.beam which doesn't exist

 GEN    eunit
======================== EUnit ========================
...
undefined
*** test module not found ***
**'status_page.dtl_dtl'
essen commented 2 years ago

Right, makes sense. The % in the path can probably just be escape with \ via $(subst %,\%,$(DTL_PATH)) at the end of the line instead of $(DTL_PATH). But it's worth having a test to confirm.