copier icon indicating copy to clipboard operation
copier copied to clipboard

Add support for initial content

Open JanMalte opened this issue 6 months ago • 2 comments

Actual Situation

Some of our template files just contain dummy content or comments like ToDo markers.

They get replaced by the developers, right after starting the project from the copier template.

To ease their work, the comments and ToDo markers show where and how some things should be done.

As soon as the project gets updated from the copier template, the actual implementation is suggested to be replaced by the dummy content.

Desired Situation

It would be great, if there is some special initial content marker to tell copier changes in this section should be ignored and not beeing updated from the template.

Proposed solution

Maybe a special marker of included jinja extension could help.

JanMalte avatar Jun 11 '25 21:06 JanMalte

Thanks for proposing this enhancement, @JanMalte! 👍 I'm not opposed to the idea, but I don't have a clear idea yet how it could be implemented. Copier's update algorithm is essentially a Git 3-way merge of a fresh project based on the new template version into the project that is based on a fresh project based on the old template version. I imagine we'd need some way to ignore (or undo) changes to some lines when performing the Git merge. The markers would need to be language agnostic – perhaps Jinja comments.

If you're interested in working on a design proposal, I'll be happy to discuss it.

sisp avatar Jun 12 '25 12:06 sisp

Related note: If the whole file is boilerplate, you can already exclude it from updates (see example at https://copier.readthedocs.io/en/stable/configuring/#exclude). Regardless, being able to exclude specific sections from updates inside otherwise managed files would be a welcome feature.

lkubb avatar Jul 10 '25 18:07 lkubb