@@ -155,24 +155,25 @@ impl Build {
155
155
if fs:: metadata ( self . src . join ( ".git" ) ) . is_err ( ) {
156
156
return
157
157
}
158
- let out = output ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "status" ) ) ;
158
+ let git_submodule = || {
159
+ let mut cmd = Command :: new ( "git" ) ;
160
+ cmd. current_dir ( & self . src ) . arg ( "submodule" ) ;
161
+ return cmd
162
+ } ;
163
+ let out = output ( git_submodule ( ) . arg ( "status" ) ) ;
159
164
if !out. lines ( ) . any ( |l| l. starts_with ( "+" ) || l. starts_with ( "-" ) ) {
160
165
return
161
166
}
162
167
163
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "sync" ) ) ;
164
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "init" ) ) ;
165
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "update" ) ) ;
166
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "update" )
167
- . arg ( "--recursive" ) ) ;
168
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "status" )
169
- . arg ( "--recursive" ) ) ;
170
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "foreach" )
171
- . arg ( "--recursive" )
172
- . arg ( "git" ) . arg ( "clean" ) . arg ( "-fdx" ) ) ;
173
- self . run ( Command :: new ( "git" ) . arg ( "submodule" ) . arg ( "foreach" )
174
- . arg ( "--recursive" )
175
- . arg ( "git" ) . arg ( "checkout" ) . arg ( "." ) ) ;
168
+ self . run ( git_submodule ( ) . arg ( "sync" ) ) ;
169
+ self . run ( git_submodule ( ) . arg ( "init" ) ) ;
170
+ self . run ( git_submodule ( ) . arg ( "update" ) ) ;
171
+ self . run ( git_submodule ( ) . arg ( "update" ) . arg ( "--recursive" ) ) ;
172
+ self . run ( git_submodule ( ) . arg ( "status" ) . arg ( "--recursive" ) ) ;
173
+ self . run ( git_submodule ( ) . arg ( "foreach" ) . arg ( "--recursive" )
174
+ . arg ( "git" ) . arg ( "clean" ) . arg ( "-fdx" ) ) ;
175
+ self . run ( git_submodule ( ) . arg ( "foreach" ) . arg ( "--recursive" )
176
+ . arg ( "git" ) . arg ( "checkout" ) . arg ( "." ) ) ;
176
177
}
177
178
178
179
/// Clear out `dir` if our build has been flagged as dirty, and also set
0 commit comments