diff --git a/cli/src/forge.rs b/cli/src/forge.rs index 3a906b224829..d4390d9343f7 100644 --- a/cli/src/forge.rs +++ b/cli/src/forge.rs @@ -72,7 +72,7 @@ fn main() -> eyre::Result<()> { Subcommands::Update { lib } => { let mut cmd = Command::new("git"); - cmd.args(&["submodule", "update", "--remote", "--init", "--recursive"]); + cmd.args(&["submodule", "update", "--remote", "--init"]); // if a lib is specified, open it if let Some(lib) = lib { diff --git a/cli/tests/it/cmd.rs b/cli/tests/it/cmd.rs index fc6946832839..fd1ef7be8db5 100644 --- a/cli/tests/it/cmd.rs +++ b/cli/tests/it/cmd.rs @@ -807,3 +807,51 @@ forgetest!(can_reinstall_after_manual_remove, |prj: TestProject, mut cmd: TestCo // install again install(&mut cmd); }); + +// Tests that forge update doesn't break a working depencency by recursively updating nested +// dependencies +forgetest!( + can_update_library_with_outdated_nested_dependency, + |prj: TestProject, mut cmd: TestCommand| { + cmd.git_init(); + + let libs = prj.root().join("lib"); + let git_mod = prj.root().join(".git/modules/lib"); + let git_mod_file = prj.root().join(".gitmodules"); + + let package = libs.join("issue-2264-repro"); + let package_mod = git_mod.join("issue-2264-repro"); + + let install = |cmd: &mut TestCommand| { + cmd.forge_fuse().args(["install", "foundry-rs/issue-2264-repro", "--no-commit"]); + cmd.assert_non_empty_stdout(); + assert!(package.exists()); + assert!(package_mod.exists()); + + let submods = read_string(&git_mod_file); + assert!(submods.contains("https://github.com/foundry-rs/issue-2264-repro")); + }; + + install(&mut cmd); + cmd.forge_fuse().args(["update", "lib/issue-2264-repro"]); + cmd.stdout_lossy(); + + prj.inner() + .add_source( + "MyTokenCopy", + r#" +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.6.0; +import "issue-2264-repro/MyToken.sol"; +contract MyTokenCopy is MyToken { +} + "#, + ) + .unwrap(); + + cmd.forge_fuse().args(["build"]); + let output = cmd.stdout_lossy(); + + assert!(output.contains("Compiler run successful",)); + } +);