Skip to content

Commit 9738e1f

Browse files
committed
bootstrap/setup: create hooks directory if non-existing
1 parent 62270fb commit 9738e1f

File tree

1 file changed

+7
-1
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+7
-1
lines changed

src/bootstrap/src/core/build_steps/setup.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ fn install_git_hook_maybe(config: &Config) -> io::Result<()> {
469469
assert!(output.status.success(), "failed to run `git`");
470470
PathBuf::from(t!(String::from_utf8(output.stdout)).trim())
471471
}));
472-
let dst = git.join("hooks").join("pre-push");
472+
let hooks_dir = git.join("hooks");
473+
let create_hooks_dir = !hooks_dir.exists();
474+
let dst = hooks_dir.join("pre-push");
473475
if dst.exists() {
474476
// The git hook has already been set up, or the user already has a custom hook.
475477
return Ok(());
@@ -486,6 +488,10 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
486488
println!("Ok, skipping installation!");
487489
return Ok(());
488490
}
491+
if create_hooks_dir {
492+
// We need to (try to) create the hooks directory first.
493+
let _ = fs::create_dir(hooks_dir);
494+
}
489495
let src = config.src.join("src").join("etc").join("pre-push.sh");
490496
match fs::hard_link(src, &dst) {
491497
Err(e) => {

0 commit comments

Comments
 (0)