-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: remove forge init template history #4001
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
fix: remove forge init template history #4001
Conversation
cli/src/cmd/forge/init.rs
Outdated
| .output()? | ||
| .stdout; | ||
| let commit_hash = String::from_utf8(git_output)?; | ||
| Command::new("rm").args(["-rf", ".git"]).exec()?; |
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.
| Command::new("rm").args(["-rf", ".git"]).exec()?; | |
| std::fs::remove_dir_all(".git")?; |
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.
Done in b8c05bf
| Command::new("git") | ||
| .args(["clone", "--recursive", &template, &root.display().to_string()]) | ||
| .exec()?; | ||
|
|
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.
don't we also have to "cd" into it (std::env::set_current_dir)?
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.
ah yes it seems root can be set and is not always the current dir, will fix
foundry/cli/src/cmd/forge/init.rs
Line 66 in 7518d37
| let root = root.unwrap_or_else(|| std::env::current_dir().unwrap()); |
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.
should be fixed in 75f918a
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 that .current_dir on the clone command was fine, i meant that when we're deleting the .git folder and initializing, we have to move into in the newly cloned repo directory
sorry didn't see the last reply, ty
Currently, if you
forge init --template <TEMPLATE>it's just an alias togit clonethe template. This means your new forge project is initialized with the template's commit history and the template repo set as the remote.OTOH, when you click the "Use this template" button in the github UI it creates a repo with a single commit from the person who forked it with the message "Initial commit". This behavior is preferable as you don't want the template's commits and authors in your repo history, nor do you want it a a remote.
This PR updates
forge init --template <TEMPLATE>to behave similarly by deleting the git folder and initializing a new repo