mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-28 06:49:19 +00:00
Merge 7187ad66794371fd70da7abcd3444bc235187a35 into b5d440fdc3a1fadad6dc6196dad2acddabdc671f
This commit is contained in:
commit
1ea80ae297
11
src/init.rs
11
src/init.rs
@ -28,6 +28,15 @@ pub fn init() -> Result<()> {
|
|||||||
bail!(RUSTLINGS_DIR_ALREADY_EXISTS_ERR);
|
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")
|
let locate_project_output = Command::new("cargo")
|
||||||
.arg("locate-project")
|
.arg("locate-project")
|
||||||
.arg("-q")
|
.arg("-q")
|
||||||
@ -58,7 +67,7 @@ pub fn init() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut stdout = io::stdout().lock();
|
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 locate_project_output.status.success() {
|
||||||
if Path::new("exercises").exists() && Path::new("solutions").exists() {
|
if Path::new("exercises").exists() && Path::new("solutions").exists() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user