提交 7944d63e 编写于 作者: M Mislav Marohnić

Support Enterprise over HTTP via `protocol` config option

Example `~/.config/hub`:

  my.example.org:
  - user: myuser
    oauth_token: mytoken
    protocol: http

Currently there is no way to set `protocol` other than manually editing the
configuration file.
上级 e6841d68
......@@ -135,3 +135,18 @@ Scenario: Related fork already exists
And "git.my.org" is a whitelisted Enterprise host
When I successfully run `hub fork`
Then the url for "mislav" should be "git@git.my.org:mislav/dotfiles.git"
Scenario: Enterprise fork using regular HTTP
Given the GitHub API server:
"""
before {
halt 400 unless request.env['HTTP_X_ORIGINAL_SCHEME'] == 'http'
halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token FITOKEN'
}
post('/api/v3/repos/evilchelu/dotfiles/forks', :host_name => 'git.my.org') { '' }
"""
And the "origin" remote has url "git@git.my.org:evilchelu/dotfiles.git"
And I am "mislav" on http://git.my.org with OAuth token "FITOKEN"
And "git.my.org" is a whitelisted Enterprise host
When I successfully run `hub fork`
Then the url for "mislav" should be "git@git.my.org:mislav/dotfiles.git"
......@@ -25,10 +25,12 @@ Given(/^the "([^"]*)" remote has url "([^"]*)"$/) do |remote_name, url|
end
end
Given(/^I am "([^"]*)" on ([\w.-]+)(?: with OAuth token "([^"]*)")?$/) do |name, host, token|
Given(/^I am "([^"]*)" on ([\S]+)(?: with OAuth token "([^"]*)")?$/) do |name, host, token|
edit_hub_config do |cfg|
entry = {'user' => name}
entry['oauth_token'] = token if token
host = host.sub(%r{^([\w-]+)://}, '')
entry['protocol'] = $1 if $1
cfg[host.downcase] = [entry]
end
end
......
......@@ -246,6 +246,7 @@ module Hub
end
def configure_connection req, url
url.scheme = config.protocol(url.host)
if ENV['HUB_TEST_HOST']
req['Host'] = url.host
req['X-Original-Scheme'] = url.scheme
......@@ -473,6 +474,11 @@ module Hub
end
end
def protocol host
host = normalize_host host
@data.fetch_value(host, nil, :protocol) { 'https' }
end
def value_to_persist(value = nil)
@data.persist_next_change!
value
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册