Skip to content

Commit

Permalink
Preventing Git::Config.git_ssh from overwriting the previously set …
Browse files Browse the repository at this point in the history
…GIT_SSH env value unless a custom value is set via `Git.configure`

closes #212
  • Loading branch information
robertodecurnex committed Jan 14, 2015
1 parent 308281f commit 47051ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 6 additions & 3 deletions lib/git/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ module Git

class Config

attr_writer :binary_path

attr_accessor :git_ssh
attr_writer :binary_path, :git_ssh

def initialize
@binary_path = nil
@git_ssh = nil
end

def binary_path
@binary_path || 'git'
end

def git_ssh
@git_ssh || ENV['GIT_SSH']
end

end

end
14 changes: 12 additions & 2 deletions tests/units/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,23 @@ def test_set_config
end

def test_env_config
assert_equal(Git::Base.config.git_ssh, nil)

ENV['GIT_SSH'] = '/env/git/ssh'

assert_equal(Git::Base.config.git_ssh, '/env/git/ssh')

Git.configure do |config|
config.binary_path = "/usr/bin/git"
config.git_ssh = "/path/to/ssh/script"
config.binary_path = '/usr/bin/git'
config.git_ssh = '/path/to/ssh/script'
end

assert_equal(Git::Base.config.git_ssh, '/path/to/ssh/script')

@git.log
ensure
ENV['GIT_SSH'] = nil

Git.configure do |config|
config.binary_path = nil
config.git_ssh = nil
Expand Down

0 comments on commit 47051ed

Please sign in to comment.