foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.34k stars 1.77k forks source link

`forge update` on repos with forge deps does a recursive update #4222

Open holic opened 1 year ago

holic commented 1 year ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

forge 0.2.0 (3a15fe9 2023-01-29T00:06:04.108254Z)

What command(s) is the bug in?

forge update

Operating System

macOS (Apple Silicon)

Describe the bug

Running forge update on a particular dependency seems to do a recursive update of all of its forge dependencies (git submodules), which keeps me from being able to commit the update/changes for the dep I wanted to update.

I would expect forge update to bump the dependency version to the latest, and then follow the checked-in submodule git hashes to update its dependencies (rather than also bumping those to the latest).

To resolve this, I have to manually go in and check out each dependency's dependency to the submodule hash checked into the dependency's repo.

ethfs/packages/contracts % git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

ethfs/packages/contracts % forge update lib/forge-std

ethfs/packages/contracts % git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
    modified:   lib/forge-std (new commits, modified content)

no changes added to commit (use "git add" and/or "git commit -a")

ethfs/packages/contracts % git add .

ethfs/packages/contracts % git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    modified:   lib/forge-std

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
    modified:   lib/forge-std (modified content)

ethfs/packages/contracts % cd lib/forge-std

contracts/lib/forge-std % git status
HEAD detached at 4a79aca
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   lib/ds-test (new commits)

no changes added to commit (use "git add" and/or "git commit -a")

See also #2618

meetmangukiya commented 1 year ago

Might look into fixing this, very annoying

Evalir commented 1 year ago

@meetmangukiya lmk if you want me to assign it to you!

0xfoobar commented 1 year ago

Any solutions?

meetmangukiya commented 1 year ago

Last I checked forge update was actually updating the submodules to the correct commits and not checking out the latest master on each submodule. But its just git showing and needing you to add them anyway. --recursive --checkout is the correct way afaict.

gakonst commented 1 year ago

@meetmangukiya still planning on taking this on? agree it's a bit annoying rn..else we're happy to own if it's a serious blocker for people

meetmangukiya commented 1 year ago

Check my previous comment. I didn't find a solution.

hcheng826 commented 1 month ago

same issue here