Skip to content

Commit

Permalink
bootstrap/setup: create hooks directory if non-existing
Browse files Browse the repository at this point in the history
  • Loading branch information
unleashed committed Nov 2, 2023
1 parent 62270fb commit 9738e1f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ fn install_git_hook_maybe(config: &Config) -> io::Result<()> {
assert!(output.status.success(), "failed to run `git`");
PathBuf::from(t!(String::from_utf8(output.stdout)).trim())
}));
let dst = git.join("hooks").join("pre-push");
let hooks_dir = git.join("hooks");
let create_hooks_dir = !hooks_dir.exists();
let dst = hooks_dir.join("pre-push");
if dst.exists() {
// The git hook has already been set up, or the user already has a custom hook.
return Ok(());
Expand All @@ -486,6 +488,10 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
println!("Ok, skipping installation!");
return Ok(());
}
if create_hooks_dir {
// We need to (try to) create the hooks directory first.
let _ = fs::create_dir(hooks_dir);
}
let src = config.src.join("src").join("etc").join("pre-push.sh");
match fs::hard_link(src, &dst) {
Err(e) => {
Expand Down

0 comments on commit 9738e1f

Please sign in to comment.