1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Merge pull request #1840 from olleolleolle/patch-1

Git plugin: shellescape git_wrapper_path
This commit is contained in:
Matt Brictson 2017-02-04 08:29:42 -08:00 committed by GitHub
commit fba0d1930b
3 changed files with 14 additions and 1 deletions

View file

@ -7,6 +7,7 @@ Reverse Chronological Order:
https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD
* [#1835](https://github.com/capistrano/capistrano/pull/1835): Stopped printing parenthesis in ask prompt if no default or nil was passed as argument [(@chamini2)](https://github.com/chamini2)
* [#1840](https://github.com/capistrano/capistrano/pull/1840): Git plugin: shellescape git_wrapper_path [(@olleolleolle)](https://github.com/olleolleolle)
* Your contribution here!
## `3.7.2` (2017-01-27)

View file

@ -1,4 +1,5 @@
require "capistrano/scm/plugin"
require "shellwords"
class Capistrano::SCM::Git < Capistrano::SCM::Plugin
def set_defaults
@ -6,7 +7,7 @@ class Capistrano::SCM::Git < Capistrano::SCM::Plugin
set_if_empty :git_wrapper_path, lambda {
# Try to avoid permissions issues when multiple users deploy the same app
# by using different file names in the same dir for each deployer and stage.
suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-").gsub(/\s+/, "-")
suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-").shellescape
"#{fetch(:tmp_dir)}/git-ssh-#{suffix}.sh"
}
set_if_empty :git_environmental_variables, lambda {

View file

@ -27,6 +27,17 @@ module Capistrano
Capistrano::Configuration.reset!
end
describe "#set_defaults" do
it "sets ::git_wrapper_path in a shell-safe way" do
env.set(:tmp_dir, "/tmp")
env.set(:application, "my_app")
env.set(:stage, "staging")
env.set(:local_user, "(Git Web User) via ShipIt")
subject.set_defaults
expect(env.fetch(:git_wrapper_path)).to eq('/tmp/git-ssh-my_app-staging-\(Git\ Web\ User\)\ via\ ShipIt.sh')
end
end
describe "#git" do
it "should call execute git in the context, with arguments" do
backend.expects(:execute).with(:git, :init)