Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ pub fn init() -> Result<()> {
bail!(RUSTLINGS_DIR_ALREADY_EXISTS_ERR);
}

let is_inside_git_repository = Command::new("git")
.arg("rev-parse")
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
// in case of error, assume not in Git repository
.is_ok_and(|status| status.success());

let locate_project_output = Command::new("cargo")
.arg("locate-project")
.arg("-q")
Expand Down Expand Up @@ -58,7 +67,7 @@ pub fn init() -> Result<()> {
}

let mut stdout = io::stdout().lock();
let mut init_git = true;
let mut init_git = !is_inside_git_repository;

if locate_project_output.status.success() {
if Path::new("exercises").exists() && Path::new("solutions").exists() {
Expand Down
Loading