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
Support for .copierignore file similar to .gitignore #1131
Comments
Have you tried the |
Or |
Thank you for pointing out the The main reason for suggesting a separate However, template users might have their own unique requirements for excluding additional files or directories when using the template. These users may not want to modify the This approach ensures that template creators can define default exclusions in |
Makes total sense. However, it seems to me that just dealing with ignore is a bit small-scoped. The same need could happen with any other conf. We should be able to provide user conf. Maybe something like |
Half-duplicate of #235. |
I would like to have support for .gitignore files
I basically (or maybe exacltly) have the same rather long list of ignored files twice. |
@entelecheia I see how this would work for @lhupfeldt I'm not sure I understand the use case behind using @entelecheia @yajo @lhupfeldt We need an agreed design to get actionable, so let me offer a suggestion:
And we might need to offer support for WDYT? |
To me the only time it makes sense to use |
I kinda like the initiative from https://dot-config.github.io/, so I feel more inclined to default to something like this, going from best to worst match:
I also thought about that. However, we're talking about user configs. Thus, I'm not sure we really want to hardcode all this stuff. Different users might need different things. Maybe we can leave that for later if needed. If a user has different templates, it's reasonable to think that all of them (if not most) will require the same default user configs. It's also reasonable IMHO to ask the user to specify a different config if the default one doesn't apply, the same as happens with answer files. So maybe this is something that we simply shouldn't need to care for now.
Config file support and config file management are 2 different things. We should focus on using configs for now, so we narrow the scope and make it simpler. Later, if needed, for config file management, I think it's better to have a specific subcommand
Isn't that the default behavior of copier when you use Lines 198 to 211 in f3639ee
|
I just realized why this conversation seemed very confusing to me. |
👍
I wasn't aware of this initiative, sounds reasonable. It tends to be better to stick to "standards" than invent something custom. 👍
We can use
👍 It should be possible to extend to per-template user configs in a backwards compatible way if/when needed.
I think global configs with config management only make sense when those settings only affect the local environment. Having a global
Ah, you're right. I confused the Lines 303 to 314 in f3639ee
|
@lhupfeldt I also realized that there was some confusion about "template-land" vs. userland config / ignore file. I also misunderstand the OT at first. So just to fully clarify your request: You'd like the |
To be honest I didn't remember that there was a |
Sorry, I don't understand this comment.
Yes, that's how it works currently. See the docs.
If you're talking about the template If you talk about the
Ha! Contradicting myself completely, I just got an idea about how to do this 😁 We can assume that any answers file will contain the word "copier-answers" somewhere in its name. Thus, if a file with the same name, but replacing that with "copier-config' is next to it, use it by default. Easy! Valid examples:
As a final note, we should be careful about what cnfigs are supported there. A malicious template could provide that file with |
I'm glad to hear that you're considering this idea! Your approach of looking for a Much like the |
I don't think the template Otherwise, what you are suggesting sounds good to me, @yajo. But what do you think about the problem that |
Hold on a moment.🤔 Sorry for throwing out so many conflicting thoughts.😁
This would be equivalent to excluding the file on copy, with no configs involved. What should happen? 🧐 According to our update logic, the file deletion should be preserved in updates unless it changes too in the template, in which case you'd be getting a conflict (a perfectly valid one). So, the use case you discovered @sisp could maybe be the only thing important here. That's a bug. If we fix it, we'd be providing an implicit fix for this issue: you don't want some files? Just delete them. You'll only get conflicts in next updates if they evolve too in the template, but that could happen not so often... so as to make this feature request unnecessary? |
My layout is
What I'm proposing is to allow |
Is your feature request related to a problem? Please describe.
I'm finding it cumbersome to handle the exclusion of certain files and directories when using Copier. Currently, there's no built-in support for an ignore file like .gitignore, which makes it difficult to manage a list of files or directories to be skipped during the copying process.
Describe the solution you'd like
I'd like to have a
.copierignore
file that works similarly to a.gitignore
file. This file should allow users to list files and directories that should be excluded from the copying process. Copier should automatically recognize the.copierignore
file and exclude the specified files and directories without the need for additional command line arguments.Describe alternatives you've considered
As a workaround, I have been using a bash script to read a
.copierignore
file and pass the files to Copier as--skip
arguments:However, this solution is not ideal, as it requires extra manual effort and may not be as intuitive for users unfamiliar with bash scripting.
Additional context
Having a built-in solution for ignoring files and directories would streamline the copying process and improve the user experience. This feature would be particularly useful for projects with numerous files or directories that need to be excluded, allowing users to easily manage their exclusion lists.
The text was updated successfully, but these errors were encountered: