2012-07-02 20:51:48 +02:00
|
|
|
class Settings < Settingslogic
|
|
|
|
source "#{Rails.root}/config/gitlab.yml"
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def web_protocol
|
2012-07-02 20:51:48 +02:00
|
|
|
self.web['protocol'] ||= web.https ? "https" : "http"
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
|
|
|
|
2012-08-03 17:27:39 +02:00
|
|
|
def web_host
|
2012-07-02 20:51:48 +02:00
|
|
|
self.web['host'] ||= 'localhost'
|
|
|
|
end
|
|
|
|
|
|
|
|
def email_from
|
2012-07-01 12:11:17 +02:00
|
|
|
self.email['from'] ||= ("notify@" + web_host)
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
|
|
|
|
2012-08-03 17:27:39 +02:00
|
|
|
def url
|
2012-07-02 20:51:48 +02:00
|
|
|
self['url'] ||= build_url
|
2012-08-03 17:27:39 +02:00
|
|
|
end
|
2012-07-02 20:51:48 +02:00
|
|
|
|
2012-08-03 17:27:39 +02:00
|
|
|
def web_port
|
2012-07-03 17:34:47 +02:00
|
|
|
if web.https
|
2012-07-03 17:52:48 +02:00
|
|
|
web['port'] = 443
|
2012-07-03 17:34:47 +02:00
|
|
|
else
|
|
|
|
web['port'] ||= 80
|
2012-07-03 17:52:48 +02:00
|
|
|
end.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def web_custom_port?
|
|
|
|
![443, 80].include?(web_port)
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
|
|
|
|
2012-07-02 20:51:48 +02:00
|
|
|
def build_url
|
2012-07-03 17:52:48 +02:00
|
|
|
if web_custom_port?
|
2012-10-02 09:54:33 +02:00
|
|
|
custom_port = ":#{web_port}"
|
|
|
|
else
|
|
|
|
custom_port = nil
|
2012-07-03 17:52:48 +02:00
|
|
|
end
|
2012-10-02 09:54:33 +02:00
|
|
|
[
|
|
|
|
web_protocol,
|
|
|
|
"://",
|
|
|
|
web_host,
|
|
|
|
custom_port
|
|
|
|
].join('')
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def ssh_port
|
|
|
|
git_host['port'] || 22
|
|
|
|
end
|
|
|
|
|
|
|
|
def ssh_user
|
|
|
|
git_host['git_user'] || 'git'
|
|
|
|
end
|
|
|
|
|
|
|
|
def ssh_host
|
2012-07-02 20:59:48 +02:00
|
|
|
git_host['host'] || web_host || 'localhost'
|
2012-07-02 20:51:48 +02:00
|
|
|
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
|
|
|
|
|
2012-08-28 10:57:23 +02:00
|
|
|
def git_hooks_path
|
|
|
|
git_host['hooks_path'] || '/home/git/share/gitolite/hooks/'
|
|
|
|
end
|
|
|
|
|
2012-07-02 20:51:48 +02:00
|
|
|
def git_upload_pack
|
2012-07-01 12:11:17 +02:00
|
|
|
if git_host['upload_pack'] != false
|
2012-07-02 20:59:48 +02:00
|
|
|
true
|
2012-07-01 12:11:17 +02:00
|
|
|
else
|
|
|
|
false
|
2012-07-02 20:59:48 +02:00
|
|
|
end
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def git_receive_pack
|
2012-07-01 12:11:17 +02:00
|
|
|
if git_host['receive_pack'] != false
|
2012-07-02 20:59:48 +02:00
|
|
|
true
|
2012-07-01 12:11:17 +02:00
|
|
|
else
|
|
|
|
false
|
2012-07-02 20:59:48 +02:00
|
|
|
end
|
2012-07-02 20:51:48 +02:00
|
|
|
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
|
2012-07-11 16:36:00 +02:00
|
|
|
git_host['admin_uri'] || 'git@localhost:gitolite-admin'
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
2012-07-02 20:59:48 +02:00
|
|
|
|
2012-08-29 01:08:39 +02:00
|
|
|
def gitolite_admin_key
|
|
|
|
git_host['gitolite_admin_key'] || 'gitlab'
|
|
|
|
end
|
|
|
|
|
2012-07-02 20:59:48 +02:00
|
|
|
def default_projects_limit
|
|
|
|
app['default_projects_limit'] || 10
|
|
|
|
end
|
2012-07-10 16:12:19 +02:00
|
|
|
|
|
|
|
def backup_path
|
|
|
|
t = app['backup_path'] || "backups/"
|
2012-09-26 20:52:01 +02:00
|
|
|
t = /^\//.match(t) ? t : Rails.root .join(t)
|
2012-07-10 16:12:19 +02:00
|
|
|
t
|
|
|
|
end
|
|
|
|
|
|
|
|
def backup_keep_time
|
|
|
|
app['backup_keep_time'] || 0
|
|
|
|
end
|
2012-08-16 03:06:08 +02:00
|
|
|
|
2012-09-12 06:48:22 +02:00
|
|
|
def ldap_enabled?
|
2012-09-13 00:11:59 +02:00
|
|
|
ldap && ldap['enabled']
|
|
|
|
rescue Settingslogic::MissingSetting
|
2012-09-12 06:48:22 +02:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2012-08-03 17:27:39 +02:00
|
|
|
def omniauth_enabled?
|
2012-09-12 06:48:22 +02:00
|
|
|
omniauth && omniauth['enabled']
|
2012-09-13 00:11:59 +02:00
|
|
|
rescue Settingslogic::MissingSetting
|
2012-09-12 06:48:22 +02:00
|
|
|
false
|
2012-08-03 17:27:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def omniauth_providers
|
2012-09-13 00:11:59 +02:00
|
|
|
(omniauth_enabled? && omniauth['providers']) || []
|
2012-08-03 17:27:39 +02:00
|
|
|
end
|
|
|
|
|
2012-08-16 03:06:08 +02:00
|
|
|
def disable_gravatar?
|
|
|
|
app['disable_gravatar'] || false
|
|
|
|
end
|
2012-07-02 20:51:48 +02:00
|
|
|
end
|
|
|
|
end
|