1_settings.rb
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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 web_port
      if web.https
        web['port'] = 443
      else
        web['port'] ||= 80
      end.to_i
    end
    def web_custom_port?
      ![443, 80].include?(web_port)
    end
    def build_url
      raw_url = self.web_protocol
      raw_url << "://"
      raw_url << web_host
      if web_custom_port?
        raw_url << ":#{web_port}"
      end
      raw_url
    end
    def ssh_port
      git_host['port'] || 22
    end
    def ssh_user
      git_host['git_user'] || 'git'
    end
    def ssh_host
      git_host['host'] || web_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_hooks_path
      git_host['hooks_path'] || '/home/git/share/gitolite/hooks/'
    end
    def git_upload_pack
      if git_host['upload_pack'] != false
        true
      else
        false
      end
    end
    def git_receive_pack
      if git_host['receive_pack'] != false
        true
      else
        false
      end
    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_host['admin_uri'] || 'git@localhost:gitolite-admin'
    end
    def gitolite_admin_key
      git_host['gitolite_admin_key'] || 'gitlab'
    end
    def default_projects_limit
      app['default_projects_limit'] || 10
    end
    def backup_path
      t = app['backup_path'] || "backups/"
      t = /^\//.match(t) ? t : File.join(Rails.root + t)
      t
    end
    def backup_keep_time
      app['backup_keep_time'] || 0
    end
    def ldap_enabled?
      ldap['enabled']
    rescue
      false
    end
    def omniauth_enabled?
      omniauth && omniauth['enabled']
    rescue
      false
    end
    def omniauth_providers
      omniauth['providers'] || []
    end
    def disable_gravatar?
      app['disable_gravatar'] || false
    end
  end
end