-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(forge): make recursive forge update
optional via --recursive
flag
#5980
Conversation
forge update
optional via --recursive
flagforge update
optional via --recursive
flag
It looks like this is actually a regression from #2274, which fixed issue #2264. This is due to the test being ignored: foundry/crates/forge/tests/cli/cmd.rs Line 978 in 163cccd
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is reasonable, though I usually tend to use git directly myself.
but I can see how this is very useful in CI etc
I did not test this though.
I admit we've been a bit careless with all the git bindings, all of this just sucks.
I think this is correct that we don't want |
As for @Evalir's comment about being a breaking change – I'm not sure that it is: Recursively updated submodules either update correctly (no recursive updates required) or they're left in a "dirty" state, which git won't/can't commit to the working tree. The current behavior means you need to manually revert the (recursive) updates that left dependencies "dirty" before you can commit the update to the root project (or, if you own the submodule commit and push the changes to the remote). At least, AFAIK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coming back to this! @jameswenzel sorry for the wait. tested and works well—I think for the test it's okay if you make a suitable repo to replace the one that the ignored test uses, and maybe you can then transfer to me? won't delete, so should be OK to use :)
4f2992f
to
0130222
Compare
@Evalir Just pushed an update to the existing ignored test. I initiated a transfer for these two repos; the path will probably have to be updated in the test once you accept ownership: https://github.com/jameswenzel/forge-5980-test The former has a dependency on the latter; the latter has an upstream breaking change, so the test will fail if Forge tries to update submodules recursively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepted the moves & updated!
Motivation
forge update
recursively updates submodules, which causes submodules with out-of-date dependencies to become out-of-sync with their remote. This can lead to non-deterministic builds and a messy git working directory.This PR makes the default behavior only to update root-level dependencies, while still recursively fetching any updated sub-dependencies.
It also adds a
--recursive
flag to mimic the old behavior, if for some reason it is desired.Closes #5926.
Unfortunately, as I'm not familiar with this codebase or Rust generally – I'm not sure the best way to go about testing this. Would appreciate input and guidance.
Solution
recursive
flag toGit::submodule_update
submodule_foreach
toGit
recursive
flag toforge update
recursive
is false, initialize submodules non-recursively, thengit submodule foreach
a recursive, non-remote initialization submodule update