Skip to content

Conversation

@mds1
Copy link
Collaborator

@mds1 mds1 commented Dec 31, 2022

Currently, if you forge init --template <TEMPLATE> it's just an alias to git clone the 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

.output()?
.stdout;
let commit_hash = String::from_utf8(git_output)?;
Command::new("rm").args(["-rf", ".git"]).exec()?;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Command::new("rm").args(["-rf", ".git"]).exec()?;
std::fs::remove_dir_all(".git")?;

Copy link
Collaborator Author

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()?;

Copy link
Member

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)?

Copy link
Collaborator Author

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

let root = root.unwrap_or_else(|| std::env::current_dir().unwrap());

Copy link
Collaborator Author

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

Copy link
Member

@DaniPopes DaniPopes Dec 31, 2022

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

@mattsse mattsse merged commit a44159a into foundry-rs:master Jan 1, 2023
@mattsse mattsse added T-bug Type: bug C-forge Command: forge labels Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-forge Command: forge T-bug Type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants