Skip to content

Commit

Permalink
remove --recursive flag from git submodule call in forge update (#2274)
Browse files Browse the repository at this point in the history
* Add test that reproduces the issue with recursive updates

* remove --recursive flag from git submodule call in forge update

* Run rust-fmt

* test: use upstream foundry repro

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
  • Loading branch information
ckoopmann and gakonst authored Jul 12, 2022
1 parent b02dcd2 commit 2e42b71
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/src/forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
48 changes: 48 additions & 0 deletions cli/tests/it/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",));
}
);

0 comments on commit 2e42b71

Please sign in to comment.