Commit 1dcf19c924ee46d713fa9fc7c8a630386a475d49

Authored by Dmitriy Zaporozhets
2 parents 9bc315bb 4c8ac320

Merge pull request #2247 from riyad/update-settings

Reorganize settings
app/controllers/admin/users_controller.rb
... ... @@ -30,7 +30,7 @@ class Admin::UsersController < AdminController
30 30  
31 31  
32 32 def new
33   - @admin_user = User.new({ projects_limit: Gitlab.config.default_projects_limit }, as: :admin)
  33 + @admin_user = User.new({ projects_limit: Gitlab.config.gitlab.default_projects_limit }, as: :admin)
34 34 end
35 35  
36 36 def edit
... ...
app/controllers/omniauth_callbacks_controller.rb
1 1 class OmniauthCallbacksController < Devise::OmniauthCallbacksController
2   - Gitlab.config.omniauth_providers.each do |provider|
  2 + Gitlab.config.omniauth.providers.each do |provider|
3 3 define_method provider['name'] do
4 4 handle_omniauth
5 5 end
... ...
app/helpers/application_helper.rb
... ... @@ -34,10 +34,10 @@ module ApplicationHelper
34 34 def gravatar_icon(user_email = '', size = nil)
35 35 size = 40 if size.nil? || size <= 0
36 36  
37   - if Gitlab.config.disable_gravatar? || user_email.blank?
  37 + if !Gitlab.config.gravatar.enabled || user_email.blank?
38 38 'no_avatar.png'
39 39 else
40   - gravatar_url = request.ssl? ? Gitlab.config.gravatar_ssl_url : Gitlab.config.gravatar_url
  40 + gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url
41 41 user_email.strip!
42 42 sprintf(gravatar_url, {:hash => Digest::MD5.hexdigest(user_email.downcase), :email => URI.escape(user_email), :size => size})
43 43 end
... ... @@ -48,7 +48,7 @@ module ApplicationHelper
48 48 end
49 49  
50 50 def web_app_url
51   - "#{request_protocol}://#{Gitlab.config.web_host}/"
  51 + "#{request_protocol}://#{Gitlab.config.gitlab.host}/"
52 52 end
53 53  
54 54 def last_commit(project)
... ...
app/mailers/notify.rb
... ... @@ -3,11 +3,11 @@ class Notify &lt; ActionMailer::Base
3 3 add_template_helper ApplicationHelper
4 4 add_template_helper GitlabMarkdownHelper
5 5  
6   - default_url_options[:host] = Gitlab.config.web_host
7   - default_url_options[:protocol] = Gitlab.config.web_protocol
8   - default_url_options[:port] = Gitlab.config.web_port if Gitlab.config.web_custom_port?
  6 + default_url_options[:host] = Gitlab.config.gitlab.host
  7 + default_url_options[:protocol] = Gitlab.config.gitlab.protocol
  8 + default_url_options[:port] = Gitlab.config.gitlab.port if Gitlab.config.gitlab_on_non_standard_port?
9 9  
10   - default from: Gitlab.config.email_from
  10 + default from: Gitlab.config.gitlab.email_from
11 11  
12 12  
13 13  
... ...
app/models/namespace.rb
... ... @@ -48,14 +48,14 @@ class Namespace &lt; ActiveRecord::Base
48 48 end
49 49  
50 50 def ensure_dir_exist
51   - namespace_dir_path = File.join(Gitlab.config.git_base_path, path)
  51 + namespace_dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
52 52 system("mkdir -m 770 #{namespace_dir_path}") unless File.exists?(namespace_dir_path)
53 53 end
54 54  
55 55 def move_dir
56 56 if path_changed?
57   - old_path = File.join(Gitlab.config.git_base_path, path_was)
58   - new_path = File.join(Gitlab.config.git_base_path, path)
  57 + old_path = File.join(Gitlab.config.gitolite.repos_path, path_was)
  58 + new_path = File.join(Gitlab.config.gitolite.repos_path, path)
59 59 if File.exists?(new_path)
60 60 raise "Already exists"
61 61 end
... ... @@ -64,7 +64,7 @@ class Namespace &lt; ActiveRecord::Base
64 64 end
65 65  
66 66 def rm_dir
67   - dir_path = File.join(Gitlab.config.git_base_path, path)
  67 + dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
68 68 system("rm -rf #{dir_path}")
69 69 end
70 70 end
... ...
app/models/project.rb
... ... @@ -195,7 +195,7 @@ class Project &lt; ActiveRecord::Base
195 195 end
196 196  
197 197 def web_url
198   - [Gitlab.config.url, path_with_namespace].join("/")
  198 + [Gitlab.config.gitlab.url, path_with_namespace].join("/")
199 199 end
200 200  
201 201 def common_notes
... ...
app/roles/push_observer.rb
... ... @@ -114,7 +114,7 @@ module PushObserver
114 114 id: commit.id,
115 115 message: commit.safe_message,
116 116 timestamp: commit.date.xmlschema,
117   - url: "#{Gitlab.config.url}/#{path_with_namespace}/commit/#{commit.id}",
  117 + url: "#{Gitlab.config.gitlab.url}/#{path_with_namespace}/commit/#{commit.id}",
118 118 author: {
119 119 name: commit.author_name,
120 120 email: commit.author_email
... ...
app/roles/repository.rb
... ... @@ -97,7 +97,7 @@ module Repository
97 97 end
98 98  
99 99 def path_to_repo
100   - File.join(Gitlab.config.git_base_path, "#{path_with_namespace}.git")
  100 + File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git")
101 101 end
102 102  
103 103 def namespace_dir
... ... @@ -199,7 +199,7 @@ module Repository
199 199 end
200 200  
201 201 def http_url_to_repo
202   - http_url = [Gitlab.config.url, "/", path_with_namespace, ".git"].join('')
  202 + http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('')
203 203 end
204 204  
205 205 # Check if current branch name is marked as protected in the system
... ...
app/views/admin/groups/show.html.haml
... ... @@ -22,7 +22,7 @@
22 22 %b
23 23 Path:
24 24 %td
25   - %span.monospace= File.join(Gitlab.config.git_base_path, @group.path)
  25 + %span.monospace= File.join(Gitlab.config.gitolite.repos_path, @group.path)
26 26 %tr
27 27 %td
28 28 %b
... ...
app/views/errors/gitolite.html.haml
... ... @@ -21,5 +21,5 @@
21 21 Permissions:
22 22 %pre
23 23 = preserve do
24   - sudo chown -R git:git #{Gitlab.config.git_base_path}
25   - sudo chmod -R ug+rwXs #{Gitlab.config.git_base_path}
  24 + sudo chown -R git:git #{Gitlab.config.gitolite.repos_path}
  25 + sudo chmod -R ug+rwXs #{Gitlab.config.gitolite.repos_path}
... ...
app/views/profiles/account.html.haml
1   -- if Gitlab.config.omniauth_enabled?
  1 +- if Gitlab.config.omniauth.enabled
2 2 %fieldset
3 3 %legend Social Accounts
4 4 .oauth_select_holder
... ...
app/views/profiles/show.html.haml
... ... @@ -33,11 +33,11 @@
33 33 %ul
34 34 %li
35 35 %p You can change your password on Account page
36   - -unless Gitlab.config.disable_gravatar?
  36 + - if Gitlab.config.gravatar.enabled
37 37 %li
38 38 %p You can change your avatar at #{link_to "gravatar.com", "http://gravatar.com"}
39 39  
40   - - if Gitlab.config.omniauth_enabled? && @user.provider?
  40 + - if Gitlab.config.omniauth.enabled && @user.provider?
41 41 %li
42 42 %p
43 43 You can login through #{@user.provider.titleize}!
... ...
app/views/shared/_clone_panel.html.haml
1 1 .input-prepend.project_clone_holder
2 2 %button{class: "btn active", :"data-clone" => @project.ssh_url_to_repo} SSH
3   - %button{class: "btn", :"data-clone" => @project.http_url_to_repo}= Gitlab.config.web_protocol.upcase
  3 + %button{class: "btn", :"data-clone" => @project.http_url_to_repo}= Gitlab.config.gitlab.protocol.upcase
4 4 = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select input-xxlarge"
... ...
app/workers/post_receive.rb
... ... @@ -2,7 +2,7 @@ class PostReceive
2 2 @queue = :post_receive
3 3  
4 4 def self.perform(repo_path, oldrev, newrev, ref, identifier)
5   - repo_path.gsub!(Gitlab.config.git_base_path.to_s, "")
  5 + repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "")
6 6 repo_path.gsub!(/.git$/, "")
7 7 repo_path.gsub!(/^\//, "")
8 8  
... ... @@ -10,7 +10,7 @@ class PostReceive
10 10 return false if project.nil?
11 11  
12 12 # Ignore push from non-gitlab users
13   - user = if identifier.eql? Gitlab.config.gitolite_admin_key
  13 + user = if identifier.eql? Gitlab.config.gitolite.admin_key
14 14 email = project.commit(newrev).author.email rescue nil
15 15 User.find_by_email(email) if email
16 16 elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
... ...
config/gitlab.yml.example
1   -# # # # # # # # # # # # # # # # # #
2   -# Gitlab application config file #
3   -# # # # # # # # # # # # # # # # # #
4 1  
5 2 #
6   -# 1. Common settings
  3 +# 1. GitLab app settings
7 4 # ==========================
8 5  
9   -# Web application specific settings
10   -web:
  6 +## GitLab settings
  7 +gitlab:
  8 + ## Web server settings
11 9 host: localhost
12 10 port: 80
13 11 https: false
14 12  
15   -# Email used for notification
16   -# about new issues, comments
17   -email:
18   - from: notify@localhost
  13 + ## Email settings
  14 + # Email address used in the "From" field in mails sent by GitLab
  15 + email_from: gitlab@localhost
19 16  
20   -# Application specific settings
21   -# Like default project limit for user etc
22   -app:
  17 + ## Project settings
23 18 default_projects_limit: 10
24   - # backup_path: "/vol/backups" # default: Rails.root + backups/
25   - # backup_keep_time: 604800 # default: 0 (forever) (in seconds)
26   - # disable_gravatar: true # default: false - Disable user avatars from Gravatar.com
27   - # gravatar_url: "http://" # default: http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm
28   - # gravatar_ssl_url: "https://" # default: https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm
  19 +
  20 +## Gravatar
  21 +gravatar:
  22 + enabled: true # Use user avatar images from Gravatar.com (default: true)
  23 + # plain_url: "http://..." # default: http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm
  24 + # ssl_url: "https://..." # default: https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm
  25 +
29 26  
30 27  
31 28 #
32 29 # 2. Auth settings
33 30 # ==========================
34   -ldap:
  31 +
  32 +## LDAP settings
  33 +ldap:
35 34 enabled: false
36 35 host: '_your_ldap_server'
37 36 base: '_the_base_where_you_search_for_users'
38 37 port: 636
39 38 uid: 'sAMAccountName'
40   - method: 'ssl' # plain
  39 + method: 'ssl' # "ssl" or "plain"
41 40 bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
42 41 password: '_the_password_of_the_bind_user'
43 42  
  43 +## Omniauth settings
44 44 omniauth:
45 45 # Enable ability for users
46   - # to login via twitter, google ..
  46 + # Allow logging in via Twitter, Google, etc. using Omniauth providers
47 47 enabled: false
48 48  
49   - # IMPORTANT!
50   - # It allows user to login without having user account
  49 + # CAUTION!
  50 + # This allows users to login without having a user account first (default: false)
  51 + # User accounts will be created automatically when authentication was successful.
51 52 allow_single_sign_on: false
  53 + # Locks down those users until they have been cleared by the admin (default: true)
52 54 block_auto_created_users: true
53 55  
54   - # Auth providers
  56 + ## Auth providers
  57 + # Uncomment the lines and fill in the data of the auth provider you want to use
  58 + # If your favorite auth provider is not listed you can user others:
  59 + # see https://github.com/gitlabhq/gitlabhq/wiki/Using-Custom-Omniauth-Providers
55 60 providers:
56 61 # - { name: 'google_oauth2', app_id: 'YOUR APP ID',
57 62 # app_secret: 'YOUR APP SECRET',
... ... @@ -62,29 +67,36 @@ omniauth:
62 67 # app_secret: 'YOUR APP SECRET' }
63 68  
64 69  
  70 +
65 71 #
66   -# 3. Advanced settings:
  72 +# 3. Advanced settings
67 73 # ==========================
68 74  
69   -# Git Hosting configuration
70   -git_host:
  75 +## Backup settings
  76 +backup:
  77 + path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
  78 + # keep_time: 604800 # default: 0 (forever) (in seconds)
  79 +
  80 +## Gitolite settings
  81 +gitolite:
71 82 admin_uri: git@localhost:gitolite-admin
72   - base_path: /home/git/repositories/
  83 + repos_path: /home/git/repositories/
73 84 hooks_path: /home/git/.gitolite/hooks/
74   - gitolite_admin_key: gitlab
75   - git_user: git
  85 + admin_key: gitlab
76 86 upload_pack: true
77 87 receive_pack: true
78   - # host: localhost
  88 + ssh_user: git
  89 + ssh_host: localhost
  90 + # ssh_port: 22
79 91 # config_file: gitolite.conf
80   - # port: 22
81 92  
82   -# Git settings
83   -# Use default values unless you understand it
  93 +## Git settings
  94 +# CAUTION!
  95 +# Use the default values unless you really know what you are doing
84 96 git:
85   - path: /usr/bin/git
  97 + bin_path: /usr/bin/git
86 98 # Max size of git object like commit, in bytes
87 99 # This value can be increased if you have a very large commits
88   - git_max_size: 5242880 # 5.megabytes
  100 + max_size: 5242880 # 5.megabytes
89 101 # Git timeout to read commit, in seconds
90   - git_timeout: 10
  102 + timeout: 10
... ...
config/initializers/1_settings.rb
... ... @@ -2,23 +2,43 @@ class Settings &lt; Settingslogic
2 2 source "#{Rails.root}/config/gitlab.yml"
3 3  
4 4 class << self
  5 + # FIXME: Deprecated: remove for 4.1
5 6 def web_protocol
  7 + ActiveSupport::Deprecation.warn("Settings.web_protocol is deprecated and will be removed from GitLab 4.1", caller)
  8 + gitlab.protocol
  9 + rescue Settingslogic::MissingSetting
6 10 self.web['protocol'] ||= web.https ? "https" : "http"
7 11 end
8 12  
  13 + # FIXME: Deprecated: remove for 4.1
9 14 def web_host
  15 + ActiveSupport::Deprecation.warn("Settings.web_host is deprecated and will be removed from GitLab 4.1", caller)
  16 + gitlab.host
  17 + rescue Settingslogic::MissingSetting
10 18 self.web['host'] ||= 'localhost'
11 19 end
12 20  
  21 + # FIXME: Deprecated: remove for 4.1
13 22 def email_from
  23 + ActiveSupport::Deprecation.warn("Settings.email_from is deprecated and will be removed from GitLab 4.1", caller)
  24 + gitlab.email_from
  25 + rescue Settingslogic::MissingSetting
14 26 self.email['from'] ||= ("notify@" + web_host)
15 27 end
16 28  
  29 + # FIXME: Deprecated: remove for 4.1
17 30 def url
  31 + ActiveSupport::Deprecation.warn("Settings.url is deprecated and will be removed from GitLab 4.1", caller)
  32 + gitlab.url
  33 + rescue Settingslogic::MissingSetting
18 34 self['url'] ||= build_url
19 35 end
20 36  
  37 + # FIXME: Deprecated: remove for 4.1
21 38 def web_port
  39 + ActiveSupport::Deprecation.warn("Settings.web_port is deprecated and will be removed from GitLab 4.1", caller)
  40 + gitlab.port.to_i
  41 + rescue Settingslogic::MissingSetting
22 42 if web.https
23 43 web['port'] = 443
24 44 else
... ... @@ -26,11 +46,17 @@ class Settings &lt; Settingslogic
26 46 end.to_i
27 47 end
28 48  
  49 + # FIXME: Deprecated: remove for 4.1
29 50 def web_custom_port?
  51 + ActiveSupport::Deprecation.warn("Settings.web_custom_port? is deprecated and will be removed from GitLab 4.1", caller)
  52 + gitlab_on_non_standard_port?
  53 + rescue Settingslogic::MissingSetting
30 54 ![443, 80].include?(web_port)
31 55 end
32 56  
  57 + # FIXME: Deprecated: remove for 4.1
33 58 def build_url
  59 + ActiveSupport::Deprecation.warn("Settings.build_url is deprecated and will be removed from GitLab 4.1", caller)
34 60 if web_custom_port?
35 61 custom_port = ":#{web_port}"
36 62 else
... ... @@ -44,19 +70,35 @@ class Settings &lt; Settingslogic
44 70 ].join('')
45 71 end
46 72  
  73 + # FIXME: Deprecated: remove for 4.1
47 74 def ssh_port
  75 + ActiveSupport::Deprecation.warn("Settings.ssh_port is deprecated and will be removed from GitLab 4.1", caller)
  76 + gitolite.ssh_port
  77 + rescue Settingslogic::MissingSetting
48 78 git_host['port'] || 22
49 79 end
50 80  
  81 + # FIXME: Deprecated: remove for 4.1
51 82 def ssh_user
  83 + ActiveSupport::Deprecation.warn("Settings.ssh_user is deprecated and will be removed from GitLab 4.1", caller)
  84 + gitolite.ssh_user
  85 + rescue Settingslogic::MissingSetting
52 86 git_host['git_user'] || 'git'
53 87 end
54 88  
  89 + # FIXME: Deprecated: remove for 4.1
55 90 def ssh_host
  91 + ActiveSupport::Deprecation.warn("Settings.ssh_host is deprecated and will be removed from GitLab 4.1", caller)
  92 + gitolite.ssh_host
  93 + rescue Settingslogic::MissingSetting
56 94 git_host['host'] || web_host || 'localhost'
57 95 end
58 96  
  97 + # FIXME: Deprecated: remove for 4.1
59 98 def ssh_path
  99 + ActiveSupport::Deprecation.warn("Settings.ssh_path is deprecated and will be removed from GitLab 4.1", caller)
  100 + gitolite.ssh_path_prefix
  101 + rescue Settingslogic::MissingSetting
60 102 if ssh_port != 22
61 103 "ssh://#{ssh_user}@#{ssh_host}:#{ssh_port}/"
62 104 else
... ... @@ -64,15 +106,27 @@ class Settings &lt; Settingslogic
64 106 end
65 107 end
66 108  
  109 + # FIXME: Deprecated: remove for 4.1
67 110 def git_base_path
  111 + ActiveSupport::Deprecation.warn("Settings.git_base_path is deprecated and will be removed from GitLab 4.1", caller)
  112 + gitolite.repos_path
  113 + rescue Settingslogic::MissingSetting
68 114 git_host['base_path'] || '/home/git/repositories/'
69 115 end
70 116  
  117 + # FIXME: Deprecated: remove for 4.1
71 118 def git_hooks_path
  119 + ActiveSupport::Deprecation.warn("Settings.git_hooks_path is deprecated and will be removed from GitLab 4.1", caller)
  120 + gitolite.hooks_path
  121 + rescue Settingslogic::MissingSetting
72 122 git_host['hooks_path'] || '/home/git/share/gitolite/hooks/'
73 123 end
74 124  
  125 + # FIXME: Deprecated: remove for 4.1
75 126 def git_upload_pack
  127 + ActiveSupport::Deprecation.warn("Settings.git_upload_pack is deprecated and will be removed from GitLab 4.1", caller)
  128 + gitolite.upload_pack
  129 + rescue Settingslogic::MissingSetting
76 130 if git_host['upload_pack'] != false
77 131 true
78 132 else
... ... @@ -80,7 +134,11 @@ class Settings &lt; Settingslogic
80 134 end
81 135 end
82 136  
  137 + # FIXME: Deprecated: remove for 4.1
83 138 def git_receive_pack
  139 + ActiveSupport::Deprecation.warn("Settings.git_receive_pack is deprecated and will be removed from GitLab 4.1", caller)
  140 + gitolite.receive_pack
  141 + rescue Settingslogic::MissingSetting
84 142 if git_host['receive_pack'] != false
85 143 true
86 144 else
... ... @@ -88,71 +146,207 @@ class Settings &lt; Settingslogic
88 146 end
89 147 end
90 148  
  149 + # FIXME: Deprecated: remove for 4.1
91 150 def git_bin_path
  151 + ActiveSupport::Deprecation.warn("Settings.git_bin_path is deprecated and will be removed from GitLab 4.1", caller)
  152 + git.bin_path
  153 + rescue Settingslogic::MissingSetting
92 154 git['path'] || '/usr/bin/git'
93 155 end
94 156  
  157 + # FIXME: Deprecated: remove for 4.1
95 158 def git_max_size
  159 + ActiveSupport::Deprecation.warn("Settings.git_max_size is deprecated and will be removed from GitLab 4.1", caller)
  160 + git.max_size
  161 + rescue Settingslogic::MissingSetting
96 162 git['git_max_size'] || 5242880 # 5.megabytes
97 163 end
98 164  
  165 + # FIXME: Deprecated: remove for 4.1
99 166 def git_timeout
  167 + ActiveSupport::Deprecation.warn("Settings.git_timeout is deprecated and will be removed from GitLab 4.1", caller)
  168 + git.timeout
  169 + rescue Settingslogic::MissingSetting
100 170 git['git_timeout'] || 10
101 171 end
102 172  
  173 + # FIXME: Deprecated: remove for 4.1
103 174 def gitolite_admin_uri
  175 + ActiveSupport::Deprecation.warn("Settings.gitolite_admin_uri is deprecated and will be removed from GitLab 4.1", caller)
  176 + gitolite.admin_uri
  177 + rescue Settingslogic::MissingSetting
104 178 git_host['admin_uri'] || 'git@localhost:gitolite-admin'
105 179 end
106 180  
  181 + # FIXME: Deprecated: remove for 4.1
107 182 def gitolite_config_file
  183 + ActiveSupport::Deprecation.warn("Settings.gitolite_config_file is deprecated and will be removed from GitLab 4.1", caller)
  184 + gitolite.config_file
  185 + rescue Settingslogic::MissingSetting
108 186 git_host['config_file'] || 'gitolite.conf'
109 187 end
110 188  
  189 + # FIXME: Deprecated: remove for 4.1
111 190 def gitolite_admin_key
  191 + ActiveSupport::Deprecation.warn("Settings.gitolite_admin_key is deprecated and will be removed from GitLab 4.1", caller)
  192 + gitolite.admin_key
  193 + rescue Settingslogic::MissingSetting
112 194 git_host['gitolite_admin_key'] || 'gitlab'
113 195 end
114 196  
  197 + # FIXME: Deprecated: remove for 4.1
115 198 def default_projects_limit
  199 + ActiveSupport::Deprecation.warn("Settings.default_projects_limit is deprecated and will be removed from GitLab 4.1", caller)
  200 + gitlab.default_projects_limit
  201 + rescue Settingslogic::MissingSetting
116 202 app['default_projects_limit'] || 10
117 203 end
118 204  
  205 + # FIXME: Deprecated: remove for 4.1
119 206 def backup_path
120   - t = app['backup_path'] || "backups/"
121   - t = /^\//.match(t) ? t : Rails.root .join(t)
122   - t
  207 + ActiveSupport::Deprecation.warn("Settings.backup_path is deprecated and will be removed from GitLab 4.1", caller)
  208 + backup.path
  209 + rescue Settingslogic::MissingSetting
  210 + File.expand_path(app['backup_path'] || "backups/", Rails.root)
123 211 end
124 212  
  213 + # FIXME: Deprecated: remove for 4.1
125 214 def backup_keep_time
  215 + ActiveSupport::Deprecation.warn("Settings.backup_keep_time is deprecated and will be removed from GitLab 4.1", caller)
  216 + backup.keep_time
  217 + rescue Settingslogic::MissingSetting
126 218 app['backup_keep_time'] || 0
127 219 end
128 220  
  221 + # FIXME: Deprecated: remove for 4.1
129 222 def ldap_enabled?
130   - ldap && ldap['enabled']
  223 + ActiveSupport::Deprecation.warn("Settings.ldap_enabled? is deprecated and will be removed from GitLab 4.1", caller)
  224 + ldap.enabled
131 225 rescue Settingslogic::MissingSetting
132 226 false
133 227 end
134 228  
  229 + # FIXME: Deprecated: remove for 4.1
135 230 def omniauth_enabled?
136   - omniauth && omniauth['enabled']
  231 + ActiveSupport::Deprecation.warn("Settings.omniauth_enabled? is deprecated and will be removed from GitLab 4.1", caller)
  232 + omniauth.enabled
137 233 rescue Settingslogic::MissingSetting
138 234 false
139 235 end
140 236  
  237 + # FIXME: Deprecated: remove for 4.1
141 238 def omniauth_providers
142   - (omniauth_enabled? && omniauth['providers']) || []
  239 + ActiveSupport::Deprecation.warn("Settings.omniauth_providers is deprecated and will be removed from GitLab 4.1", caller)
  240 + omniauth.providers
  241 + rescue Settingslogic::MissingSetting
  242 + []
143 243 end
144 244  
  245 + # FIXME: Deprecated: remove for 4.1
145 246 def disable_gravatar?
  247 + ActiveSupport::Deprecation.warn("Settings.disable_gravatar? is deprecated and will be removed from GitLab 4.1", caller)
  248 + !gravatar.enabled
  249 + rescue Settingslogic::MissingSetting
146 250 app['disable_gravatar'] || false
147 251 end
148 252  
  253 + # FIXME: Deprecated: remove for 4.1
149 254 def gravatar_url
  255 + ActiveSupport::Deprecation.warn("Settings.gravatar_url is deprecated and will be removed from GitLab 4.1", caller)
  256 + gravatar.plain_url
  257 + rescue Settingslogic::MissingSetting
150 258 app['gravatar_url'] || 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
151 259 end
152 260  
  261 + # FIXME: Deprecated: remove for 4.1
153 262 def gravatar_ssl_url
  263 + ActiveSupport::Deprecation.warn("Settings.gravatar_ssl_url is deprecated and will be removed from GitLab 4.1", caller)
  264 + gravatar.ssl_url
  265 + rescue Settingslogic::MissingSetting
154 266 app['gravatar_ssl_url'] || 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
155 267 end
156 268  
  269 +
  270 +
  271 + def gitlab_on_non_standard_port?
  272 + ![443, 80].include?(gitlab.port.to_i)
  273 + end
  274 +
  275 + private
  276 +
  277 + def build_gitolite_ssh_path_prefix
  278 + if gitolite.ssh_port != 22
  279 + "ssh://#{gitolite.ssh_user}@#{gitolite.ssh_host}:#{gitolite.ssh_port}/"
  280 + else
  281 + "#{gitolite.ssh_user}@#{gitolite.ssh_host}:"
  282 + end
  283 + end
  284 +
  285 + def build_gitlab_url
  286 + if gitlab_on_non_standard_port?
  287 + custom_port = ":#{gitlab.port}"
  288 + else
  289 + custom_port = nil
  290 + end
  291 + [ gitlab.protocol,
  292 + "://",
  293 + gitlab.host,
  294 + custom_port
  295 + ].join('')
  296 + end
157 297 end
158 298 end
  299 +
  300 +
  301 +# Default settings
  302 +
  303 +# FIXME: Deprecated: remove for 4.1
  304 +# all Settings.web ...
  305 +# all Settings.app ...
  306 +# all Settings.email ...
  307 +# all Settings.git_host ...
  308 +Settings['pre_40_config'] ||= Settings['web'].present?
  309 +
  310 +Settings['ldap'] ||= Settingslogic.new({})
  311 +Settings.ldap['enabled'] ||= false
  312 +
  313 +Settings['omniauth'] ||= Settingslogic.new({})
  314 +Settings.omniauth['enabled'] ||= false
  315 +Settings.omniauth['providers'] ||= []
  316 +
  317 +Settings['gitlab'] ||= Settingslogic.new({})
  318 +Settings.gitlab['default_projects_limit'] ||= Settings.pre_40_config ? Settings.default_projects_limit : 10
  319 +Settings.gitlab['host'] ||= Settings.pre_40_config ? Settings.web_host : 'localhost'
  320 +Settings.gitlab['https'] ||= Settings.pre_40_config ? Settings.web.https : false
  321 +Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80
  322 +Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
  323 +Settings.gitlab['email_from'] ||= Settings.pre_40_config ? Settings.email_from : "gitlab@#{Settings.gitlab.host}"
  324 +Settings.gitlab['url'] ||= Settings.pre_40_config ? Settings.url : Settings.send(:build_gitlab_url)
  325 +
  326 +Settings['gravatar'] ||= Settingslogic.new({})
  327 +Settings.gravatar['enabled'] ||= Settings.pre_40_config ? !Settings.disable_gravatar? : true
  328 +Settings.gravatar['plain_url'] ||= Settings.pre_40_config ? Settings.gravatar_url : 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
  329 +Settings.gravatar['ssl_url'] ||= Settings.pre_40_config ? Settings.gravatar_ssl_url : 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
  330 +
  331 +Settings['gitolite'] ||= Settingslogic.new({})
  332 +Settings.gitolite['admin_key'] ||= Settings.pre_40_config ? Settings.gitolite_admin_key : 'gitlab'
  333 +Settings.gitolite['admin_uri'] ||= Settings.pre_40_config ? Settings.gitolite_admin_uri : 'git@localhost:gitolite-admin'
  334 +Settings.gitolite['config_file'] ||= Settings.pre_40_config ? Settings.gitolite_config_file : 'gitolite.conf'
  335 +Settings.gitolite['hooks_path'] ||= Settings.pre_40_config ? Settings.git_hooks_path : '/home/git/share/gitolite/hooks/'
  336 +Settings.gitolite['receive_pack'] ||= Settings.pre_40_config ? Settings.git_receive_pack : (Settings.gitolite['receive_pack'] != false)
  337 +Settings.gitolite['repos_path'] ||= Settings.pre_40_config ? Settings.git_base_path : '/home/git/repositories/'
  338 +Settings.gitolite['upload_pack'] ||= Settings.pre_40_config ? Settings.git_upload_pack : (Settings.gitolite['upload_pack'] != false)
  339 +Settings.gitolite['ssh_host'] ||= Settings.pre_40_config ? Settings.ssh_host : (Settings.gitlab.host || 'localhost')
  340 +Settings.gitolite['ssh_port'] ||= Settings.pre_40_config ? Settings.ssh_port : 22
  341 +Settings.gitolite['ssh_user'] ||= Settings.pre_40_config ? Settings.ssh_user : 'git'
  342 +Settings.gitolite['ssh_path_prefix'] ||= Settings.pre_40_config ? Settings.ssh_path : Settings.send(:build_gitolite_ssh_path_prefix)
  343 +
  344 +Settings['backup'] ||= Settingslogic.new({})
  345 +Settings.backup['keep_time'] ||= Settings.pre_40_config ? Settings.backup_keep_time : 0
  346 +Settings.backup['path'] = Settings.pre_40_config ? Settings.backup_path : File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
  347 +
  348 +Settings['git'] ||= Settingslogic.new({})
  349 +Settings.git['max_size'] ||= Settings.pre_40_config ? Settings.git_max_size : 5242880 # 5.megabytes
  350 +Settings.git['bin_path'] ||= Settings.pre_40_config ? Settings.git_bin_path : '/usr/bin/git'
  351 +Settings.git['timeout'] ||= Settings.pre_40_config ? Settings.git_timeout : 10
  352 +Settings.git['path'] ||= Settings.git.bin_path # FIXME: Deprecated: remove for 4.1
... ...
config/initializers/3_grit_ext.rb
1 1 require 'grit'
2 2 require 'pygments'
3 3  
4   -Grit::Git.git_timeout = Gitlab.config.git_timeout
5   -Grit::Git.git_max_size = Gitlab.config.git_max_size
  4 +Grit::Git.git_timeout = Gitlab.config.git.timeout
  5 +Grit::Git.git_max_size = Gitlab.config.git.max_size
6 6  
7 7 Grit::Blob.class_eval do
8 8 include Linguist::BlobHelper
... ...
config/initializers/devise.rb
... ... @@ -4,7 +4,7 @@ Devise.setup do |config|
4 4 # ==> Mailer Configuration
5 5 # Configure the e-mail address which will be shown in Devise::Mailer,
6 6 # note that it will be overwritten if you use your own mailer class with default "from" parameter.
7   - config.mailer_sender = Gitlab.config.email_from
  7 + config.mailer_sender = Gitlab.config.gitlab.email_from
8 8  
9 9 # Configure the class responsible to send e-mails.
10 10 # config.mailer = "Devise::Mailer"
... ... @@ -205,20 +205,18 @@ Devise.setup do |config|
205 205 # manager.default_strategies(:scope => :user).unshift :some_external_strategy
206 206 # end
207 207  
208   - gl = Gitlab.config
209   -
210   - if gl.ldap_enabled?
  208 + if Gitlab.config.ldap.enabled
211 209 config.omniauth :ldap,
212   - :host => gl.ldap['host'],
213   - :base => gl.ldap['base'],
214   - :uid => gl.ldap['uid'],
215   - :port => gl.ldap['port'],
216   - :method => gl.ldap['method'],
217   - :bind_dn => gl.ldap['bind_dn'],
218   - :password => gl.ldap['password']
  210 + :host => Gitlab.config.ldap['host'],
  211 + :base => Gitlab.config.ldap['base'],
  212 + :uid => Gitlab.config.ldap['uid'],
  213 + :port => Gitlab.config.ldap['port'],
  214 + :method => Gitlab.config.ldap['method'],
  215 + :bind_dn => Gitlab.config.ldap['bind_dn'],
  216 + :password => Gitlab.config.ldap['password']
219 217 end
220 218  
221   - gl.omniauth_providers.each do |gl_provider|
222   - config.omniauth gl_provider['name'].to_sym, gl_provider['app_id'], gl_provider['app_secret']
  219 + Gitlab.config.omniauth.providers.each do |provider|
  220 + config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret']
223 221 end
224 222 end
... ...
config/routes.rb
... ... @@ -14,10 +14,10 @@ Gitlab::Application.routes.draw do
14 14  
15 15 # Enable Grack support
16 16 mount Grack::Bundle.new({
17   - git_path: Gitlab.config.git_bin_path,
18   - project_root: Gitlab.config.git_base_path,
19   - upload_pack: Gitlab.config.git_upload_pack,
20   - receive_pack: Gitlab.config.git_receive_pack
  17 + git_path: Gitlab.config.git.bin_path,
  18 + project_root: Gitlab.config.gitolite.repos_path,
  19 + upload_pack: Gitlab.config.gitolite.upload_pack,
  20 + receive_pack: Gitlab.config.gitolite.receive_pack
21 21 }), at: '/:path', constraints: { path: /[-\/\w\.-]+\.git/ }
22 22  
23 23 #
... ...
features/support/env.rb
... ... @@ -33,9 +33,9 @@ DatabaseCleaner.strategy = :truncation
33 33  
34 34 Spinach.hooks.before_scenario do
35 35 # Use tmp dir for FS manipulations
36   - Gitlab.config.stub(git_base_path: Rails.root.join('tmp', 'test-git-base-path'))
37   - FileUtils.rm_rf Gitlab.config.git_base_path
38   - FileUtils.mkdir_p Gitlab.config.git_base_path
  36 + Gitlab.config.gitolite.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
  37 + FileUtils.rm_rf Gitlab.config.gitolite.repos_path
  38 + FileUtils.mkdir_p Gitlab.config.gitolite.repos_path
39 39 end
40 40  
41 41 Spinach.hooks.after_scenario do
... ...
lib/gitlab/auth.rb
... ... @@ -38,7 +38,7 @@ module Gitlab
38 38 email: email,
39 39 password: password,
40 40 password_confirmation: password,
41   - projects_limit: Gitlab.config.default_projects_limit,
  41 + projects_limit: Gitlab.config.gitlab.default_projects_limit,
42 42 }, as: :admin)
43 43 if Gitlab.config.omniauth['block_auto_created_users'] && !ldap
44 44 @user.blocked = true
... ...
lib/gitlab/backend/gitolite.rb
... ... @@ -38,7 +38,7 @@ module Gitlab
38 38 end
39 39  
40 40 def url_to_repo path
41   - Gitlab.config.ssh_path + "#{path}.git"
  41 + Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
42 42 end
43 43  
44 44 def enable_automerge
... ...
lib/gitlab/backend/gitolite_config.rb
... ... @@ -16,7 +16,7 @@ module Gitlab
16 16 def ga_repo
17 17 @ga_repo ||= ::Gitolite::GitoliteAdmin.new(
18 18 File.join(config_tmp_dir,'gitolite'),
19   - conf: Gitlab.config.gitolite_config_file
  19 + conf: Gitlab.config.gitolite.config_file
20 20 )
21 21 end
22 22  
... ... @@ -167,7 +167,7 @@ module Gitlab
167 167 # Enable access to all repos for gitolite admin.
168 168 # We use it for accept merge request feature
169 169 def admin_all_repo
170   - owner_name = Gitlab.config.gitolite_admin_key
  170 + owner_name = Gitlab.config.gitolite.admin_key
171 171  
172 172 # @ALL repos premission for gitolite owner
173 173 repo_name = "@all"
... ... @@ -189,7 +189,7 @@ module Gitlab
189 189  
190 190 def pull tmp_dir
191 191 Dir.mkdir tmp_dir
192   - `git clone #{Gitlab.config.gitolite_admin_uri} #{tmp_dir}/gitolite`
  192 + `git clone #{Gitlab.config.gitolite.admin_uri} #{tmp_dir}/gitolite`
193 193  
194 194 unless File.exists?(File.join(tmp_dir, 'gitolite', 'conf', 'gitolite.conf'))
195 195 raise PullError, "unable to clone gitolite-admin repo"
... ...
lib/gitlab/project_mover.rb
... ... @@ -15,10 +15,10 @@ module Gitlab
15 15  
16 16 def execute
17 17 # Create new dir if missing
18   - new_dir_path = File.join(Gitlab.config.git_base_path, new_dir)
  18 + new_dir_path = File.join(Gitlab.config.gitolite.repos_path, new_dir)
19 19 system("mkdir -m 770 #{new_dir_path}") unless File.exists?(new_dir_path)
20 20  
21   - old_path = File.join(Gitlab.config.git_base_path, old_dir, "#{project.path}.git")
  21 + old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git")
22 22 new_path = File.join(new_dir_path, "#{project.path}.git")
23 23  
24 24 if File.exists? new_path
... ...
lib/tasks/gitlab/activate_namespaces.rake
... ... @@ -27,7 +27,7 @@ namespace :gitlab do
27 27 end
28 28  
29 29 print "\n\nMove projects from groups under groups dirs:".yellow
30   - git_path = Gitlab.config.git_base_path
  30 + git_path = Gitlab.config.gitolite.repos_path
31 31  
32 32 Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project|
33 33 next unless project.group
... ...
lib/tasks/gitlab/backup.rake
... ... @@ -8,7 +8,7 @@ namespace :gitlab do
8 8 Rake::Task["gitlab:app:db_dump"].invoke
9 9 Rake::Task["gitlab:app:repo_dump"].invoke
10 10  
11   - Dir.chdir(Gitlab.config.backup_path)
  11 + Dir.chdir(Gitlab.config.backup.path)
12 12  
13 13 # saving additional informations
14 14 s = {}
... ... @@ -17,7 +17,7 @@ namespace :gitlab do
17 17 s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"")
18 18 s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"")
19 19  
20   - File.open("#{Gitlab.config.backup_path}/backup_information.yml", "w+") do |file|
  20 + File.open("#{Gitlab.config.backup.path}/backup_information.yml", "w+") do |file|
21 21 file << s.to_yaml.gsub(/^---\n/,'')
22 22 end
23 23  
... ... @@ -39,10 +39,10 @@ namespace :gitlab do
39 39  
40 40 # delete backups
41 41 print "Deleting old backups... "
42   - if Gitlab.config.backup_keep_time > 0
  42 + if Gitlab.config.backup.keep_time > 0
43 43 file_list = Dir.glob("*_gitlab_backup.tar").map { |f| f.split(/_/).first.to_i }
44 44 file_list.sort.each do |timestamp|
45   - if Time.at(timestamp) < (Time.now - Gitlab.config.backup_keep_time)
  45 + if Time.at(timestamp) < (Time.now - Gitlab.config.backup.keep_time)
46 46 %x{rm #{timestamp}_gitlab_backup.tar}
47 47 end
48 48 end
... ... @@ -55,7 +55,7 @@ namespace :gitlab do
55 55 # Restore backup of GitLab system
56 56 desc "GITLAB | Restore a previously created backup"
57 57 task :backup_restore => :environment do
58   - Dir.chdir(Gitlab.config.backup_path)
  58 + Dir.chdir(Gitlab.config.backup.path)
59 59  
60 60 # check for existing backups in the backup dir
61 61 file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i }
... ... @@ -111,7 +111,7 @@ namespace :gitlab do
111 111 ################################# REPOSITORIES #################################
112 112  
113 113 task :repo_dump => :environment do
114   - backup_path_repo = File.join(Gitlab.config.backup_path, "repositories")
  114 + backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
115 115 FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo)
116 116 puts "Dumping repositories:"
117 117 project = Project.all.map { |n| [n.path, n.path_to_repo] }
... ... @@ -127,7 +127,7 @@ namespace :gitlab do
127 127 end
128 128  
129 129 task :repo_restore => :environment do
130   - backup_path_repo = File.join(Gitlab.config.backup_path, "repositories")
  130 + backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
131 131 puts "Restoring repositories:"
132 132 project = Project.all.map { |n| [n.path, n.path_to_repo] }
133 133 project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
... ... @@ -136,8 +136,8 @@ namespace :gitlab do
136 136 FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff
137 137 if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1")
138 138 permission_commands = [
139   - "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}",
140   - "sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}"
  139 + "sudo chmod -R g+rwX #{Gitlab.config.gitolite.repos_path}",
  140 + "sudo chown -R #{Gitlab.config.gitolite.ssh_user}:#{Gitlab.config.gitolite.ssh_user} #{Gitlab.config.gitolite.repos_path}"
141 141 ]
142 142 permission_commands.each { |command| Kernel.system(command) }
143 143 puts "[DONE]".green
... ... @@ -150,7 +150,7 @@ namespace :gitlab do
150 150 ###################################### DB ######################################
151 151  
152 152 task :db_dump => :environment do
153   - backup_path_db = File.join(Gitlab.config.backup_path, "db")
  153 + backup_path_db = File.join(Gitlab.config.backup.path, "db")
154 154 FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db)
155 155  
156 156 puts "Dumping database tables:"
... ... @@ -170,7 +170,7 @@ namespace :gitlab do
170 170 end
171 171  
172 172 task :db_restore=> :environment do
173   - backup_path_db = File.join(Gitlab.config.backup_path, "db")
  173 + backup_path_db = File.join(Gitlab.config.backup.path, "db")
174 174  
175 175 puts "Restoring database tables:"
176 176 Rake::Task["db:reset"].invoke
... ...
lib/tasks/gitlab/check.rake
... ... @@ -90,7 +90,7 @@ namespace :gitlab do
90 90 end
91 91  
92 92 def check_gitlab_config_not_outdated
93   - print "GitLab config not outdated? ... "
  93 + print "GitLab config outdated? ... "
94 94  
95 95 gitlab_config_file = Rails.root.join("config", "gitlab.yml")
96 96 unless File.exists?(gitlab_config_file)
... ... @@ -98,11 +98,12 @@ namespace :gitlab do
98 98 end
99 99  
100 100 # omniauth or ldap could have been deleted from the file
101   - if File.read(gitlab_config_file) =~ /^web:/
102   - puts "yes".green
  101 + unless Gitlab.config.pre_40_config
  102 + puts "no".green
103 103 else
104   - puts "no".red
  104 + puts "yes".red
105 105 try_fixing_it(
  106 + "Backup your config/gitlab.yml",
106 107 "Copy config/gitlab.yml.example to config/gitlab.yml",
107 108 "Update config/gitlab.yml to match your setup"
108 109 )
... ... @@ -268,7 +269,7 @@ namespace :gitlab do
268 269  
269 270 options = {
270 271 "user.name" => "GitLab",
271   - "user.email" => Gitlab.config.email_from
  272 + "user.email" => Gitlab.config.gitlab.email_from
272 273 }
273 274 correct_options = options.map do |name, value|
274 275 run("git config --global --get #{name}").try(:squish) == value
... ... @@ -290,7 +291,7 @@ namespace :gitlab do
290 291 end
291 292  
292 293 def check_gitlab_in_git_group
293   - gitolite_ssh_user = Gitlab.config.ssh_user
  294 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
294 295 print "gitlab user is in #{gitolite_ssh_user} group? ... "
295 296  
296 297 if run_and_match("id -rnG", /\Wgit\W/)
... ... @@ -309,10 +310,10 @@ namespace :gitlab do
309 310  
310 311 # see https://github.com/gitlabhq/gitlabhq/issues/1059
311 312 def check_issue_1056_shell_profile_error
312   - gitolite_ssh_user = Gitlab.config.ssh_user
  313 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
313 314 print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
314 315  
315   - profile_file = File.expand_path("~#{Gitlab.config.ssh_user}/.profile")
  316 + profile_file = File.expand_path("~#{Gitlab.config.gitolite.ssh_user}/.profile")
316 317  
317 318 unless File.read(profile_file) =~ /^-e PATH/
318 319 puts "yes".green
... ... @@ -414,7 +415,7 @@ namespace :gitlab do
414 415  
415 416 test_path = "/tmp/gitlab_gitolite_admin_test"
416 417 FileUtils.rm_rf(test_path)
417   - `git clone -q #{Gitlab.config.gitolite_admin_uri} #{test_path}`
  418 + `git clone -q #{Gitlab.config.gitolite.admin_uri} #{test_path}`
418 419 raise unless $?.success?
419 420  
420 421 puts "yes".green
... ... @@ -423,7 +424,7 @@ namespace :gitlab do
423 424 try_fixing_it(
424 425 "Make sure the \"admin_uri\" is set correctly in config/gitlab.yml",
425 426 "Try cloning it yourself with:",
426   - " git clone -q #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite-admin",
  427 + " git clone -q #{Gitlab.config.gitolite.admin_uri} /tmp/gitolite-admin",
427 428 "Make sure Gitolite is installed correctly."
428 429 )
429 430 for_more_information(
... ... @@ -452,7 +453,7 @@ namespace :gitlab do
452 453 puts "no".red
453 454 try_fixing_it(
454 455 "Try committing to it yourself with:",
455   - " git clone -q #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite-admin",
  456 + " git clone -q #{Gitlab.config.gitolite.admin_uri} /tmp/gitolite-admin",
456 457 " touch foo",
457 458 " git add foo",
458 459 " git commit -m \"foo\"",
... ... @@ -469,7 +470,7 @@ namespace :gitlab do
469 470 def check_dot_gitolite_exists
470 471 print "Config directory exists? ... "
471 472  
472   - gitolite_config_path = File.expand_path("~#{Gitlab.config.ssh_user}/.gitolite")
  473 + gitolite_config_path = File.expand_path("~#{Gitlab.config.gitolite.ssh_user}/.gitolite")
473 474  
474 475 if File.directory?(gitolite_config_path)
475 476 puts "yes".green
... ... @@ -490,7 +491,7 @@ namespace :gitlab do
490 491 def check_dot_gitolite_permissions
491 492 print "Config directory access is drwxr-x---? ... "
492 493  
493   - gitolite_config_path = File.expand_path("~#{Gitlab.config.ssh_user}/.gitolite")
  494 + gitolite_config_path = File.expand_path("~#{Gitlab.config.gitolite.ssh_user}/.gitolite")
494 495 unless File.exists?(gitolite_config_path)
495 496 puts "can't check because of previous errors".magenta
496 497 return
... ... @@ -512,7 +513,7 @@ namespace :gitlab do
512 513 end
513 514  
514 515 def check_dot_gitolite_user_and_group
515   - gitolite_ssh_user = Gitlab.config.ssh_user
  516 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
516 517 print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... "
517 518  
518 519 gitolite_config_path = File.expand_path("~#{gitolite_ssh_user}/.gitolite")
... ... @@ -615,9 +616,9 @@ namespace :gitlab do
615 616 print "post-receive hook exists? ... "
616 617  
617 618 hook_file = "post-receive"
618   - gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
  619 + gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
619 620 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
620   - gitolite_ssh_user = Gitlab.config.ssh_user
  621 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
621 622  
622 623 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
623 624  
... ... @@ -639,10 +640,10 @@ namespace :gitlab do
639 640 print "post-receive hook up-to-date? ... "
640 641  
641 642 hook_file = "post-receive"
642   - gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
  643 + gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
643 644 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
644 645 gitolite_hook_content = File.read(gitolite_hook_file)
645   - gitolite_ssh_user = Gitlab.config.ssh_user
  646 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
646 647  
647 648 unless File.exists?(gitolite_hook_file)
648 649 puts "can't check because of previous errors".magenta
... ... @@ -669,7 +670,7 @@ namespace :gitlab do
669 670 def check_repo_base_exists
670 671 print "Repo base directory exists? ... "
671 672  
672   - repo_base_path = Gitlab.config.git_base_path
  673 + repo_base_path = Gitlab.config.gitolite.repos_path
673 674  
674 675 if File.exists?(repo_base_path)
675 676 puts "yes".green
... ... @@ -691,7 +692,7 @@ namespace :gitlab do
691 692 def check_repo_base_permissions
692 693 print "Repo base access is drwsrws---? ... "
693 694  
694   - repo_base_path = Gitlab.config.git_base_path
  695 + repo_base_path = Gitlab.config.gitolite.repos_path
695 696 unless File.exists?(repo_base_path)
696 697 puts "can't check because of previous errors".magenta
697 698 return
... ... @@ -713,10 +714,10 @@ namespace :gitlab do
713 714 end
714 715  
715 716 def check_repo_base_user_and_group
716   - gitolite_ssh_user = Gitlab.config.ssh_user
  717 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
717 718 print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_ssh_user}? ... "
718 719  
719   - repo_base_path = Gitlab.config.git_base_path
  720 + repo_base_path = Gitlab.config.gitolite.repos_path
720 721 unless File.exists?(repo_base_path)
721 722 puts "can't check because of previous errors".magenta
722 723 return
... ... @@ -777,9 +778,9 @@ namespace :gitlab do
777 778 print "post-receive hooks in repos are links: ... "
778 779  
779 780 hook_file = "post-receive"
780   - gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
  781 + gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
781 782 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
782   - gitolite_ssh_user = Gitlab.config.ssh_user
  783 + gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
783 784  
784 785 unless File.exists?(gitolite_hook_file)
785 786 puts "can't check because of previous errors".magenta
... ... @@ -828,7 +829,7 @@ namespace :gitlab do
828 829 ########################
829 830  
830 831 def gitolite_home
831   - File.expand_path("~#{Gitlab.config.ssh_user}")
  832 + File.expand_path("~#{Gitlab.config.gitolite.ssh_user}")
832 833 end
833 834  
834 835 def gitolite_version
... ...
lib/tasks/gitlab/import.rake
... ... @@ -12,7 +12,7 @@ namespace :gitlab do
12 12 desc "GITLAB | Import bare repositories from git_host -> base_path into GitLab project instance"
13 13 task :repos => :environment do
14 14  
15   - git_base_path = Gitlab.config.git_base_path
  15 + git_base_path = Gitlab.config.gitolite.repos_path
16 16 repos_to_import = Dir.glob(git_base_path + '/*')
17 17  
18 18 repos_to_import.each do |repo_path|
... ...
lib/tasks/gitlab/info.rake
... ... @@ -46,7 +46,7 @@ namespace :gitlab do
46 46 http_clone_url = project.http_url_to_repo
47 47 ssh_clone_url = project.ssh_url_to_repo
48 48  
49   - omniauth_providers = Gitlab.config.omniauth_providers
  49 + omniauth_providers = Gitlab.config.omniauth.providers
50 50 omniauth_providers.map! { |provider| provider['name'] }
51 51  
52 52 puts ""
... ... @@ -55,17 +55,17 @@ namespace :gitlab do
55 55 puts "Revision:\t#{Gitlab::Revision}"
56 56 puts "Directory:\t#{Rails.root}"
57 57 puts "DB Adapter:\t#{database_adapter}"
58   - puts "URL:\t\t#{Gitlab.config.url}"
  58 + puts "URL:\t\t#{Gitlab.config.gitlab.url}"
59 59 puts "HTTP Clone URL:\t#{http_clone_url}"
60 60 puts "SSH Clone URL:\t#{ssh_clone_url}"
61   - puts "Using LDAP:\t#{Gitlab.config.ldap_enabled? ? "yes".green : "no"}"
62   - puts "Using Omniauth:\t#{Gitlab.config.omniauth_enabled? ? "yes".green : "no"}"
63   - puts "Omniauth Providers: #{omniauth_providers.map(&:magenta).join(', ')}" if Gitlab.config.omniauth_enabled?
  61 + puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".green : "no"}"
  62 + puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".green : "no"}"
  63 + puts "Omniauth Providers: #{omniauth_providers.map(&:magenta).join(', ')}" if Gitlab.config.omniauth.enabled
64 64  
65 65  
66 66  
67 67 # check Gitolite version
68   - gitolite_version_file = "#{Gitlab.config.git_base_path}/../gitolite/src/VERSION"
  68 + gitolite_version_file = "#{Gitlab.config.gitolite.repos_path}/../gitolite/src/VERSION"
69 69 if File.exists?(gitolite_version_file) && File.readable?(gitolite_version_file)
70 70 gitolite_version = File.read(gitolite_version_file)
71 71 end
... ... @@ -73,11 +73,11 @@ namespace :gitlab do
73 73 puts ""
74 74 puts "Gitolite information".yellow
75 75 puts "Version:\t#{gitolite_version || "unknown".red}"
76   - puts "Admin URI:\t#{Gitlab.config.gitolite_admin_uri}"
77   - puts "Admin Key:\t#{Gitlab.config.gitolite_admin_key}"
78   - puts "Repositories:\t#{Gitlab.config.git_base_path}"
79   - puts "Hooks:\t\t#{Gitlab.config.git_hooks_path}"
80   - puts "Git:\t\t#{Gitlab.config.git.path}"
  76 + puts "Admin URI:\t#{Gitlab.config.gitolite.admin_uri}"
  77 + puts "Admin Key:\t#{Gitlab.config.gitolite.admin_key}"
  78 + puts "Repositories:\t#{Gitlab.config.gitolite.repos_path}"
  79 + puts "Hooks:\t\t#{Gitlab.config.gitolite.hooks_path}"
  80 + puts "Git:\t\t#{Gitlab.config.git.bin_path}"
81 81  
82 82 end
83 83  
... ...
spec/helpers/application_helper_spec.rb
... ... @@ -43,7 +43,7 @@ describe ApplicationHelper do
43 43 let(:user_email) { 'user@email.com' }
44 44  
45 45 it "should return a generic avatar path when Gravatar is disabled" do
46   - Gitlab.config.stub(:disable_gravatar?).and_return(true)
  46 + Gitlab.config.gravatar.stub(:enabled).and_return(false)
47 47 gravatar_icon(user_email).should == 'no_avatar.png'
48 48 end
49 49  
... ... @@ -63,7 +63,7 @@ describe ApplicationHelper do
63 63  
64 64 it "should return custom gravatar path when gravatar_url is set" do
65 65 stub!(:request).and_return(double(:ssl? => false))
66   - Gitlab.config.stub(:gravatar_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
  66 + Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
67 67 gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
68 68 end
69 69  
... ...
spec/lib/gitolite_spec.rb
... ... @@ -16,7 +16,7 @@ describe Gitlab::Gitolite do
16 16 it { should respond_to :create_repository }
17 17 it { should respond_to :remove_repository }
18 18  
19   - it { gitolite.url_to_repo('diaspora').should == Gitlab.config.ssh_path + "diaspora.git" }
  19 + it { gitolite.url_to_repo('diaspora').should == Gitlab.config.gitolite.ssh_path_prefix + "diaspora.git" }
20 20  
21 21 it "should call config update" do
22 22 gitolite_config.should_receive(:update_project!)
... ...
spec/lib/project_mover_spec.rb
... ... @@ -6,7 +6,7 @@ describe Gitlab::ProjectMover do
6 6 before do
7 7 FileUtils.rm_rf base_path if File.exists? base_path
8 8  
9   - Gitlab.config.stub(git_base_path: base_path)
  9 + Gitlab.config.gitolite.stub(repos_path: base_path)
10 10  
11 11 @project = create(:project)
12 12 end
... ...
spec/models/project_hooks_spec.rb
... ... @@ -108,7 +108,7 @@ describe Project, &quot;Hooks&quot; do
108 108 it { should include(id: @commit.id) }
109 109 it { should include(message: @commit.safe_message) }
110 110 it { should include(timestamp: @commit.date.xmlschema) }
111   - it { should include(url: "#{Gitlab.config.url}/#{project.code}/commit/#{@commit.id}") }
  111 + it { should include(url: "#{Gitlab.config.gitlab.url}/#{project.code}/commit/#{@commit.id}") }
112 112  
113 113 context "with a author" do
114 114 subject { @data[:commits].first[:author] }
... ...
spec/models/project_spec.rb
... ... @@ -148,7 +148,7 @@ describe Project do
148 148  
149 149 it "should return valid url to repo" do
150 150 project = Project.new(path: "somewhere")
151   - project.url_to_repo.should == Gitlab.config.ssh_path + "somewhere.git"
  151 + project.url_to_repo.should == Gitlab.config.gitolite.ssh_path_prefix + "somewhere.git"
152 152 end
153 153  
154 154 it "should return path to repo" do
... ... @@ -158,7 +158,7 @@ describe Project do
158 158  
159 159 it "returns the full web URL for this repo" do
160 160 project = Project.new(path: "somewhere")
161   - project.web_url.should == "#{Gitlab.config.url}/somewhere"
  161 + project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere"
162 162 end
163 163  
164 164 describe "last_activity methods" do
... ...
spec/spec_helper.rb
... ... @@ -42,8 +42,8 @@ RSpec.configure do |config|
42 42 # ActiveRecord::Base.observers.enable(:all)
43 43  
44 44 # Use tmp dir for FS manipulations
45   - Gitlab.config.stub(git_base_path: Rails.root.join('tmp', 'test-git-base-path'))
46   - FileUtils.rm_rf Gitlab.config.git_base_path
47   - FileUtils.mkdir_p Gitlab.config.git_base_path
  45 + Gitlab.config.gitolite.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
  46 + FileUtils.rm_rf Gitlab.config.gitolite.repos_path
  47 + FileUtils.mkdir_p Gitlab.config.gitolite.repos_path
48 48 end
49 49 end
... ...
spec/workers/post_receive_spec.rb
... ... @@ -39,6 +39,6 @@ describe PostReceive do
39 39 end
40 40  
41 41 def pwd(project)
42   - File.join(Gitlab.config.git_base_path, project.path_with_namespace)
  42 + File.join(Gitlab.config.gitolite.repos_path, project.path_with_namespace)
43 43 end
44 44 end
... ...