@@ -80,15 +80,10 @@ impl fmt::Display for Profile {
80
80
}
81
81
82
82
pub fn setup ( config : & Config , profile : Option < Profile > ) {
83
- let path = & config. config . clone ( ) . unwrap_or ( PathBuf :: from ( "config.toml" ) ) ;
84
83
let profile = profile. unwrap_or_else ( || t ! ( interactive_path( ) ) ) ;
85
- setup_config_toml ( path, profile, config) ;
86
-
87
84
let stage_path =
88
85
[ "build" , config. build . rustc_target_arg ( ) , "stage1" ] . join ( & MAIN_SEPARATOR . to_string ( ) ) ;
89
86
90
- println ! ( ) ;
91
-
92
87
if !rustup_installed ( ) && profile != Profile :: User {
93
88
eprintln ! ( "`rustup` is not installed; cannot link `stage1` toolchain" ) ;
94
89
} else if stage_dir_exists ( & stage_path[ ..] ) {
@@ -109,8 +104,6 @@ pub fn setup(config: &Config, profile: Option<Profile>) {
109
104
Profile :: User => & [ "dist" , "build" ] ,
110
105
} ;
111
106
112
- println ! ( ) ;
113
-
114
107
t ! ( install_git_hook_maybe( & config) ) ;
115
108
116
109
println ! ( ) ;
@@ -125,10 +118,14 @@ pub fn setup(config: &Config, profile: Option<Profile>) {
125
118
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
126
119
) ;
127
120
}
121
+
122
+ let path = & config. config . clone ( ) . unwrap_or ( PathBuf :: from ( "config.toml" ) ) ;
123
+ setup_config_toml ( path, profile, config) ;
128
124
}
129
125
130
126
fn setup_config_toml ( path : & PathBuf , profile : Profile , config : & Config ) {
131
127
if path. exists ( ) {
128
+ eprintln ! ( ) ;
132
129
eprintln ! (
133
130
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`" ,
134
131
path. display( )
@@ -304,7 +301,18 @@ pub fn interactive_path() -> io::Result<Profile> {
304
301
305
302
// install a git hook to automatically run tidy --bless, if they want
306
303
fn install_git_hook_maybe ( config : & Config ) -> io:: Result < ( ) > {
304
+ let git = t ! ( config. git( ) . args( & [ "rev-parse" , "--git-common-dir" ] ) . output( ) . map( |output| {
305
+ assert!( output. status. success( ) , "failed to run `git`" ) ;
306
+ PathBuf :: from( t!( String :: from_utf8( output. stdout) ) . trim( ) )
307
+ } ) ) ;
308
+ let dst = git. join ( "hooks" ) . join ( "pre-push" ) ;
309
+ if dst. exists ( ) {
310
+ // The git hook has already been set up, or the user already has a custom hook.
311
+ return Ok ( ( ) ) ;
312
+ }
313
+
307
314
let mut input = String :: new ( ) ;
315
+ println ! ( ) ;
308
316
println ! (
309
317
"Rust's CI will automatically fail if it doesn't pass `tidy`, the internal tool for ensuring code quality.
310
318
If you'd like, x.py can install a git hook for you that will automatically run `tidy --bless` before
@@ -330,12 +338,6 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
330
338
331
339
if should_install {
332
340
let src = config. src . join ( "src" ) . join ( "etc" ) . join ( "pre-push.sh" ) ;
333
- let git =
334
- t ! ( config. git( ) . args( & [ "rev-parse" , "--git-common-dir" ] ) . output( ) . map( |output| {
335
- assert!( output. status. success( ) , "failed to run `git`" ) ;
336
- PathBuf :: from( t!( String :: from_utf8( output. stdout) ) . trim( ) )
337
- } ) ) ;
338
- let dst = git. join ( "hooks" ) . join ( "pre-push" ) ;
339
341
match fs:: hard_link ( src, & dst) {
340
342
Err ( e) => eprintln ! (
341
343
"error: could not create hook {}: do you already have the git hook installed?\n {}" ,
0 commit comments