Skip to content
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

Added branch functionality to forge init command #5742

Merged
merged 4 commits into from
Aug 29, 2023

Conversation

janbro
Copy link
Contributor

@janbro janbro commented Aug 29, 2023

Motivation

Implements feature #5687 which allows a branch argument to be passed when initializing a forge repository from a template. Adds an additional argument branch which requires the template argument to exist.

Solution

forge init --template foundry-rs/forge-template --branch [branch_name]

@janbro
Copy link
Contributor Author

janbro commented Aug 29, 2023

In implementing this, I believe I uncovered a bug with how the template command logic resets the git history. The following code does not remove the .git directory from the correct root folder and operates on the CWD. Let me know if this context issue should be addressed in this PR or another issue should be opened.

p_println!(!quiet => "Initializing {} from {}...", root.display(), template);
Git::clone(shallow, &template, Some(&root))?;
// Modify the git history.
let commit_hash = git.commit_hash(true)?;
std::fs::remove_dir_all(".git")?;
git.init()?;
git.add(Some("--all"))?;
let commit_msg = format!("chore: init from {template} at {commit_hash}");
git.commit(&commit_msg)?;

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! we can tackle what you found in another PR, thank you!

@Evalir Evalir merged commit 1dd5410 into foundry-rs:master Aug 29, 2023
16 checks passed
mikelodder7 pushed a commit to LIT-Protocol/foundry that referenced this pull request Sep 12, 2023
* Added branch functionality to forge init command

* fmt

* clippy

* clippy

---------

Co-authored-by: Alejandro Muñoz-McDonald <alejandro@immunefi.com>
Co-authored-by: Enrique Ortiz <hi@enriqueortiz.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants