Skip to content

Commit

Permalink
Pass the proxy settings to GitWorktree from GitRepository
Browse files Browse the repository at this point in the history
This commit also adds a path setting to the proxy url because
without it the url validation was failing in libgit2. It wants
at least a trailing slash.

https://bugzilla.redhat.com/show_bug.cgi?id=1735712
  • Loading branch information
carbonin committed Aug 13, 2019
1 parent 74dc807 commit ad9b2b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/git_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,20 @@ def worktree_params
params[:password] = auth.password
end
end
params[:proxy_url] = proxy_url if proxy_url?
params
end

def proxy_url?
!!Settings.git_repository_proxy.host
end

def proxy_url
uri_opts = Settings.git_repository_proxy.to_h.slice(:host, :port, :scheme, :path)
uri_opts[:path] ||= "/"
URI::Generic.build(uri_opts).to_s
end

def broadcast_repo_dir_delete
MiqQueue.broadcast(
:class_name => self.class.name,
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@
:port:
:user:
:scheme:
:path:
:help_menu:
:documentation:
:type: default
Expand Down
13 changes: 13 additions & 0 deletions spec/models/git_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@
expect(repo.default_authentication.password).to eq(password)
end

it "sends the proxy settings to the worktree instance" do
stub_settings(:git_repository_proxy => {
:host => "example.com",
:port => "80",
:scheme => "http",
:path => "/proxy"
})
expect(GitWorktree).to receive(:new).with(hash_including(:proxy_url => "http://example.com:80/proxy")).twice.times.and_return(gwt)
expect(gwt).to receive(:pull).with(no_args)

repo.refresh
end

context "self signed certifcate" do
let(:verify_ssl) { OpenSSL::SSL::VERIFY_NONE }

Expand Down

0 comments on commit ad9b2b2

Please sign in to comment.