Commit e88ec0a4 authored by Stan Hu's avatar Stan Hu

Put redis library in lib/vendor/ and adjust LOAD_PATH

parent 729470d3
...@@ -8,4 +8,3 @@ coverage/ ...@@ -8,4 +8,3 @@ coverage/
.bundle .bundle
tags tags
.bundle/ .bundle/
*.orig
...@@ -964,7 +964,7 @@ AllCops: ...@@ -964,7 +964,7 @@ AllCops:
- 'bin/**/*' - 'bin/**/*'
- 'lib/backup/**/*' - 'lib/backup/**/*'
- 'lib/tasks/**/*' - 'lib/tasks/**/*'
- 'lib/vendor/**/*'
- 'lib/email_validator.rb' - 'lib/email_validator.rb'
- 'lib/gitlab/upgrader.rb' - 'lib/gitlab/upgrader.rb'
- 'lib/gitlab/seeder.rb' - 'lib/gitlab/seeder.rb'
- 'lib/vendor/**/*'
REDIS_RB_VERSION=v3.3.0 REDIS_RB_VERSION=v3.3.0
REDIS_RB_TMP_DIR := $(shell mktemp -d) REDIS_RB_VENDOR_DIR=lib/vendor/redis
REDIS_RB_VENDOR_DIR=lib/vendor
PWD=`pwd` PWD=`pwd`
all: all:
update-redis: update-redis:
git clone https://github.com/redis/redis-rb.git $(REDIS_RB_TMP_DIR) rm -rf $(REDIS_RB_VENDOR_DIR)
cd $(REDIS_RB_TMP_DIR); git checkout $(REDIS_RB_VERSION) git clone -b $(REDIS_RB_VERSION) https://github.com/redis/redis-rb.git $(REDIS_RB_VENDOR_DIR)
cd $(PWD) rm -rf $(REDIS_RB_VENDOR_DIR)/.git
mkdir -p $(REDIS_RB_VENDOR_DIR)
cp -r $(REDIS_RB_TMP_DIR)/lib/* $(REDIS_RB_VENDOR_DIR)
# Adjust all 'require redis/' paths to relative paths
sed -i.orig -e 's/require "redis/require_relative "redis/g' $(REDIS_RB_VENDOR_DIR)/redis.rb
find $(REDIS_RB_VENDOR_DIR)/redis -name \*.rb -maxdepth 1 -exec sed -i.orig -e "s/require \"redis\//require_relative \"/g" {} \;
find $(REDIS_RB_VENDOR_DIR)/redis/connection -name \*.rb -maxdepth 1 -exec sed -i.orig -e 's/require "redis\/connection\//require_relative "/g' *.rb {} \;
find $(REDIS_RB_VENDOR_DIR)/redis/connection -name \*.rb -maxdepth 1 -exec sed -i.orig -e 's/require "redis\//require_relative "..\//g' *.rb {} \;
.PHONY=update-redis .PHONY=update-redis
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'vendor/redis/lib')))
require 'yaml' require 'yaml'
class GitlabConfig class GitlabConfig
......
require 'net/http' require 'net/http'
require 'openssl' require 'openssl'
require 'json' require 'json'
require 'redis'
require_relative 'gitlab_config' require_relative 'gitlab_config'
require_relative 'gitlab_logger' require_relative 'gitlab_logger'
require_relative 'gitlab_access' require_relative 'gitlab_access'
require_relative 'httpunix' require_relative 'httpunix'
require_relative 'vendor/redis'
class GitlabNet class GitlabNet
class ApiUnreachableError < StandardError; end class ApiUnreachableError < StandardError; end
......
require "monitor" require "monitor"
require_relative "redis/errors" require "redis/errors"
class Redis class Redis
...@@ -2766,8 +2766,8 @@ private ...@@ -2766,8 +2766,8 @@ private
end end
require_relative "redis/version" require "redis/version"
require_relative "redis/connection" require "redis/connection"
require_relative "redis/client" require "redis/client"
require_relative "redis/pipeline" require "redis/pipeline"
require_relative "redis/subscribe" require "redis/subscribe"
require_relative "errors" require "redis/errors"
require "socket" require "socket"
require "cgi" require "cgi"
...@@ -478,7 +478,7 @@ class Redis ...@@ -478,7 +478,7 @@ class Redis
if driver.kind_of?(String) if driver.kind_of?(String)
begin begin
require_relative "connection/#{driver}" require "redis/connection/#{driver}"
driver = Connection.const_get(driver.capitalize) driver = Connection.const_get(driver.capitalize)
rescue LoadError, NameError rescue LoadError, NameError
raise RuntimeError, "Cannot load driver #{driver.inspect}" raise RuntimeError, "Cannot load driver #{driver.inspect}"
......
require_relative "connection/registry" require "redis/connection/registry"
# If a connection driver was required before this file, the array # If a connection driver was required before this file, the array
# Redis::Connection.drivers will contain one or more classes. The last driver # Redis::Connection.drivers will contain one or more classes. The last driver
...@@ -6,4 +6,4 @@ require_relative "connection/registry" ...@@ -6,4 +6,4 @@ require_relative "connection/registry"
# the plain Ruby driver as our default. Another driver can be required at a # the plain Ruby driver as our default. Another driver can be required at a
# later point in time, causing it to be the last element of the #drivers array # later point in time, causing it to be the last element of the #drivers array
# and therefore be chosen by default. # and therefore be chosen by default.
require_relative "connection/ruby" if Redis::Connection.drivers.empty? require "redis/connection/ruby" if Redis::Connection.drivers.empty?
\ No newline at end of file
require_relative "registry" require "redis/connection/registry"
require_relative "../errors" require "redis/errors"
require "hiredis/connection" require "hiredis/connection"
require "timeout" require "timeout"
......
require_relative "registry" require "redis/connection/registry"
require_relative "command_helper" require "redis/connection/command_helper"
require_relative "../errors" require "redis/errors"
require "socket" require "socket"
require "timeout" require "timeout"
......
require_relative "command_helper" require "redis/connection/command_helper"
require_relative "registry" require "redis/connection/registry"
require_relative "../errors" require "redis/errors"
require "em-synchrony" require "em-synchrony"
require "hiredis/reader" require "hiredis/reader"
......
require_relative "hash_ring" require "redis/hash_ring"
class Redis class Redis
class Distributed class Distributed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment