-
Notifications
You must be signed in to change notification settings - Fork 161
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: Unable to use {basename} in template file-refs #1319
base: main
Are you sure you want to change the base?
fix: Unable to use {basename} in template file-refs #1319
Conversation
nandorholozsnyak
commented
Mar 20, 2022
- {filename} and {basename} have different validation rules for their usage
- fixes Unable to use {basename} in template file-refs #1318
- {filename} and {basename} have different validation rules for their usage
Codecov Report
@@ Coverage Diff @@
## main #1319 +/- ##
============================================
- Coverage 56.64% 56.62% -0.02%
+ Complexity 1154 1153 -1
============================================
Files 99 99
Lines 6128 6128
Branches 1019 1019
============================================
- Hits 3471 3470 -1
Misses 2176 2176
- Partials 481 482 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
- Test for case when {basename} is being used in a template file ref - fixes jbangdev#1318
- Test for Init.resolveBaseName
Can I ask for a review @quintesse @maxandersen ? |
Tests that the name given by the user matches the template
I added an extra test that shows where your code causes problems. That test should already have existed of course but it didn't :-) So it's not that we disagree with what you want to do, it's a very useful feature. But the way templates work is honestly a bit obscure. So right now a template needs at least one of these two things to be true:
Right now JBang does this check for all files in a template, which is not really what you want because it prevents a template author from doing exactly what you want to do. But we still need to make sure that at least one file follows one of these rules! And right now your code only follows the first rule. The code would have to be adapted in such a way that it checks that the first file it encounters that matches those rules is enough. So having:
is correct, but so is:
And in both cases JBang has to check that typing Edit: so to make sure that this is clear: in reality a template should either only contain a single |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment I left on PR
Perhaps the best thing to do would be to do is to split this code into two steps: https://github.com/jbangdev/jbang/blob/main/src/main/java/dev/jbang/cli/Init.java#L67-L76 The first step checks if the correct rules are followed and throws an error when it finds a problem. And then the second step would be the current code without the error checking. |
Wow. Thanks for the input, let me dig deeper and find a good solution for this as soon as I have time. |