Skip to content

Commit ce8d798

Browse files
dr-BEatStephan Dilly
authored andcommitted
Fix Command::new behaviour on windows
1 parent 99dad5c commit ce8d798

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

asyncgit/src/sync/hooks.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ fn run_hook(
105105
let output = Command::new("bash")
106106
.args(bash_args)
107107
.current_dir(path)
108+
.env("DUMMYENV", "FixPathHandlingOnWindows") // This call forces Command to handle the Path environment correctly on windows, the specific env set here does not matter
108109
.output();
109110

110111
let output = output.expect("general hook error");
@@ -183,8 +184,7 @@ mod tests {
183184
let root = repo.path().parent().unwrap();
184185
let repo_path = root.as_os_str().to_str().unwrap();
185186

186-
let hook = b"
187-
#!/bin/sh
187+
let hook = b"#!/bin/sh
188188
exit 0
189189
";
190190

@@ -204,8 +204,7 @@ exit 0
204204
let root = repo.path().parent().unwrap();
205205
let repo_path = root.as_os_str().to_str().unwrap();
206206

207-
let hook = b"
208-
#!/bin/sh
207+
let hook = b"#!/bin/sh
209208
echo 'msg' > $1
210209
echo 'rejected'
211210
exit 1
@@ -230,8 +229,7 @@ exit 1
230229
let root = repo.path().parent().unwrap();
231230
// let repo_path = root.as_os_str().to_str().unwrap();
232231

233-
let hook = b"
234-
#!/bin/sh
232+
let hook = b"#!/bin/sh
235233
echo 'msg' > $1
236234
echo 'rejected'
237235
exit 1
@@ -261,8 +259,7 @@ exit 1
261259
let root = repo.path().parent().unwrap();
262260
let repo_path = root.as_os_str().to_str().unwrap();
263261

264-
let hook = b"
265-
#!/bin/sh
262+
let hook = b"#!/bin/sh
266263
echo 'msg' > $1
267264
exit 0
268265
";
@@ -281,8 +278,7 @@ exit 0
281278
let (_td, repo) = repo_init().unwrap();
282279
let root = repo.path().parent().unwrap();
283280

284-
let hook = b"
285-
#!/bin/sh
281+
let hook = b"#!/bin/sh
286282
echo 'rejected'
287283
exit 1
288284
";

0 commit comments

Comments
 (0)