mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Make changes based on @jyn514's comments
This commit is contained in:
+16
-9
@@ -46,8 +46,12 @@ pub fn setup(src_path: &Path, include_name: &str) {
|
||||
_ => return,
|
||||
};
|
||||
|
||||
println!();
|
||||
|
||||
t!(install_git_hook_maybe(src_path));
|
||||
|
||||
println!();
|
||||
|
||||
println!("To get started, try one of the following commands:");
|
||||
for cmd in suggestions {
|
||||
println!("- `x.py {}`", cmd);
|
||||
@@ -102,10 +106,10 @@ fn install_git_hook_maybe(src_path: &Path) -> io::Result<()> {
|
||||
let should_install = loop {
|
||||
print!("Would you like to install the git hook?: [y/N] ");
|
||||
io::stdout().flush()?;
|
||||
input.clear();
|
||||
io::stdin().read_line(&mut input)?;
|
||||
break match input.trim().to_lowercase().as_str() {
|
||||
"y" | "yes" => true,
|
||||
// is this the right way to check for "entered nothing"?
|
||||
"n" | "no" | "" => false,
|
||||
_ => {
|
||||
println!("error: unrecognized option '{}'", input.trim());
|
||||
@@ -115,14 +119,17 @@ fn install_git_hook_maybe(src_path: &Path) -> io::Result<()> {
|
||||
};
|
||||
};
|
||||
|
||||
if should_install {
|
||||
let src = src_path.join("/etc/pre-commit.rs");
|
||||
let dst = src_path.join("/.git/hooks/pre-commit");
|
||||
fs::hard_link(src, dst)?;
|
||||
println!("Linked `src/etc/pre-commit.sh` to `.git/hooks/pre-commit`");
|
||||
Ok(if should_install {
|
||||
let src = src_path.join("src").join("etc").join("pre-commit.sh");
|
||||
let dst = src_path.join(".git").join("hooks").join("pre-commit");
|
||||
match fs::hard_link(src, dst) {
|
||||
Err(e) => println!(
|
||||
"x.py encountered an error -- do you already have the git hook installed?\n{}",
|
||||
e
|
||||
),
|
||||
Ok(_) => println!("Linked `src/etc/pre-commit.sh` to `.git/hooks/pre-commit`"),
|
||||
};
|
||||
} else {
|
||||
println!("Ok, skipping installation!");
|
||||
};
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user