Epic: Gitlab configuration with default values
This commit is contained in:
parent
b3a0ee8e63
commit
9b337b8328
25 changed files with 147 additions and 45 deletions
|
@ -1,4 +0,0 @@
|
|||
GIT_HOST = YAML.load_file("#{Rails.root}/config/gitlab.yml")["git_host"]
|
||||
EMAIL_OPTS = YAML.load_file("#{Rails.root}/config/gitlab.yml")["email"]
|
||||
GIT_OPTS = YAML.load_file("#{Rails.root}/config/gitlab.yml")["git"]
|
||||
GITLAB_OPTS = YAML.load_file("#{Rails.root}/config/gitlab.yml")["gitlab"]
|
1
config/initializers/0_before_all.rb
Normal file
1
config/initializers/0_before_all.rb
Normal file
|
@ -0,0 +1 @@
|
|||
GITLAB_OPTS = YAML.load_file("#{Rails.root}/config/gitlab.yml")["gitlab"]
|
75
config/initializers/1_settings.rb
Normal file
75
config/initializers/1_settings.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
class Settings < Settingslogic
|
||||
source "#{Rails.root}/config/gitlab.yml"
|
||||
|
||||
class << self
|
||||
def web_protocol
|
||||
self.web['protocol'] ||= web.https ? "https://" : "http://"
|
||||
end
|
||||
|
||||
def web_host
|
||||
self.web['host'] ||= 'localhost'
|
||||
end
|
||||
|
||||
def email_from
|
||||
self.email['from'] ||= "notify@" + web_host
|
||||
end
|
||||
|
||||
def url
|
||||
self['url'] ||= build_url
|
||||
end
|
||||
|
||||
def build_url
|
||||
raw_url = self.web_protocol
|
||||
raw_url << web.host
|
||||
raw_url << ":#{web.port}" if web.port.to_i != 80
|
||||
end
|
||||
|
||||
def ssh_port
|
||||
git_host['port'] || 22
|
||||
end
|
||||
|
||||
def ssh_user
|
||||
git_host['git_user'] || 'git'
|
||||
end
|
||||
|
||||
def ssh_host
|
||||
git_host['host'] || 'localhost'
|
||||
end
|
||||
|
||||
def ssh_path
|
||||
if ssh_port != 22
|
||||
"ssh://#{ssh_user}@#{ssh_host}:#{ssh_port}/"
|
||||
else
|
||||
"#{ssh_user}@#{ssh_host}:"
|
||||
end
|
||||
end
|
||||
|
||||
def git_base_path
|
||||
git_host['base_path'] || '/home/git/repositories/'
|
||||
end
|
||||
|
||||
def git_upload_pack
|
||||
git_host['upload_pack'] || true
|
||||
end
|
||||
|
||||
def git_receive_pack
|
||||
git_host['receive_pack'] || true
|
||||
end
|
||||
|
||||
def git_bin_path
|
||||
git['path'] || '/usr/bin/git'
|
||||
end
|
||||
|
||||
def git_max_size
|
||||
git['git_max_size'] || 5242880 # 5.megabytes
|
||||
end
|
||||
|
||||
def git_timeout
|
||||
git['git_timeout'] || 10
|
||||
end
|
||||
|
||||
def gitolite_admin_uri
|
||||
git['admin_uri'] || 'git@localhost:gitolite-admin'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,8 @@
|
|||
module Gitlab
|
||||
Version = File.read(Rails.root.join("VERSION"))
|
||||
Revision = `git log --pretty=format:'%h' -n 1`
|
||||
|
||||
def self.config
|
||||
Settings
|
||||
end
|
||||
end
|
|
@ -1,8 +1,8 @@
|
|||
require 'grit'
|
||||
require 'pygments'
|
||||
|
||||
Grit::Git.git_timeout = GIT_OPTS["git_timeout"]
|
||||
Grit::Git.git_max_size = GIT_OPTS["git_max_size"]
|
||||
Grit::Git.git_timeout = Gitlab.config.git_timeout
|
||||
Grit::Git.git_max_size = Gitlab.config.git_max_size
|
||||
|
||||
Grit::Blob.class_eval do
|
||||
include Linguist::BlobHelper
|
|
@ -4,7 +4,7 @@ Devise.setup do |config|
|
|||
# ==> Mailer Configuration
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
||||
config.mailer_sender = EMAIL_OPTS["from"]
|
||||
config.mailer_sender = Gitlab.config.email_from
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
# config.mailer = "Devise::Mailer"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue