diff options
-rw-r--r-- | app/metal/git_http_cloner.rb | 2 | ||||
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | db/migrate/20090319111629_adding_protocol_to_cloners.rb | 11 | ||||
-rwxr-xr-x | script/git-daemon | 2 | ||||
-rw-r--r-- | test/integration/git_http_cloning_test.rb | 1 |
5 files changed, 16 insertions, 4 deletions
diff --git a/app/metal/git_http_cloner.rb b/app/metal/git_http_cloner.rb index 8daa3da..015503d 100644 --- a/app/metal/git_http_cloner.rb +++ b/app/metal/git_http_cloner.rb @@ -18,7 +18,7 @@ class GitHttpCloner rest = match[2] begin repo = Repository.find_by_path(path) - repo.cloned_from(remote_ip(env)) if rest == '/HEAD' + repo.cloned_from(remote_ip(env), nil, nil, 'http') if rest == '/HEAD' full_path = File.join(GitoriousConfig['repository_base_path'], repo.real_gitdir, rest) return [200, {"X-Sendfile" => full_path, 'Content-Type' => 'application/octet-stream'}, []] rescue ActiveRecord::RecordNotFound diff --git a/app/models/repository.rb b/app/models/repository.rb index 0615c3e..8dbb987 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -351,8 +351,8 @@ class Repository < ActiveRecord::Base users_by_email end - def cloned_from(ip, country_code = "--", country_name = nil) - cloners.create(:ip => ip, :date => Time.now.utc, :country_code => country_code, :country => country_name) + def cloned_from(ip, country_code = "--", country_name = nil, protocol = 'git') + cloners.create(:ip => ip, :date => Time.now.utc, :country_code => country_code, :country => country_name, :protocol => protocol) end def wiki? diff --git a/db/migrate/20090319111629_adding_protocol_to_cloners.rb b/db/migrate/20090319111629_adding_protocol_to_cloners.rb new file mode 100644 index 0000000..a0d0897 --- /dev/null +++ b/db/migrate/20090319111629_adding_protocol_to_cloners.rb @@ -0,0 +1,11 @@ +class AddingProtocolToCloners < ActiveRecord::Migration + def self.up + add_column :cloners, :protocol, :string + Cloner.reset_column_information + Cloner.update_all(:protocol => 'git') + end + + def self.down + remove_column :cloners, :protocol + end +end diff --git a/script/git-daemon b/script/git-daemon index 0fc2642..472c3eb 100755 --- a/script/git-daemon +++ b/script/git-daemon @@ -112,7 +112,7 @@ module Git else geoip = GeoIP.new(File.join(RAILS_ROOT, "data", "GeoIP.dat")) localization = geoip.country(ip) - repository.cloned_from(ip, localization[3], localization[5]) + repository.cloned_from(ip, localization[3], localization[5], 'git') end Dir.chdir(real_path) do diff --git a/test/integration/git_http_cloning_test.rb b/test/integration/git_http_cloning_test.rb index 0ffa7f0..70fe283 100644 --- a/test/integration/git_http_cloning_test.rb +++ b/test/integration/git_http_cloning_test.rb @@ -13,6 +13,7 @@ class GitHttpCloningTest < ActionController::IntegrationTest get @request_uri, {}, :host => host, :remote_addr => '192.71.1.2' last_cloner = @repository.cloners.last assert_equal('192.71.1.2', last_cloner.ip) + assert_equal('http', last_cloner.protocol) end assert_response :success assert_not_nil(headers['X-Sendfile']) |