Skip to content

Commit 3a5c009

Browse files
kopporOliver Kopp
authored andcommitted
Enfore using bash.exe on Windows
1 parent 04b83cf commit 3a5c009

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
* Add `--key_file` to allow using a service account key file
1616

17+
### pages
18+
19+
* Fix to allow being run on a Windows Git bash
20+
1721
### Releases
1822

1923
* Make --file glob files by default, and default to `*`

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ gems.each do |name, version, opts|
1212
gem name, version, opts
1313
end
1414

15+
gem 'os'
16+
1517
group :test do
1618
gem 'coveralls'
1719
gem 'rspec'

lib/dpl/ctx/bash.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'fileutils'
33
require 'logger'
44
require 'open3'
5+
require 'os'
56
require 'tmpdir'
67
require 'securerandom'
78
require '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

lib/dpl/providers/pages/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def deploy
9696
info :committer_from_gh if committer_from_gh?
9797
info :git_config
9898
copy_files
99-
return info :stop unless git_dirty?
99+
return info :stop unless !(git_clone?) || git_dirty?
100100
git_config
101101
git_commit
102102
git_push

0 commit comments

Comments
 (0)