Skip to content
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

Add the ability to (git) merge files when executing different templates #1738

Open
woile opened this issue Aug 19, 2024 · 0 comments
Open

Add the ability to (git) merge files when executing different templates #1738

woile opened this issue Aug 19, 2024 · 0 comments

Comments

@woile
Copy link

woile commented Aug 19, 2024

Actual Situation

I'm opening this issue as per discussed here: https://github.com/orgs/copier-org/discussions/1485#discussioncomment-10101273

Copier is really nice, because you can have multiple templates and apply them to the same repo, but it has a limitation. When both templates try to modify the same file, the second template overrides the previous one.

Imagine a team maintains 2 templates: python-base and python-app.

  • python-base: creates the pyproject.toml with the name and all the information that is required once.
  • python-app: creates a python module and it needs to update the pyproject.toml, for this example, let's say it needs to add dependencies (it could also need to update the tool.poetry.packages).

Now these 2 templates live in different repositories and both create the file pyproject.toml.

If you run the templates python-base and after the python-app, the end result of pyproject.toml will only be the content of python-app and we lose what was created on python-base.

Desired Situation

When applying the second template, it should be possible to merge the files (maybe with a conflict) instead of just overwriting.

Proposed solution

I'm not entirely sure how it would work. But it would be nice to have the ability to "merge" the same files.
Right now, if copier detects the same file, it asks if it should be overwritten. It would be nice, if there's a third option, called "merge", where it tries to merge the files, similar to git (possibly using the same conflict mechanism, so we can use existing tool to resolve the conflict). Ideally, having a flag to tell copier to merge if it finds conflicts, like --merge-files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant