question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Copy updates as 1st-class citizens

See original GitHub issue

The scaffolding landscape in Python currently is pretty bad, thanks for bringing to life this nice project.

Handling updates is pretty bad still. Imagine:

  1. You have a scaffolding.
  2. You copy it and start a new project.
  3. Your new project evolves in a separate git repo.
  4. You update your scaffolding.
  5. 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.
  6. 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:

  1. When a scaffolding is copied, store all answers in a file. It could be something like .copied.yml.
  2. Store in .copied.yml also the source of the copy (e.g. _copied_from: gh:my/scaffolding).
  3. 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:

  1. Fails if .copied.yml is absent.
  2. Fails if _copied_from is absent in that file.
  3. If _copied_commit is absent, it should be the equivalent of copier $_copied_from ..
  4. If _copied_commit is present, it should be the equivalent of copied --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:

  1. Fails if source is not a git repo.
  2. If present, will generate a patch from --from-commit to --to-commit.
  3. It will only apply that diff.
  4. Does nothing if both flags are equal.

Why all of this?

  1. 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.
  2. 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pykongcommented, Dec 17, 2019

@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/ ?

1reaction
yajocommented, Nov 20, 2019

Cool, I have a PR in the oven ready to improve this. I think tomorrow I’ll have time to push it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found