scm: add config option to stage files automatically#4543
Conversation
|
Thinking more on this I do think it would be much better to fork in |
|
I moved the logic to |
|
Also, I was not sure about handling of If noone has objections to this I'll start looking at adding documentation possibilities soon. Edit: And look at tests. I looked at the tests before this failed now so I think I know what failed and why. |
6dc33d4 to
54f6595
Compare
|
Okay, I added I'm a little lost on how to test EDIT: I'm removing WIP, because the code seems ready for review at least.
|
efiop
left a comment
There was a problem hiding this comment.
Thank you for your patience!
Looks great! 🔥 Just a few minor comments to address.
|
That should cover both points. Would you prefer squashed commits in PRs? I'm used to doing that but usually on my own commits only. |
We'll squash automatically when merging, so it is up to you how to organize this PR internally 🙂 |
|
@bobertlo Btw, we'll need to add this new option to https://dvc.org/doc/command-reference/config . Could you submit a PR for it as well, please? |
|
@pmrowla Could you take a look, please? Wonder if this will affect the experiments feature in some harmful way. |
pmrowla
left a comment
There was a problem hiding this comment.
In general, this LGTM.
Regarding the experiments feature, this shouldn't affect anything as far as I can tell. Currently dvc exp checkout ... will still not stage any files even if core.autostage is enabled, since nothing is added to the scm.files_to_track list by Experiments.checkout(). Given how the experiments feature is supposed to be used, this seems like the correct behavior to me. We can consider making exp checkout support auto-staging at a later date if needed.
|
Thank you @bobertlo ! 🙏 |
Fixes #4330
I'd appreciate feedback on this.
scm_autostagewas arbitrary, but chosen to matchno_scm. I wasn't sure if justautostagewould be too generic or ifgit_autostagemight not be future proof.scm.remind_to_trackcould be renamedscm.handle_changes? I didn't want to go there without feedback. It's named in tests, but not called anywhere else in the codebase outside the context of this patch.scm_context. I thought altering the attribute/behavior in the scm class would be more straight-forward but, after writing out the previous point, maybe a separate maybescm_contextcould read the attribute from the repo class and handle the logic there, calling a separate function if changes are to be staged.❗ I have followed the Contributing to DVC checklist.
📖 If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
config: document new
core.autostagesetting dvc.org#1779Thank you for the contribution - we'll try to review it as soon as possible. 🙏