-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(dependencies
): support pinning of tags / revs when using .gitmodules
with foundry.lock
#9522
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
base: master
Are you sure you want to change the base?
Conversation
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 makes sense overall, 2 scenarios was thinking of
- update deps of dependencies
forge init
and then install specific tagforge install OpenZeppelin/openzeppelin-contracts@tag=v4.9.4
. This will result in 2 deps inlib/openzeppelin-contracts/lib
:
erc4626-tests
forge-std
forge update
updates dependencies of Oz dependency, resulting in 3 deps
erc4626-tests
forge-std
halmos-cheatcodes
This probably cannot be fixed even when openzeppelin-contracts
contracts will add its own forge-submodule-info.json
?
- updating dependency to a different version
- cd in
lib/openzeppelin-contracts/
andgit checkout v5.0.2
forge update
silently checks outv4.9.4
- in order to persist then
forge-submodule-info.json
should be manually edited and"lib/openzeppelin-contracts":{"Tag":"v4.9.4"}
updated to"lib/openzeppelin-contracts":{"Tag":"v5.0.2"}
Maybe on forge update
we should print out versions (and should follow up with docs / book update).
(1). Yeah, this is because we run (2) Deps can be updated along with the values in |
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.
Some minor nits, implementation and tests I performed all look good
Updated the title
dependencies
): support pinning of tags / revs with .gitmodules
dependencies
): support pinning of tags / revs when using .gitmodules
using foundry.lock
dependencies
): support pinning of tags / revs when using .gitmodules
using foundry.lock
dependencies
): support pinning of tags / revs when using .gitmodules
with foundry.lock
Related book PR: foundry-rs/book#1494 |
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.
left some preliminary comments, could be I am missing some context so looking more into. thanks!
crates/forge/src/lockfile.rs
Outdated
} | ||
|
||
// Find out if rev has a tag associated with it. | ||
let maybe_tag = |
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.
is this a safe assumption? git.tag_for_commit
returns the first tag the commit was included, but that doesn't necessarily mean that tag was done at specified rev? e.g. if abc1234
rev included in v0.1.0
but v0.1.0
tagged at subsequent rev xyz1234
wouldn't then the identified tag point to xyz1234
rev? (and wrongly add dep as DepIdentifier::Tag
instead DepIdentifier::Rev
)
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.
Yeah, this has always been an unsafe assumption. Initially, I started with getting the latest tag for a commit, which is not right, and it can pull a bunch of changes from the lib that the user did not intend.
Defered to getting the earliest tag for a commit, so that the changes (if any) pulled are minimal.
But it is surely a footgun, resolved this by always pinning to a rev in 98223b0
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.
lgtm. @zerosnacks do you want to have another look since things changed?
@zerosnacks conflicts resolved, rfr |
Motivation
Closes #7225
git submodule
doesn't have support for pinning to tags/revisions, onlybranches
in.gitmodules
forge
when updating deps.forge install OpenZeppelin/[email protected]
.git submodule status
shows the oz dep checked out at OpenZeppelin/openzeppelin-contracts@69c8defforge update
Solution
Introduce a basic lockfile
foundry.lock
that consists of a mapping from relativelib_path
toDepIdentifier
.Every time
forge update
is run, this file is inferred to correctly check out the dep and maintaintag
orrev
pinning if specified.In case we want to override a dep and set a new tag, this can be done like so:
forge update owner/dep@new-tag
TODO
foundry.lock
generation the first time.