Commit fb30270
authored
Rollup merge of rust-lang#117524 - unleashed:bootstrap-create-hooks-dir, r=Mark-Simulacrum
bootstrap/setup: create hooks directory if non-existing
When running `./x setup` on a local repository I chose to install a `pre-push` git hook, but this happened:
```shell
Would you like to install the git hook?: [y/N] y
error: could not create hook .git/hooks/pre-push: do you already have the git hook installed?
No such file or directory (os error 2)
thread 'main' panicked at src/core/build_steps/setup.rs:462:9:
install_git_hook_maybe(&config) failed with No such file or directory (os error 2)
```
This was caused because the `.git/hooks` directory did not exist in my local repository. Creating it manually and re-running the command works fine.
This PR tests for the above directory and if it does not exist then it _tries_ to create it before hard linking the pre-push hook - we use `fs::create_dir()` and disregard the result (ie. it could fail if the directory was created in the meantime) and proceed to call `fs::hard_link()` all the same.1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
| 473 | + | |
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
| |||
486 | 487 | | |
487 | 488 | | |
488 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
489 | 494 | | |
490 | 495 | | |
491 | 496 | | |
| |||
0 commit comments