@@ -46,8 +46,12 @@ pub fn setup(src_path: &Path, include_name: &str) {
46
46
_ => return ,
47
47
} ;
48
48
49
+ println ! ( ) ;
50
+
49
51
t ! ( install_git_hook_maybe( src_path) ) ;
50
52
53
+ println ! ( ) ;
54
+
51
55
println ! ( "To get started, try one of the following commands:" ) ;
52
56
for cmd in suggestions {
53
57
println ! ( "- `x.py {}`" , cmd) ;
@@ -102,10 +106,10 @@ simply delete the `pre-commit` file from .git/hooks."
102
106
let should_install = loop {
103
107
print ! ( "Would you like to install the git hook?: [y/N] " ) ;
104
108
io:: stdout ( ) . flush ( ) ?;
109
+ input. clear ( ) ;
105
110
io:: stdin ( ) . read_line ( & mut input) ?;
106
111
break match input. trim ( ) . to_lowercase ( ) . as_str ( ) {
107
112
"y" | "yes" => true ,
108
- // is this the right way to check for "entered nothing"?
109
113
"n" | "no" | "" => false ,
110
114
_ => {
111
115
println ! ( "error: unrecognized option '{}'" , input. trim( ) ) ;
@@ -115,14 +119,17 @@ simply delete the `pre-commit` file from .git/hooks."
115
119
} ;
116
120
} ;
117
121
118
- if should_install {
119
- let src = src_path. join ( "/etc/pre-commit.rs" ) ;
120
- let dst = src_path. join ( "/.git/hooks/pre-commit" ) ;
121
- fs:: hard_link ( src, dst) ?;
122
- println ! ( "Linked `src/etc/pre-commit.sh` to `.git/hooks/pre-commit`" ) ;
122
+ Ok ( if should_install {
123
+ let src = src_path. join ( "src" ) . join ( "etc" ) . join ( "pre-commit.sh" ) ;
124
+ let dst = src_path. join ( ".git" ) . join ( "hooks" ) . join ( "pre-commit" ) ;
125
+ match fs:: hard_link ( src, dst) {
126
+ Err ( e) => println ! (
127
+ "x.py encountered an error -- do you already have the git hook installed?\n {}" ,
128
+ e
129
+ ) ,
130
+ Ok ( _) => println ! ( "Linked `src/etc/pre-commit.sh` to `.git/hooks/pre-commit`" ) ,
131
+ } ;
123
132
} else {
124
133
println ! ( "Ok, skipping installation!" ) ;
125
- } ;
126
-
127
- Ok ( ( ) )
134
+ } )
128
135
}
0 commit comments