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,7 +30,7 @@ class Admin::UsersController < AdminController
30 30
31 31
32 def new 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 end 34 end
35 35
36 def edit 36 def edit
app/controllers/omniauth_callbacks_controller.rb
1 class OmniauthCallbacksController < Devise::OmniauthCallbacksController 1 class OmniauthCallbacksController < Devise::OmniauthCallbacksController
2 - Gitlab.config.omniauth_providers.each do |provider| 2 + Gitlab.config.omniauth.providers.each do |provider|
3 define_method provider['name'] do 3 define_method provider['name'] do
4 handle_omniauth 4 handle_omniauth
5 end 5 end
app/helpers/application_helper.rb
@@ -34,10 +34,10 @@ module ApplicationHelper @@ -34,10 +34,10 @@ module ApplicationHelper
34 def gravatar_icon(user_email = '', size = nil) 34 def gravatar_icon(user_email = '', size = nil)
35 size = 40 if size.nil? || size <= 0 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 'no_avatar.png' 38 'no_avatar.png'
39 else 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 user_email.strip! 41 user_email.strip!
42 sprintf(gravatar_url, {:hash => Digest::MD5.hexdigest(user_email.downcase), :email => URI.escape(user_email), :size => size}) 42 sprintf(gravatar_url, {:hash => Digest::MD5.hexdigest(user_email.downcase), :email => URI.escape(user_email), :size => size})
43 end 43 end
@@ -48,7 +48,7 @@ module ApplicationHelper @@ -48,7 +48,7 @@ module ApplicationHelper
48 end 48 end
49 49
50 def web_app_url 50 def web_app_url
51 - "#{request_protocol}://#{Gitlab.config.web_host}/" 51 + "#{request_protocol}://#{Gitlab.config.gitlab.host}/"
52 end 52 end
53 53
54 def last_commit(project) 54 def last_commit(project)
app/mailers/notify.rb
@@ -3,11 +3,11 @@ class Notify &lt; ActionMailer::Base @@ -3,11 +3,11 @@ class Notify &lt; ActionMailer::Base
3 add_template_helper ApplicationHelper 3 add_template_helper ApplicationHelper
4 add_template_helper GitlabMarkdownHelper 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,14 +48,14 @@ class Namespace &lt; ActiveRecord::Base
48 end 48 end
49 49
50 def ensure_dir_exist 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 system("mkdir -m 770 #{namespace_dir_path}") unless File.exists?(namespace_dir_path) 52 system("mkdir -m 770 #{namespace_dir_path}") unless File.exists?(namespace_dir_path)
53 end 53 end
54 54
55 def move_dir 55 def move_dir
56 if path_changed? 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 if File.exists?(new_path) 59 if File.exists?(new_path)
60 raise "Already exists" 60 raise "Already exists"
61 end 61 end
@@ -64,7 +64,7 @@ class Namespace &lt; ActiveRecord::Base @@ -64,7 +64,7 @@ class Namespace &lt; ActiveRecord::Base
64 end 64 end
65 65
66 def rm_dir 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 system("rm -rf #{dir_path}") 68 system("rm -rf #{dir_path}")
69 end 69 end
70 end 70 end
app/models/project.rb
@@ -195,7 +195,7 @@ class Project &lt; ActiveRecord::Base @@ -195,7 +195,7 @@ class Project &lt; ActiveRecord::Base
195 end 195 end
196 196
197 def web_url 197 def web_url
198 - [Gitlab.config.url, path_with_namespace].join("/") 198 + [Gitlab.config.gitlab.url, path_with_namespace].join("/")
199 end 199 end
200 200
201 def common_notes 201 def common_notes
app/roles/push_observer.rb
@@ -114,7 +114,7 @@ module PushObserver @@ -114,7 +114,7 @@ module PushObserver
114 id: commit.id, 114 id: commit.id,
115 message: commit.safe_message, 115 message: commit.safe_message,
116 timestamp: commit.date.xmlschema, 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 author: { 118 author: {
119 name: commit.author_name, 119 name: commit.author_name,
120 email: commit.author_email 120 email: commit.author_email
app/roles/repository.rb
@@ -97,7 +97,7 @@ module Repository @@ -97,7 +97,7 @@ module Repository
97 end 97 end
98 98
99 def path_to_repo 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 end 101 end
102 102
103 def namespace_dir 103 def namespace_dir
@@ -199,7 +199,7 @@ module Repository @@ -199,7 +199,7 @@ module Repository
199 end 199 end
200 200
201 def http_url_to_repo 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 end 203 end
204 204
205 # Check if current branch name is marked as protected in the system 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,7 +22,7 @@
22 %b 22 %b
23 Path: 23 Path:
24 %td 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 %tr 26 %tr
27 %td 27 %td
28 %b 28 %b
app/views/errors/gitolite.html.haml
@@ -21,5 +21,5 @@ @@ -21,5 +21,5 @@
21 Permissions: 21 Permissions:
22 %pre 22 %pre
23 = preserve do 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 %fieldset 2 %fieldset
3 %legend Social Accounts 3 %legend Social Accounts
4 .oauth_select_holder 4 .oauth_select_holder
app/views/profiles/show.html.haml
@@ -33,11 +33,11 @@ @@ -33,11 +33,11 @@
33 %ul 33 %ul
34 %li 34 %li
35 %p You can change your password on Account page 35 %p You can change your password on Account page
36 - -unless Gitlab.config.disable_gravatar? 36 + - if Gitlab.config.gravatar.enabled
37 %li 37 %li
38 %p You can change your avatar at #{link_to "gravatar.com", "http://gravatar.com"} 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 %li 41 %li
42 %p 42 %p
43 You can login through #{@user.provider.titleize}! 43 You can login through #{@user.provider.titleize}!
app/views/shared/_clone_panel.html.haml
1 .input-prepend.project_clone_holder 1 .input-prepend.project_clone_holder
2 %button{class: "btn active", :"data-clone" => @project.ssh_url_to_repo} SSH 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 = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select input-xxlarge" 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,7 +2,7 @@ class PostReceive
2 @queue = :post_receive 2 @queue = :post_receive
3 3
4 def self.perform(repo_path, oldrev, newrev, ref, identifier) 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 repo_path.gsub!(/.git$/, "") 6 repo_path.gsub!(/.git$/, "")
7 repo_path.gsub!(/^\//, "") 7 repo_path.gsub!(/^\//, "")
8 8
@@ -10,7 +10,7 @@ class PostReceive @@ -10,7 +10,7 @@ class PostReceive
10 return false if project.nil? 10 return false if project.nil?
11 11
12 # Ignore push from non-gitlab users 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 email = project.commit(newrev).author.email rescue nil 14 email = project.commit(newrev).author.email rescue nil
15 User.find_by_email(email) if email 15 User.find_by_email(email) if email
16 elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) 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 host: localhost 9 host: localhost
12 port: 80 10 port: 80
13 https: false 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 default_projects_limit: 10 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 # 2. Auth settings 29 # 2. Auth settings
33 # ========================== 30 # ==========================
34 -ldap: 31 +
  32 +## LDAP settings
  33 +ldap:
35 enabled: false 34 enabled: false
36 host: '_your_ldap_server' 35 host: '_your_ldap_server'
37 base: '_the_base_where_you_search_for_users' 36 base: '_the_base_where_you_search_for_users'
38 port: 636 37 port: 636
39 uid: 'sAMAccountName' 38 uid: 'sAMAccountName'
40 - method: 'ssl' # plain 39 + method: 'ssl' # "ssl" or "plain"
41 bind_dn: '_the_full_dn_of_the_user_you_will_bind_with' 40 bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
42 password: '_the_password_of_the_bind_user' 41 password: '_the_password_of_the_bind_user'
43 42
  43 +## Omniauth settings
44 omniauth: 44 omniauth:
45 # Enable ability for users 45 # Enable ability for users
46 - # to login via twitter, google .. 46 + # Allow logging in via Twitter, Google, etc. using Omniauth providers
47 enabled: false 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 allow_single_sign_on: false 52 allow_single_sign_on: false
  53 + # Locks down those users until they have been cleared by the admin (default: true)
52 block_auto_created_users: true 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 providers: 60 providers:
56 # - { name: 'google_oauth2', app_id: 'YOUR APP ID', 61 # - { name: 'google_oauth2', app_id: 'YOUR APP ID',
57 # app_secret: 'YOUR APP SECRET', 62 # app_secret: 'YOUR APP SECRET',
@@ -62,29 +67,36 @@ omniauth: @@ -62,29 +67,36 @@ omniauth:
62 # app_secret: 'YOUR APP SECRET' } 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 admin_uri: git@localhost:gitolite-admin 82 admin_uri: git@localhost:gitolite-admin
72 - base_path: /home/git/repositories/ 83 + repos_path: /home/git/repositories/
73 hooks_path: /home/git/.gitolite/hooks/ 84 hooks_path: /home/git/.gitolite/hooks/
74 - gitolite_admin_key: gitlab  
75 - git_user: git 85 + admin_key: gitlab
76 upload_pack: true 86 upload_pack: true
77 receive_pack: true 87 receive_pack: true
78 - # host: localhost 88 + ssh_user: git
  89 + ssh_host: localhost
  90 + # ssh_port: 22
79 # config_file: gitolite.conf 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 git: 96 git:
85 - path: /usr/bin/git 97 + bin_path: /usr/bin/git
86 # Max size of git object like commit, in bytes 98 # Max size of git object like commit, in bytes
87 # This value can be increased if you have a very large commits 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 # Git timeout to read commit, in seconds 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,23 +2,43 @@ class Settings &lt; Settingslogic
2 source "#{Rails.root}/config/gitlab.yml" 2 source "#{Rails.root}/config/gitlab.yml"
3 3
4 class << self 4 class << self
  5 + # FIXME: Deprecated: remove for 4.1
5 def web_protocol 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 self.web['protocol'] ||= web.https ? "https" : "http" 10 self.web['protocol'] ||= web.https ? "https" : "http"
7 end 11 end
8 12
  13 + # FIXME: Deprecated: remove for 4.1
9 def web_host 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 self.web['host'] ||= 'localhost' 18 self.web['host'] ||= 'localhost'
11 end 19 end
12 20
  21 + # FIXME: Deprecated: remove for 4.1
13 def email_from 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 self.email['from'] ||= ("notify@" + web_host) 26 self.email['from'] ||= ("notify@" + web_host)
15 end 27 end
16 28
  29 + # FIXME: Deprecated: remove for 4.1
17 def url 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 self['url'] ||= build_url 34 self['url'] ||= build_url
19 end 35 end
20 36
  37 + # FIXME: Deprecated: remove for 4.1
21 def web_port 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 if web.https 42 if web.https
23 web['port'] = 443 43 web['port'] = 443
24 else 44 else
@@ -26,11 +46,17 @@ class Settings &lt; Settingslogic @@ -26,11 +46,17 @@ class Settings &lt; Settingslogic
26 end.to_i 46 end.to_i
27 end 47 end
28 48
  49 + # FIXME: Deprecated: remove for 4.1
29 def web_custom_port? 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 ![443, 80].include?(web_port) 54 ![443, 80].include?(web_port)
31 end 55 end
32 56
  57 + # FIXME: Deprecated: remove for 4.1
33 def build_url 58 def build_url
  59 + ActiveSupport::Deprecation.warn("Settings.build_url is deprecated and will be removed from GitLab 4.1", caller)
34 if web_custom_port? 60 if web_custom_port?
35 custom_port = ":#{web_port}" 61 custom_port = ":#{web_port}"
36 else 62 else
@@ -44,19 +70,35 @@ class Settings &lt; Settingslogic @@ -44,19 +70,35 @@ class Settings &lt; Settingslogic
44 ].join('') 70 ].join('')
45 end 71 end
46 72
  73 + # FIXME: Deprecated: remove for 4.1
47 def ssh_port 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 git_host['port'] || 22 78 git_host['port'] || 22
49 end 79 end
50 80
  81 + # FIXME: Deprecated: remove for 4.1
51 def ssh_user 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 git_host['git_user'] || 'git' 86 git_host['git_user'] || 'git'
53 end 87 end
54 88
  89 + # FIXME: Deprecated: remove for 4.1
55 def ssh_host 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 git_host['host'] || web_host || 'localhost' 94 git_host['host'] || web_host || 'localhost'
57 end 95 end
58 96
  97 + # FIXME: Deprecated: remove for 4.1
59 def ssh_path 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 if ssh_port != 22 102 if ssh_port != 22
61 "ssh://#{ssh_user}@#{ssh_host}:#{ssh_port}/" 103 "ssh://#{ssh_user}@#{ssh_host}:#{ssh_port}/"
62 else 104 else
@@ -64,15 +106,27 @@ class Settings &lt; Settingslogic @@ -64,15 +106,27 @@ class Settings &lt; Settingslogic
64 end 106 end
65 end 107 end
66 108
  109 + # FIXME: Deprecated: remove for 4.1
67 def git_base_path 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 git_host['base_path'] || '/home/git/repositories/' 114 git_host['base_path'] || '/home/git/repositories/'
69 end 115 end
70 116
  117 + # FIXME: Deprecated: remove for 4.1
71 def git_hooks_path 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 git_host['hooks_path'] || '/home/git/share/gitolite/hooks/' 122 git_host['hooks_path'] || '/home/git/share/gitolite/hooks/'
73 end 123 end
74 124
  125 + # FIXME: Deprecated: remove for 4.1
75 def git_upload_pack 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 if git_host['upload_pack'] != false 130 if git_host['upload_pack'] != false
77 true 131 true
78 else 132 else
@@ -80,7 +134,11 @@ class Settings &lt; Settingslogic @@ -80,7 +134,11 @@ class Settings &lt; Settingslogic
80 end 134 end
81 end 135 end
82 136
  137 + # FIXME: Deprecated: remove for 4.1
83 def git_receive_pack 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 if git_host['receive_pack'] != false 142 if git_host['receive_pack'] != false
85 true 143 true
86 else 144 else
@@ -88,71 +146,207 @@ class Settings &lt; Settingslogic @@ -88,71 +146,207 @@ class Settings &lt; Settingslogic
88 end 146 end
89 end 147 end
90 148
  149 + # FIXME: Deprecated: remove for 4.1
91 def git_bin_path 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 git['path'] || '/usr/bin/git' 154 git['path'] || '/usr/bin/git'
93 end 155 end
94 156
  157 + # FIXME: Deprecated: remove for 4.1
95 def git_max_size 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 git['git_max_size'] || 5242880 # 5.megabytes 162 git['git_max_size'] || 5242880 # 5.megabytes
97 end 163 end
98 164
  165 + # FIXME: Deprecated: remove for 4.1
99 def git_timeout 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 git['git_timeout'] || 10 170 git['git_timeout'] || 10
101 end 171 end
102 172
  173 + # FIXME: Deprecated: remove for 4.1
103 def gitolite_admin_uri 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 git_host['admin_uri'] || 'git@localhost:gitolite-admin' 178 git_host['admin_uri'] || 'git@localhost:gitolite-admin'
105 end 179 end
106 180
  181 + # FIXME: Deprecated: remove for 4.1
107 def gitolite_config_file 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 git_host['config_file'] || 'gitolite.conf' 186 git_host['config_file'] || 'gitolite.conf'
109 end 187 end
110 188
  189 + # FIXME: Deprecated: remove for 4.1
111 def gitolite_admin_key 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 git_host['gitolite_admin_key'] || 'gitlab' 194 git_host['gitolite_admin_key'] || 'gitlab'
113 end 195 end
114 196
  197 + # FIXME: Deprecated: remove for 4.1
115 def default_projects_limit 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 app['default_projects_limit'] || 10 202 app['default_projects_limit'] || 10
117 end 203 end
118 204
  205 + # FIXME: Deprecated: remove for 4.1
119 def backup_path 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 end 211 end
124 212
  213 + # FIXME: Deprecated: remove for 4.1
125 def backup_keep_time 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 app['backup_keep_time'] || 0 218 app['backup_keep_time'] || 0
127 end 219 end
128 220
  221 + # FIXME: Deprecated: remove for 4.1
129 def ldap_enabled? 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 rescue Settingslogic::MissingSetting 225 rescue Settingslogic::MissingSetting
132 false 226 false
133 end 227 end
134 228
  229 + # FIXME: Deprecated: remove for 4.1
135 def omniauth_enabled? 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 rescue Settingslogic::MissingSetting 233 rescue Settingslogic::MissingSetting
138 false 234 false
139 end 235 end
140 236
  237 + # FIXME: Deprecated: remove for 4.1
141 def omniauth_providers 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 end 243 end
144 244
  245 + # FIXME: Deprecated: remove for 4.1
145 def disable_gravatar? 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 app['disable_gravatar'] || false 250 app['disable_gravatar'] || false
147 end 251 end
148 252
  253 + # FIXME: Deprecated: remove for 4.1
149 def gravatar_url 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 app['gravatar_url'] || 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' 258 app['gravatar_url'] || 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
151 end 259 end
152 260
  261 + # FIXME: Deprecated: remove for 4.1
153 def gravatar_ssl_url 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 app['gravatar_ssl_url'] || 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' 266 app['gravatar_ssl_url'] || 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
155 end 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 end 297 end
158 end 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 require 'grit' 1 require 'grit'
2 require 'pygments' 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 Grit::Blob.class_eval do 7 Grit::Blob.class_eval do
8 include Linguist::BlobHelper 8 include Linguist::BlobHelper
config/initializers/devise.rb
@@ -4,7 +4,7 @@ Devise.setup do |config| @@ -4,7 +4,7 @@ Devise.setup do |config|
4 # ==> Mailer Configuration 4 # ==> Mailer Configuration
5 # Configure the e-mail address which will be shown in Devise::Mailer, 5 # Configure the e-mail address which will be shown in Devise::Mailer,
6 # note that it will be overwritten if you use your own mailer class with default "from" parameter. 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 # Configure the class responsible to send e-mails. 9 # Configure the class responsible to send e-mails.
10 # config.mailer = "Devise::Mailer" 10 # config.mailer = "Devise::Mailer"
@@ -205,20 +205,18 @@ Devise.setup do |config| @@ -205,20 +205,18 @@ Devise.setup do |config|
205 # manager.default_strategies(:scope => :user).unshift :some_external_strategy 205 # manager.default_strategies(:scope => :user).unshift :some_external_strategy
206 # end 206 # end
207 207
208 - gl = Gitlab.config  
209 -  
210 - if gl.ldap_enabled? 208 + if Gitlab.config.ldap.enabled
211 config.omniauth :ldap, 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 end 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 end 221 end
224 end 222 end
config/routes.rb
@@ -14,10 +14,10 @@ Gitlab::Application.routes.draw do @@ -14,10 +14,10 @@ Gitlab::Application.routes.draw do
14 14
15 # Enable Grack support 15 # Enable Grack support
16 mount Grack::Bundle.new({ 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 }), at: '/:path', constraints: { path: /[-\/\w\.-]+\.git/ } 21 }), at: '/:path', constraints: { path: /[-\/\w\.-]+\.git/ }
22 22
23 # 23 #
features/support/env.rb
@@ -33,9 +33,9 @@ DatabaseCleaner.strategy = :truncation @@ -33,9 +33,9 @@ DatabaseCleaner.strategy = :truncation
33 33
34 Spinach.hooks.before_scenario do 34 Spinach.hooks.before_scenario do
35 # Use tmp dir for FS manipulations 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 end 39 end
40 40
41 Spinach.hooks.after_scenario do 41 Spinach.hooks.after_scenario do
lib/gitlab/auth.rb
@@ -38,7 +38,7 @@ module Gitlab @@ -38,7 +38,7 @@ module Gitlab
38 email: email, 38 email: email,
39 password: password, 39 password: password,
40 password_confirmation: password, 40 password_confirmation: password,
41 - projects_limit: Gitlab.config.default_projects_limit, 41 + projects_limit: Gitlab.config.gitlab.default_projects_limit,
42 }, as: :admin) 42 }, as: :admin)
43 if Gitlab.config.omniauth['block_auto_created_users'] && !ldap 43 if Gitlab.config.omniauth['block_auto_created_users'] && !ldap
44 @user.blocked = true 44 @user.blocked = true
lib/gitlab/backend/gitolite.rb
@@ -38,7 +38,7 @@ module Gitlab @@ -38,7 +38,7 @@ module Gitlab
38 end 38 end
39 39
40 def url_to_repo path 40 def url_to_repo path
41 - Gitlab.config.ssh_path + "#{path}.git" 41 + Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
42 end 42 end
43 43
44 def enable_automerge 44 def enable_automerge
lib/gitlab/backend/gitolite_config.rb
@@ -16,7 +16,7 @@ module Gitlab @@ -16,7 +16,7 @@ module Gitlab
16 def ga_repo 16 def ga_repo
17 @ga_repo ||= ::Gitolite::GitoliteAdmin.new( 17 @ga_repo ||= ::Gitolite::GitoliteAdmin.new(
18 File.join(config_tmp_dir,'gitolite'), 18 File.join(config_tmp_dir,'gitolite'),
19 - conf: Gitlab.config.gitolite_config_file 19 + conf: Gitlab.config.gitolite.config_file
20 ) 20 )
21 end 21 end
22 22
@@ -167,7 +167,7 @@ module Gitlab @@ -167,7 +167,7 @@ module Gitlab
167 # Enable access to all repos for gitolite admin. 167 # Enable access to all repos for gitolite admin.
168 # We use it for accept merge request feature 168 # We use it for accept merge request feature
169 def admin_all_repo 169 def admin_all_repo
170 - owner_name = Gitlab.config.gitolite_admin_key 170 + owner_name = Gitlab.config.gitolite.admin_key
171 171
172 # @ALL repos premission for gitolite owner 172 # @ALL repos premission for gitolite owner
173 repo_name = "@all" 173 repo_name = "@all"
@@ -189,7 +189,7 @@ module Gitlab @@ -189,7 +189,7 @@ module Gitlab
189 189
190 def pull tmp_dir 190 def pull tmp_dir
191 Dir.mkdir tmp_dir 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 unless File.exists?(File.join(tmp_dir, 'gitolite', 'conf', 'gitolite.conf')) 194 unless File.exists?(File.join(tmp_dir, 'gitolite', 'conf', 'gitolite.conf'))
195 raise PullError, "unable to clone gitolite-admin repo" 195 raise PullError, "unable to clone gitolite-admin repo"
lib/gitlab/project_mover.rb
@@ -15,10 +15,10 @@ module Gitlab @@ -15,10 +15,10 @@ module Gitlab
15 15
16 def execute 16 def execute
17 # Create new dir if missing 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 system("mkdir -m 770 #{new_dir_path}") unless File.exists?(new_dir_path) 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 new_path = File.join(new_dir_path, "#{project.path}.git") 22 new_path = File.join(new_dir_path, "#{project.path}.git")
23 23
24 if File.exists? new_path 24 if File.exists? new_path
lib/tasks/gitlab/activate_namespaces.rake
@@ -27,7 +27,7 @@ namespace :gitlab do @@ -27,7 +27,7 @@ namespace :gitlab do
27 end 27 end
28 28
29 print "\n\nMove projects from groups under groups dirs:".yellow 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 Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project| 32 Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project|
33 next unless project.group 33 next unless project.group
lib/tasks/gitlab/backup.rake
@@ -8,7 +8,7 @@ namespace :gitlab do @@ -8,7 +8,7 @@ namespace :gitlab do
8 Rake::Task["gitlab:app:db_dump"].invoke 8 Rake::Task["gitlab:app:db_dump"].invoke
9 Rake::Task["gitlab:app:repo_dump"].invoke 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 # saving additional informations 13 # saving additional informations
14 s = {} 14 s = {}
@@ -17,7 +17,7 @@ namespace :gitlab do @@ -17,7 +17,7 @@ namespace :gitlab do
17 s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"") 17 s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"")
18 s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"") 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 file << s.to_yaml.gsub(/^---\n/,'') 21 file << s.to_yaml.gsub(/^---\n/,'')
22 end 22 end
23 23
@@ -39,10 +39,10 @@ namespace :gitlab do @@ -39,10 +39,10 @@ namespace :gitlab do
39 39
40 # delete backups 40 # delete backups
41 print "Deleting old backups... " 41 print "Deleting old backups... "
42 - if Gitlab.config.backup_keep_time > 0 42 + if Gitlab.config.backup.keep_time > 0
43 file_list = Dir.glob("*_gitlab_backup.tar").map { |f| f.split(/_/).first.to_i } 43 file_list = Dir.glob("*_gitlab_backup.tar").map { |f| f.split(/_/).first.to_i }
44 file_list.sort.each do |timestamp| 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 %x{rm #{timestamp}_gitlab_backup.tar} 46 %x{rm #{timestamp}_gitlab_backup.tar}
47 end 47 end
48 end 48 end
@@ -55,7 +55,7 @@ namespace :gitlab do @@ -55,7 +55,7 @@ namespace :gitlab do
55 # Restore backup of GitLab system 55 # Restore backup of GitLab system
56 desc "GITLAB | Restore a previously created backup" 56 desc "GITLAB | Restore a previously created backup"
57 task :backup_restore => :environment do 57 task :backup_restore => :environment do
58 - Dir.chdir(Gitlab.config.backup_path) 58 + Dir.chdir(Gitlab.config.backup.path)
59 59
60 # check for existing backups in the backup dir 60 # check for existing backups in the backup dir
61 file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i } 61 file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i }
@@ -111,7 +111,7 @@ namespace :gitlab do @@ -111,7 +111,7 @@ namespace :gitlab do
111 ################################# REPOSITORIES ################################# 111 ################################# REPOSITORIES #################################
112 112
113 task :repo_dump => :environment do 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 FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo) 115 FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo)
116 puts "Dumping repositories:" 116 puts "Dumping repositories:"
117 project = Project.all.map { |n| [n.path, n.path_to_repo] } 117 project = Project.all.map { |n| [n.path, n.path_to_repo] }
@@ -127,7 +127,7 @@ namespace :gitlab do @@ -127,7 +127,7 @@ namespace :gitlab do
127 end 127 end
128 128
129 task :repo_restore => :environment do 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 puts "Restoring repositories:" 131 puts "Restoring repositories:"
132 project = Project.all.map { |n| [n.path, n.path_to_repo] } 132 project = Project.all.map { |n| [n.path, n.path_to_repo] }
133 project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] 133 project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
@@ -136,8 +136,8 @@ namespace :gitlab do @@ -136,8 +136,8 @@ namespace :gitlab do
136 FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff 136 FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff
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") 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 permission_commands = [ 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 permission_commands.each { |command| Kernel.system(command) } 142 permission_commands.each { |command| Kernel.system(command) }
143 puts "[DONE]".green 143 puts "[DONE]".green
@@ -150,7 +150,7 @@ namespace :gitlab do @@ -150,7 +150,7 @@ namespace :gitlab do
150 ###################################### DB ###################################### 150 ###################################### DB ######################################
151 151
152 task :db_dump => :environment do 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 FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db) 154 FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db)
155 155
156 puts "Dumping database tables:" 156 puts "Dumping database tables:"
@@ -170,7 +170,7 @@ namespace :gitlab do @@ -170,7 +170,7 @@ namespace :gitlab do
170 end 170 end
171 171
172 task :db_restore=> :environment do 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 puts "Restoring database tables:" 175 puts "Restoring database tables:"
176 Rake::Task["db:reset"].invoke 176 Rake::Task["db:reset"].invoke
lib/tasks/gitlab/check.rake
@@ -90,7 +90,7 @@ namespace :gitlab do @@ -90,7 +90,7 @@ namespace :gitlab do
90 end 90 end
91 91
92 def check_gitlab_config_not_outdated 92 def check_gitlab_config_not_outdated
93 - print "GitLab config not outdated? ... " 93 + print "GitLab config outdated? ... "
94 94
95 gitlab_config_file = Rails.root.join("config", "gitlab.yml") 95 gitlab_config_file = Rails.root.join("config", "gitlab.yml")
96 unless File.exists?(gitlab_config_file) 96 unless File.exists?(gitlab_config_file)
@@ -98,11 +98,12 @@ namespace :gitlab do @@ -98,11 +98,12 @@ namespace :gitlab do
98 end 98 end
99 99
100 # omniauth or ldap could have been deleted from the file 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 else 103 else
104 - puts "no".red 104 + puts "yes".red
105 try_fixing_it( 105 try_fixing_it(
  106 + "Backup your config/gitlab.yml",
106 "Copy config/gitlab.yml.example to config/gitlab.yml", 107 "Copy config/gitlab.yml.example to config/gitlab.yml",
107 "Update config/gitlab.yml to match your setup" 108 "Update config/gitlab.yml to match your setup"
108 ) 109 )
@@ -268,7 +269,7 @@ namespace :gitlab do @@ -268,7 +269,7 @@ namespace :gitlab do
268 269
269 options = { 270 options = {
270 "user.name" => "GitLab", 271 "user.name" => "GitLab",
271 - "user.email" => Gitlab.config.email_from 272 + "user.email" => Gitlab.config.gitlab.email_from
272 } 273 }
273 correct_options = options.map do |name, value| 274 correct_options = options.map do |name, value|
274 run("git config --global --get #{name}").try(:squish) == value 275 run("git config --global --get #{name}").try(:squish) == value
@@ -290,7 +291,7 @@ namespace :gitlab do @@ -290,7 +291,7 @@ namespace :gitlab do
290 end 291 end
291 292
292 def check_gitlab_in_git_group 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 print "gitlab user is in #{gitolite_ssh_user} group? ... " 295 print "gitlab user is in #{gitolite_ssh_user} group? ... "
295 296
296 if run_and_match("id -rnG", /\Wgit\W/) 297 if run_and_match("id -rnG", /\Wgit\W/)
@@ -309,10 +310,10 @@ namespace :gitlab do @@ -309,10 +310,10 @@ namespace :gitlab do
309 310
310 # see https://github.com/gitlabhq/gitlabhq/issues/1059 311 # see https://github.com/gitlabhq/gitlabhq/issues/1059
311 def check_issue_1056_shell_profile_error 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 print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... " 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 unless File.read(profile_file) =~ /^-e PATH/ 318 unless File.read(profile_file) =~ /^-e PATH/
318 puts "yes".green 319 puts "yes".green
@@ -414,7 +415,7 @@ namespace :gitlab do @@ -414,7 +415,7 @@ namespace :gitlab do
414 415
415 test_path = "/tmp/gitlab_gitolite_admin_test" 416 test_path = "/tmp/gitlab_gitolite_admin_test"
416 FileUtils.rm_rf(test_path) 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 raise unless $?.success? 419 raise unless $?.success?
419 420
420 puts "yes".green 421 puts "yes".green
@@ -423,7 +424,7 @@ namespace :gitlab do @@ -423,7 +424,7 @@ namespace :gitlab do
423 try_fixing_it( 424 try_fixing_it(
424 "Make sure the \"admin_uri\" is set correctly in config/gitlab.yml", 425 "Make sure the \"admin_uri\" is set correctly in config/gitlab.yml",
425 "Try cloning it yourself with:", 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 "Make sure Gitolite is installed correctly." 428 "Make sure Gitolite is installed correctly."
428 ) 429 )
429 for_more_information( 430 for_more_information(
@@ -452,7 +453,7 @@ namespace :gitlab do @@ -452,7 +453,7 @@ namespace :gitlab do
452 puts "no".red 453 puts "no".red
453 try_fixing_it( 454 try_fixing_it(
454 "Try committing to it yourself with:", 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 " touch foo", 457 " touch foo",
457 " git add foo", 458 " git add foo",
458 " git commit -m \"foo\"", 459 " git commit -m \"foo\"",
@@ -469,7 +470,7 @@ namespace :gitlab do @@ -469,7 +470,7 @@ namespace :gitlab do
469 def check_dot_gitolite_exists 470 def check_dot_gitolite_exists
470 print "Config directory exists? ... " 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 if File.directory?(gitolite_config_path) 475 if File.directory?(gitolite_config_path)
475 puts "yes".green 476 puts "yes".green
@@ -490,7 +491,7 @@ namespace :gitlab do @@ -490,7 +491,7 @@ namespace :gitlab do
490 def check_dot_gitolite_permissions 491 def check_dot_gitolite_permissions
491 print "Config directory access is drwxr-x---? ... " 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 unless File.exists?(gitolite_config_path) 495 unless File.exists?(gitolite_config_path)
495 puts "can't check because of previous errors".magenta 496 puts "can't check because of previous errors".magenta
496 return 497 return
@@ -512,7 +513,7 @@ namespace :gitlab do @@ -512,7 +513,7 @@ namespace :gitlab do
512 end 513 end
513 514
514 def check_dot_gitolite_user_and_group 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 print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... " 517 print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... "
517 518
518 gitolite_config_path = File.expand_path("~#{gitolite_ssh_user}/.gitolite") 519 gitolite_config_path = File.expand_path("~#{gitolite_ssh_user}/.gitolite")
@@ -615,9 +616,9 @@ namespace :gitlab do @@ -615,9 +616,9 @@ namespace :gitlab do
615 print "post-receive hook exists? ... " 616 print "post-receive hook exists? ... "
616 617
617 hook_file = "post-receive" 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 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) 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 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file) 623 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
623 624
@@ -639,10 +640,10 @@ namespace :gitlab do @@ -639,10 +640,10 @@ namespace :gitlab do
639 print "post-receive hook up-to-date? ... " 640 print "post-receive hook up-to-date? ... "
640 641
641 hook_file = "post-receive" 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 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) 644 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
644 gitolite_hook_content = File.read(gitolite_hook_file) 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 unless File.exists?(gitolite_hook_file) 648 unless File.exists?(gitolite_hook_file)
648 puts "can't check because of previous errors".magenta 649 puts "can't check because of previous errors".magenta
@@ -669,7 +670,7 @@ namespace :gitlab do @@ -669,7 +670,7 @@ namespace :gitlab do
669 def check_repo_base_exists 670 def check_repo_base_exists
670 print "Repo base directory exists? ... " 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 if File.exists?(repo_base_path) 675 if File.exists?(repo_base_path)
675 puts "yes".green 676 puts "yes".green
@@ -691,7 +692,7 @@ namespace :gitlab do @@ -691,7 +692,7 @@ namespace :gitlab do
691 def check_repo_base_permissions 692 def check_repo_base_permissions
692 print "Repo base access is drwsrws---? ... " 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 unless File.exists?(repo_base_path) 696 unless File.exists?(repo_base_path)
696 puts "can't check because of previous errors".magenta 697 puts "can't check because of previous errors".magenta
697 return 698 return
@@ -713,10 +714,10 @@ namespace :gitlab do @@ -713,10 +714,10 @@ namespace :gitlab do
713 end 714 end
714 715
715 def check_repo_base_user_and_group 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 print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_ssh_user}? ... " 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 unless File.exists?(repo_base_path) 721 unless File.exists?(repo_base_path)
721 puts "can't check because of previous errors".magenta 722 puts "can't check because of previous errors".magenta
722 return 723 return
@@ -777,9 +778,9 @@ namespace :gitlab do @@ -777,9 +778,9 @@ namespace :gitlab do
777 print "post-receive hooks in repos are links: ... " 778 print "post-receive hooks in repos are links: ... "
778 779
779 hook_file = "post-receive" 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 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) 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 unless File.exists?(gitolite_hook_file) 785 unless File.exists?(gitolite_hook_file)
785 puts "can't check because of previous errors".magenta 786 puts "can't check because of previous errors".magenta
@@ -828,7 +829,7 @@ namespace :gitlab do @@ -828,7 +829,7 @@ namespace :gitlab do
828 ######################## 829 ########################
829 830
830 def gitolite_home 831 def gitolite_home
831 - File.expand_path("~#{Gitlab.config.ssh_user}") 832 + File.expand_path("~#{Gitlab.config.gitolite.ssh_user}")
832 end 833 end
833 834
834 def gitolite_version 835 def gitolite_version
lib/tasks/gitlab/import.rake
@@ -12,7 +12,7 @@ namespace :gitlab do @@ -12,7 +12,7 @@ namespace :gitlab do
12 desc "GITLAB | Import bare repositories from git_host -> base_path into GitLab project instance" 12 desc "GITLAB | Import bare repositories from git_host -> base_path into GitLab project instance"
13 task :repos => :environment do 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 repos_to_import = Dir.glob(git_base_path + '/*') 16 repos_to_import = Dir.glob(git_base_path + '/*')
17 17
18 repos_to_import.each do |repo_path| 18 repos_to_import.each do |repo_path|
lib/tasks/gitlab/info.rake
@@ -46,7 +46,7 @@ namespace :gitlab do @@ -46,7 +46,7 @@ namespace :gitlab do
46 http_clone_url = project.http_url_to_repo 46 http_clone_url = project.http_url_to_repo
47 ssh_clone_url = project.ssh_url_to_repo 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 omniauth_providers.map! { |provider| provider['name'] } 50 omniauth_providers.map! { |provider| provider['name'] }
51 51
52 puts "" 52 puts ""
@@ -55,17 +55,17 @@ namespace :gitlab do @@ -55,17 +55,17 @@ namespace :gitlab do
55 puts "Revision:\t#{Gitlab::Revision}" 55 puts "Revision:\t#{Gitlab::Revision}"
56 puts "Directory:\t#{Rails.root}" 56 puts "Directory:\t#{Rails.root}"
57 puts "DB Adapter:\t#{database_adapter}" 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 puts "HTTP Clone URL:\t#{http_clone_url}" 59 puts "HTTP Clone URL:\t#{http_clone_url}"
60 puts "SSH Clone URL:\t#{ssh_clone_url}" 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 # check Gitolite version 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 if File.exists?(gitolite_version_file) && File.readable?(gitolite_version_file) 69 if File.exists?(gitolite_version_file) && File.readable?(gitolite_version_file)
70 gitolite_version = File.read(gitolite_version_file) 70 gitolite_version = File.read(gitolite_version_file)
71 end 71 end
@@ -73,11 +73,11 @@ namespace :gitlab do @@ -73,11 +73,11 @@ namespace :gitlab do
73 puts "" 73 puts ""
74 puts "Gitolite information".yellow 74 puts "Gitolite information".yellow
75 puts "Version:\t#{gitolite_version || "unknown".red}" 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 end 82 end
83 83
spec/helpers/application_helper_spec.rb
@@ -43,7 +43,7 @@ describe ApplicationHelper do @@ -43,7 +43,7 @@ describe ApplicationHelper do
43 let(:user_email) { 'user@email.com' } 43 let(:user_email) { 'user@email.com' }
44 44
45 it "should return a generic avatar path when Gravatar is disabled" do 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 gravatar_icon(user_email).should == 'no_avatar.png' 47 gravatar_icon(user_email).should == 'no_avatar.png'
48 end 48 end
49 49
@@ -63,7 +63,7 @@ describe ApplicationHelper do @@ -63,7 +63,7 @@ describe ApplicationHelper do
63 63
64 it "should return custom gravatar path when gravatar_url is set" do 64 it "should return custom gravatar path when gravatar_url is set" do
65 stub!(:request).and_return(double(:ssl? => false)) 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 gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118' 67 gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
68 end 68 end
69 69
spec/lib/gitolite_spec.rb
@@ -16,7 +16,7 @@ describe Gitlab::Gitolite do @@ -16,7 +16,7 @@ describe Gitlab::Gitolite do
16 it { should respond_to :create_repository } 16 it { should respond_to :create_repository }
17 it { should respond_to :remove_repository } 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 it "should call config update" do 21 it "should call config update" do
22 gitolite_config.should_receive(:update_project!) 22 gitolite_config.should_receive(:update_project!)
spec/lib/project_mover_spec.rb
@@ -6,7 +6,7 @@ describe Gitlab::ProjectMover do @@ -6,7 +6,7 @@ describe Gitlab::ProjectMover do
6 before do 6 before do
7 FileUtils.rm_rf base_path if File.exists? base_path 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 @project = create(:project) 11 @project = create(:project)
12 end 12 end
spec/models/project_hooks_spec.rb
@@ -108,7 +108,7 @@ describe Project, &quot;Hooks&quot; do @@ -108,7 +108,7 @@ describe Project, &quot;Hooks&quot; do
108 it { should include(id: @commit.id) } 108 it { should include(id: @commit.id) }
109 it { should include(message: @commit.safe_message) } 109 it { should include(message: @commit.safe_message) }
110 it { should include(timestamp: @commit.date.xmlschema) } 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 context "with a author" do 113 context "with a author" do
114 subject { @data[:commits].first[:author] } 114 subject { @data[:commits].first[:author] }
spec/models/project_spec.rb
@@ -148,7 +148,7 @@ describe Project do @@ -148,7 +148,7 @@ describe Project do
148 148
149 it "should return valid url to repo" do 149 it "should return valid url to repo" do
150 project = Project.new(path: "somewhere") 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 end 152 end
153 153
154 it "should return path to repo" do 154 it "should return path to repo" do
@@ -158,7 +158,7 @@ describe Project do @@ -158,7 +158,7 @@ describe Project do
158 158
159 it "returns the full web URL for this repo" do 159 it "returns the full web URL for this repo" do
160 project = Project.new(path: "somewhere") 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 end 162 end
163 163
164 describe "last_activity methods" do 164 describe "last_activity methods" do
spec/spec_helper.rb
@@ -42,8 +42,8 @@ RSpec.configure do |config| @@ -42,8 +42,8 @@ RSpec.configure do |config|
42 # ActiveRecord::Base.observers.enable(:all) 42 # ActiveRecord::Base.observers.enable(:all)
43 43
44 # Use tmp dir for FS manipulations 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 end 48 end
49 end 49 end
spec/workers/post_receive_spec.rb
@@ -39,6 +39,6 @@ describe PostReceive do @@ -39,6 +39,6 @@ describe PostReceive do
39 end 39 end
40 40
41 def pwd(project) 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 end 43 end
44 end 44 end