Copy updates as 1st-class citizens
See original GitHub issueThe scaffolding landscape in Python currently is pretty bad, thanks for bringing to life this nice project.
Handling updates is pretty bad still. Imagine:
- You have a scaffolding.
- You copy it and start a new project.
- Your new project evolves in a separate git repo.
- You update your scaffolding.
- You want to apply your scaffolding to your copied project again, but don’t want the default answers; you want the ones you used last time.
- You don’t want the updates to touch the files that you already touched, unless they’ve been touched also in those lines in the source scaffolding.
cruft
handles this pretty well, as it stores all answers in a json file, which also happens to include the git commit of the source when it was copied, and this allows it to extract the diff since that commit to the latest and apply only that diff to the destination.
How should copier
copy (lol) this behavior?
First, when copying:
- When a scaffolding is copied, store all answers in a file. It could be something like
.copied.yml
. - Store in
.copied.yml
also the source of the copy (e.g._copied_from: gh:my/scaffolding
). - When the scaffolding was a git repo, store also the copied commit. It could be a hidden key in
.copied.yml
(e.g.:_copied_commit: o3ho4ho5hoho2hoh2o
).
Then, support running copier
without arguments, which:
- Fails if
.copied.yml
is absent. - Fails if
_copied_from
is absent in that file. - If
_copied_commit
is absent, it should be the equivalent ofcopier $_copied_from .
. - If
_copied_commit
is present, it should be the equivalent ofcopied --from-commit $_copied_commit --to-commit HEAD $_copied_from .
.
As you probably have guessed, we need to add new flags --from-commit
and --to-commit
(which defaults to HEAD
), which:
- Fails if source is not a git repo.
- If present, will generate a patch from
--from-commit
to--to-commit
. - It will only apply that diff.
- Does nothing if both flags are equal.
Why all of this?
- We need to be able to just execute
copier
in a pre-copied scaffolding and let it get only the diff since it was copied last time. - We need to be able to ensure a project is updated with its scaffolding, i.e. to raise an error in CI when that’s not the case.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Copy a class - Classroom Help - Google Support
Only teachers and co-teachers can copy a class. The teacher who copies the class becomes the primary owner of the copied class.
Read more >First-class Function - MDN Web Docs Glossary
A programming language is said to have First-class functions when functions in that language are treated like any other variable.
Read more >First-class function - Wikipedia
In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. ... The first option...
Read more >Copy all values from fields in one class to another through ...
What I am doing is putting values from class A into CopyA before sending CopyA through a webservice call. Now I would like...
Read more >First Class Citizenship: The Civil Rights Letters of Jackie ...
First Class Citizenship : The Civil Rights Letters of Jackie Robinson [Long, ... Follow authors to get new release updates, plus improved recommendations....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Yajo. The approach seems sane to me. The
--commit
flag as well. I am not yet sure about the `–no-diff`` flag.Maybe put
--no-diff
into a separate PR.Otherwise feel free to go ahead. Thanks for the great work! I really appreciate it.
btw - do you use https://gitter.im/ ?
Cool, I have a PR in the oven ready to improve this. I think tomorrow I’ll have time to push it.