Skip to content

fix git ssh env usage #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
fix git ssh env usage
v1.2.8 allowed setting of GIT_SSH to point to SSH wrapper; v1.2.9
overrides this with value of Git::Base.config.git_ssh.

This is our story in our backlog: https://www.pivotaltracker.com/story/show/86059268.

Signed-off-by: Frank Kotsianas <frankkotsianas@gmail.com>
  • Loading branch information
ericTsiliacos authored and fkotsian committed Jan 13, 2015
commit 06dae5f8a0f27fe57bcaa217867007484262ebe3
2 changes: 1 addition & 1 deletion lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def set_custom_git_env_variables
ENV['GIT_DIR'] = @git_dir
ENV['GIT_WORK_TREE'] = @git_work_dir
ENV['GIT_INDEX_FILE'] = @git_index_file
ENV['GIT_SSH'] = Git::Base.config.git_ssh
ENV.fetch('GIT_SSH', Git::Base.config.git_ssh)
end

# Runs a block inside an environment with customized ENV variables.
Expand Down
21 changes: 21 additions & 0 deletions tests/units/test_lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ def test_environment_reset
assert_equal(ENV['GIT_INDEX_FILE'],'my_index')
end

def test_git_ssh_from_environment_is_passed_to_binary
ENV['GIT_SSH'] = 'my/git-ssh-wrapper'

Dir.mktmpdir do |dir|
begin
output_path = File.join(dir, 'git_ssh_value')
binary_path = File.join(dir, 'git')
old_binary_path = Git::Base.config.binary_path
Git::Base.config.binary_path = binary_path
File.open(binary_path, 'w') { |f|
f << "echo $GIT_SSH > #{output_path}"
}
FileUtils.chmod(0700, binary_path)
@lib.checkout('something')
assert_equal("my/git-ssh-wrapper\n", File.read(output_path))
ensure
Git::Base.config.binary_path = old_binary_path
end
end
end

def test_revparse
assert_equal('1cc8667014381e2788a94777532a788307f38d26', @lib.revparse('1cc8667014381')) # commit
assert_equal('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', @lib.revparse('1cc8667014381^{tree}')) #tree
Expand Down