22require 'fileutils'
33require 'logger'
44require 'open3'
5+ require 'os'
56require 'tmpdir'
67require 'securerandom'
78require 'dpl/support/version'
@@ -262,7 +263,17 @@ def shell(cmd, opts = {})
262263 info cmd . echo if cmd . echo?
263264
264265 @last_out , @last_err , @last_status = retrying ( cmd . retry ? 2 : 0 ) do
265- send ( cmd . capture? ? :open3 : :system , cmd . cmd , cmd . opts )
266+ if OS . windows?
267+ command = "set -o pipefail && #{ cmd . cmd } "
268+ # required to get rsync working as rsync otherwise outputs "ssh: Could not resolve hostname c: Name or service not known"
269+ command = command . sub ( "C:/" , "/c/" )
270+ command = "bash -c \" #{ command } \" "
271+ system ( "#{ command } " )
272+ cmd_status = $?
273+ return cmd_status . exitstatus == 0
274+ else
275+ send ( cmd . capture? ? :open3 : :system , cmd . cmd , cmd . opts )
276+ end
266277 end
267278
268279 info cmd . success % { out : last_out } if success? && cmd . success?
@@ -405,14 +416,14 @@ def git_author_name
405416 `git log #{ git_sha } -n 1 --pretty=%an` . chomp
406417 end
407418
408- # Returns the comitter email of the commit `git_sha`.
419+ # Returns the committer email of the commit `git_sha`.
409420 def git_author_email
410421 `git log #{ git_sha } -n 1 --pretty=%ae` . chomp
411422 end
412423
413424 # Whether or not the git working directory is dirty
414425 def git_dirty?
415- !Kernel . system ( 'git diff --quiet' )
426+ !shell ( 'git diff --quiet' )
416427 end
417428
418429 # Returns the output of `git log`, using the given args.
@@ -430,7 +441,7 @@ def git_ls_files
430441
431442 # Returns true if the given ref exists remotely
432443 def git_ls_remote? ( url , ref )
433- Kernel . system ( "git ls-remote --exit-code #{ url } #{ ref } > /dev/null 2>&1" )
444+ shell ( "git ls-remote --exit-code #{ url } #{ ref } > /dev/null 2>&1" )
434445 end
435446
436447 # Returns known Git remote URLs
0 commit comments