From ce8d79855db0d788f600d21248c6126ca5a72a91 Mon Sep 17 00:00:00 2001 From: dr-BEat Date: Sun, 16 Aug 2020 13:48:35 +0200 Subject: [PATCH] Fix Command::new behaviour on windows --- asyncgit/src/sync/hooks.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/asyncgit/src/sync/hooks.rs b/asyncgit/src/sync/hooks.rs index 6b34a1b8..271e93d3 100644 --- a/asyncgit/src/sync/hooks.rs +++ b/asyncgit/src/sync/hooks.rs @@ -105,6 +105,7 @@ fn run_hook( let output = Command::new("bash") .args(bash_args) .current_dir(path) + .env("DUMMYENV", "FixPathHandlingOnWindows") // This call forces Command to handle the Path environment correctly on windows, the specific env set here does not matter .output(); let output = output.expect("general hook error"); @@ -183,8 +184,7 @@ mod tests { let root = repo.path().parent().unwrap(); let repo_path = root.as_os_str().to_str().unwrap(); - let hook = b" -#!/bin/sh + let hook = b"#!/bin/sh exit 0 "; @@ -204,8 +204,7 @@ exit 0 let root = repo.path().parent().unwrap(); let repo_path = root.as_os_str().to_str().unwrap(); - let hook = b" -#!/bin/sh + let hook = b"#!/bin/sh echo 'msg' > $1 echo 'rejected' exit 1 @@ -230,8 +229,7 @@ exit 1 let root = repo.path().parent().unwrap(); // let repo_path = root.as_os_str().to_str().unwrap(); - let hook = b" -#!/bin/sh + let hook = b"#!/bin/sh echo 'msg' > $1 echo 'rejected' exit 1 @@ -261,8 +259,7 @@ exit 1 let root = repo.path().parent().unwrap(); let repo_path = root.as_os_str().to_str().unwrap(); - let hook = b" -#!/bin/sh + let hook = b"#!/bin/sh echo 'msg' > $1 exit 0 "; @@ -281,8 +278,7 @@ exit 0 let (_td, repo) = repo_init().unwrap(); let root = repo.path().parent().unwrap(); - let hook = b" -#!/bin/sh + let hook = b"#!/bin/sh echo 'rejected' exit 1 ";