Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

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

### pages

* Fix to allow being run on a Windows Git bash

### Releases

* Make --file glob files by default, and default to `*`
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ gems.each do |name, version, opts|
gem name, version, opts
end

gem 'os'

group :test do
gem 'coveralls'
gem 'rspec'
Expand Down
19 changes: 15 additions & 4 deletions lib/dpl/ctx/bash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'fileutils'
require 'logger'
require 'open3'
require 'os'
require 'tmpdir'
require 'securerandom'
require 'dpl/support/version'
Expand Down Expand Up @@ -262,7 +263,17 @@ def shell(cmd, opts = {})
info cmd.echo if cmd.echo?

@last_out, @last_err, @last_status = retrying(cmd.retry ? 2 : 0) do
send(cmd.capture? ? :open3 : :system, cmd.cmd, cmd.opts)
if OS.windows?
command = "set -o pipefail && #{cmd.cmd}"
# required to get rsync working as rsync otherwise outputs "ssh: Could not resolve hostname c: Name or service not known"
command = command.sub("C:/", "/c/")
command = "bash -c \"#{command}\""
system("#{command}")
cmd_status = $?
return cmd_status.exitstatus == 0
else
send(cmd.capture? ? :open3 : :system, cmd.cmd, cmd.opts)
end
end

info cmd.success % { out: last_out } if success? && cmd.success?
Expand Down Expand Up @@ -405,14 +416,14 @@ def git_author_name
`git log #{git_sha} -n 1 --pretty=%an`.chomp
end

# Returns the comitter email of the commit `git_sha`.
# Returns the committer email of the commit `git_sha`.
def git_author_email
`git log #{git_sha} -n 1 --pretty=%ae`.chomp
end

# Whether or not the git working directory is dirty
def git_dirty?
!Kernel.system('git diff --quiet')
!shell('git diff --quiet')
end

# Returns the output of `git log`, using the given args.
Expand All @@ -430,7 +441,7 @@ def git_ls_files

# Returns true if the given ref exists remotely
def git_ls_remote?(url, ref)
Kernel.system("git ls-remote --exit-code #{url} #{ref} > /dev/null 2>&1")
shell("git ls-remote --exit-code #{url} #{ref} > /dev/null 2>&1")
end

# Returns known Git remote URLs
Expand Down
6 changes: 3 additions & 3 deletions lib/dpl/providers/pages/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def login

def setup
info :setup_dir, src_dir
info :committer_from_gh if committer_from_gh?
info :git_config
end

def prepare
Expand All @@ -95,8 +93,10 @@ def prepare

def deploy
git_clone? ? git_clone : git_init
info :committer_from_gh if committer_from_gh?
info :git_config
copy_files
return info :stop unless git_dirty?
return info :stop unless !(git_clone?) || git_dirty?
git_config
git_commit
git_push
Expand Down
2 changes: 1 addition & 1 deletion spec/dpl/providers/pages/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

describe 'by default', record: true do
it { should have_run '[info] Authenticated as login' }
it { should have_run '[info] Configuring git committer to be author name (via Travis CI) <author email>' }
it { should have_run '[info] Deploying branch gh-pages to github.com/travis-ci/dpl.git' }
it { should have_run '[info] Cloning the branch gh-pages from the remote repo' }
it { should have_run 'git clone --quiet --branch="gh-pages" --depth=1 "https://token@github.com/travis-ci/dpl.git" . > /dev/null 2>&1' }
it { should have_run '[info] Configuring git committer to be author name (via Travis CI) <author email>' }
it { should have_run %(rsync -rl --exclude .git --delete "#{cwd}/" .) }
it { should have_run 'git config user.name "author name (via Travis CI)"' }
it { should have_run 'git config user.email "author email"' }
Expand Down