-
-
Notifications
You must be signed in to change notification settings - Fork 188
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: Fix issue with update subdirectory given an answers file path #452
fix: Fix issue with update subdirectory given an answers file path #452
Conversation
…given, add unit test
This one doesn't seem to fix the linked issue. Keep in mind that the subdirectory option belongs to the template, and indicates what subdirectory of the template should I render in The expected fix is to allow updates in destination when destination is inside a git repo, no matter if it's the root of the repo or not. |
Codecov Report
@@ Coverage Diff @@
## master #452 +/- ##
==========================================
+ Coverage 96.32% 96.36% +0.04%
==========================================
Files 39 39
Lines 2473 2504 +31
==========================================
+ Hits 2382 2413 +31
Misses 91 91
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Thank you for the clarifications. I am still trying to understand the various use cases and what we can do in the code to meet them. I see two use cases:
I think we should support both use cases. Otherwise, how would the user know which is the correct usage?
I think you are correct. The issue (subdirectory use case 1) that I linked in this PR may be the wrong issue for the changes I made. I meant my changes to fix subdirectory use case 2. For subdirectory use case 2 Potential action items
I am open to suggestions on how to improve the changes in this PR, to still fix subdirectory use case 2. What changes do you want me to make, so that it better aligns with the copier design and code? Thank you. |
Just forget about this use case. Once you fix case 1, this will work automatically with:
We can't guess where the subfolder is because a single project can have more than 1 subfolders that each one use different templates. The copier-answers path provided with |
Thanks. Are you saying that subdirectory use case 2 should not be supported? I think it could be supported with this PR change that I have made. The user can provide enough information in the -a argument so that the path down to the answers file is not ambiguous. The -a argument can contain the relative path folders down to the answer file from the destination path, as I have shown in the unit test. If this is still not acceptable, then can we make copier return a better error for this case? Something like: |
I am currently working on the subdirectory use case 1 and will post a separate PR for it. |
Yes, case 2 is conceptually wrong, because -a is not meant to explain where the root of your project is. Instead it just tells where to find the answers, and those could perfectly exist in a subdirectory. The thing that tells the project root is If your project has several subsections that apply templates, you should indicate that in dst_path. If a subsection uses more than 1 template, then you'll need different -a inside that subsection.
Ok, closing this one as explained. Thanks! |
Fixes #451
Justification
During update, the destination _subdirectory is joined with the rendered answers_file value. We want to avoid including the same folders twice in the path.
Implementation
Write the answers filename to the config, but without the path.
Testing
Added unit test for this case.