Commit d64090b8a9065746c6d532057228c079a1d57013

Authored by Dmitriy Zaporozhets
1 parent 8e0b58d7

No gitolite in project any more

1 v 5.0.0 1 v 5.0.0
2 - - replaced gitolite with gitlab-shell 2 + - Replaced gitolite with gitlab-shell
3 3
4 v 4.2.0 4 v 4.2.0
  5 + - Teams
5 - User show page. Via /u/username 6 - User show page. Via /u/username
6 - Show help contents on pages for better navigation 7 - Show help contents on pages for better navigation
7 8
app/controllers/admin/projects_controller.rb
@@ -41,9 +41,7 @@ class Admin::ProjectsController < Admin::ApplicationController @@ -41,9 +41,7 @@ class Admin::ProjectsController < Admin::ApplicationController
41 end 41 end
42 42
43 def destroy 43 def destroy
44 - # Delete team first in order to prevent multiple gitolite calls  
45 @project.team.truncate 44 @project.team.truncate
46 -  
47 @project.destroy 45 @project.destroy
48 46
49 redirect_to admin_projects_path, notice: 'Project was successfully deleted.' 47 redirect_to admin_projects_path, notice: 'Project was successfully deleted.'
app/controllers/errors_controller.rb
1 class ErrorsController < ApplicationController 1 class ErrorsController < ApplicationController
2 - def githost  
3 - render "errors/gitolite"  
4 - end  
5 end 2 end
app/controllers/projects_controller.rb
@@ -93,9 +93,7 @@ class ProjectsController &lt; ProjectResourceController @@ -93,9 +93,7 @@ class ProjectsController &lt; ProjectResourceController
93 def destroy 93 def destroy
94 return access_denied! unless can?(current_user, :remove_project, project) 94 return access_denied! unless can?(current_user, :remove_project, project)
95 95
96 - # Delete team first in order to prevent multiple gitolite calls  
97 project.team.truncate 96 project.team.truncate
98 -  
99 project.destroy 97 project.destroy
100 98
101 respond_to do |format| 99 respond_to do |format|
app/models/namespace.rb
@@ -31,8 +31,6 @@ class Namespace &lt; ActiveRecord::Base @@ -31,8 +31,6 @@ class Namespace &lt; ActiveRecord::Base
31 31
32 scope :root, where('type IS NULL') 32 scope :root, where('type IS NULL')
33 33
34 - attr_accessor :require_update_gitolite  
35 -  
36 def self.search query 34 def self.search query
37 where("name LIKE :query OR path LIKE :query", query: "%#{query}%") 35 where("name LIKE :query OR path LIKE :query", query: "%#{query}%")
38 end 36 end
@@ -60,13 +58,13 @@ class Namespace &lt; ActiveRecord::Base @@ -60,13 +58,13 @@ class Namespace &lt; ActiveRecord::Base
60 end 58 end
61 59
62 def namespace_full_path 60 def namespace_full_path
63 - @namespace_full_path ||= File.join(Gitlab.config.gitolite.repos_path, path) 61 + @namespace_full_path ||= File.join(Gitlab.config.gitlab_shell.repos_path, path)
64 end 62 end
65 63
66 def move_dir 64 def move_dir
67 if path_changed? 65 if path_changed?
68 - old_path = File.join(Gitlab.config.gitolite.repos_path, path_was)  
69 - new_path = File.join(Gitlab.config.gitolite.repos_path, path) 66 + old_path = File.join(Gitlab.config.gitlab_shell.repos_path, path_was)
  67 + new_path = File.join(Gitlab.config.gitlab_shell.repos_path, path)
70 if File.exists?(new_path) 68 if File.exists?(new_path)
71 raise "Already exists" 69 raise "Already exists"
72 end 70 end
@@ -81,7 +79,6 @@ class Namespace &lt; ActiveRecord::Base @@ -81,7 +79,6 @@ class Namespace &lt; ActiveRecord::Base
81 79
82 FileUtils.mv( old_path, new_path ) 80 FileUtils.mv( old_path, new_path )
83 send_update_instructions 81 send_update_instructions
84 - @require_update_gitolite = true  
85 rescue Exception => e 82 rescue Exception => e
86 raise "Namespace move error #{old_path} #{new_path}" 83 raise "Namespace move error #{old_path} #{new_path}"
87 end 84 end
@@ -89,7 +86,7 @@ class Namespace &lt; ActiveRecord::Base @@ -89,7 +86,7 @@ class Namespace &lt; ActiveRecord::Base
89 end 86 end
90 87
91 def rm_dir 88 def rm_dir
92 - dir_path = File.join(Gitlab.config.gitolite.repos_path, path) 89 + dir_path = File.join(Gitlab.config.gitlab_shell.repos_path, path)
93 FileUtils.rm_r( dir_path, force: true ) 90 FileUtils.rm_r( dir_path, force: true )
94 end 91 end
95 92
app/models/project.rb
@@ -140,10 +140,6 @@ class Project &lt; ActiveRecord::Base @@ -140,10 +140,6 @@ class Project &lt; ActiveRecord::Base
140 nil 140 nil
141 end 141 end
142 142
143 - def git_error?  
144 - error_code == :gitolite  
145 - end  
146 -  
147 def saved? 143 def saved?
148 id && valid? 144 id && valid?
149 end 145 end
@@ -157,7 +153,7 @@ class Project &lt; ActiveRecord::Base @@ -157,7 +153,7 @@ class Project &lt; ActiveRecord::Base
157 end 153 end
158 154
159 def repo_name 155 def repo_name
160 - denied_paths = %w(gitolite-admin admin dashboard groups help profile projects search) 156 + denied_paths = %w(admin dashboard groups help profile projects search)
161 157
162 if denied_paths.include?(path) 158 if denied_paths.include?(path)
163 errors.add(:path, "like #{path} is not allowed") 159 errors.add(:path, "like #{path} is not allowed")
@@ -450,7 +446,7 @@ class Project &lt; ActiveRecord::Base @@ -450,7 +446,7 @@ class Project &lt; ActiveRecord::Base
450 end 446 end
451 447
452 def url_to_repo 448 def url_to_repo
453 - gitolite.url_to_repo(path_with_namespace) 449 + gitlab_shell.url_to_repo(path_with_namespace)
454 end 450 end
455 451
456 def namespace_dir 452 def namespace_dir
app/models/repository.rb
@@ -25,7 +25,7 @@ class Repository @@ -25,7 +25,7 @@ class Repository
25 end 25 end
26 26
27 def path_to_repo 27 def path_to_repo
28 - @path_to_repo ||= File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git") 28 + @path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, "#{path_with_namespace}.git")
29 end 29 end
30 30
31 def repo 31 def repo
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.gitolite.repos_path, @group.path) 25 + %span.monospace= File.join(Gitlab.config.gitlab_shell.repos_path, @group.path)
26 %tr 26 %tr
27 %td 27 %td
28 %b 28 %b
app/views/errors/gitolite.html.haml
@@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
1 -%h1.http_status_code 500  
2 -%h3.page_title GitLab was unable to access your Gitolite system.  
3 -%hr  
4 -  
5 -.git_error_tips  
6 - %h4 Tips for Administrator:  
7 - %ol  
8 - %li  
9 - %p  
10 - Check git logs in admin area  
11 - %li  
12 - %p  
13 - Check config/gitlab.yml for correct settings.  
14 - %li  
15 - %p  
16 - Diagnostic tool:  
17 - %pre  
18 - bundle exec rake gitlab:check RAILS_ENV=production  
19 - %li  
20 - %p  
21 - Permissions:  
22 - %pre  
23 - = preserve do  
24 - sudo chown -R git:git #{Gitlab.config.gitolite.repos_path}  
25 - sudo chmod -R ug+rwXs #{Gitlab.config.gitolite.repos_path}  
app/workers/gitlab_shell_worker.rb 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +class GitoliteWorker
  2 + include Sidekiq::Worker
  3 + include Gitolited
  4 +
  5 + sidekiq_options queue: :gitlab_shell
  6 +
  7 + def perform(action, *arg)
  8 + gitlab_shell.send(action, *arg)
  9 + end
  10 +end
app/workers/gitolite_worker.rb
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -class GitoliteWorker  
2 - include Sidekiq::Worker  
3 - include Gitolited  
4 -  
5 - sidekiq_options queue: :gitolite  
6 -  
7 - def perform(action, *arg)  
8 - gitolite.send(action, *arg)  
9 - end  
10 -end  
app/workers/post_receive.rb
@@ -5,10 +5,10 @@ class PostReceive @@ -5,10 +5,10 @@ class PostReceive
5 5
6 def perform(repo_path, oldrev, newrev, ref, identifier) 6 def perform(repo_path, oldrev, newrev, ref, identifier)
7 7
8 - if repo_path.start_with?(Gitlab.config.gitolite.repos_path.to_s)  
9 - repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "") 8 + if repo_path.start_with?(Gitlab.config.gitlab_shell.repos_path.to_s)
  9 + repo_path.gsub!(Gitlab.config.gitlab_shell.repos_path.to_s, "")
10 else 10 else
11 - Gitlab::GitLogger.error("POST-RECEIVE: Check gitlab.yml config for correct gitolite.repos_path variable. \"#{Gitlab.config.gitolite.repos_path}\" does not match \"#{repo_path}\"") 11 + Gitlab::GitLogger.error("POST-RECEIVE: Check gitlab.yml config for correct gitlab_shell.repos_path variable. \"#{Gitlab.config.gitlab_shell.repos_path}\" does not match \"#{repo_path}\"")
12 end 12 end
13 13
14 repo_path.gsub!(/.git$/, "") 14 repo_path.gsub!(/.git$/, "")
@@ -22,7 +22,8 @@ class PostReceive @@ -22,7 +22,8 @@ class PostReceive
22 end 22 end
23 23
24 # Ignore push from non-gitlab users 24 # Ignore push from non-gitlab users
25 - user = if identifier.eql? Gitlab.config.gitolite.admin_key 25 + user = if identifier.nil?
  26 + raise identifier.inspect
26 email = project.repository.commit(newrev).author.email rescue nil 27 email = project.repository.commit(newrev).author.email rescue nil
27 User.find_by_email(email) if email 28 User.find_by_email(email) if email
28 elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) 29 elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
config/gitlab.yml.example
@@ -5,8 +5,7 @@ @@ -5,8 +5,7 @@
5 # How to use: 5 # How to use:
6 # 1. copy file as gitlab.yml 6 # 1. copy file as gitlab.yml
7 # 2. Replace gitlab -> host with your domain 7 # 2. Replace gitlab -> host with your domain
8 -# 3. Replace gitolite -> ssh_host with your domain  
9 -# 4. Replace gitlab -> email_from 8 +# 3. Replace gitlab -> email_from
10 9
11 # 10 #
12 # 1. GitLab app settings 11 # 1. GitLab app settings
@@ -22,8 +21,8 @@ gitlab: @@ -22,8 +21,8 @@ gitlab:
22 # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed 21 # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed
23 # relative_url_root: /gitlab 22 # relative_url_root: /gitlab
24 23
25 - # Uncomment and customize if you can't use the default user to run GitLab (default: 'gitlab')  
26 - # user: user123 24 + # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
  25 + # user: git
27 26
28 ## Email settings 27 ## Email settings
29 # Email address used in the "From" field in mails sent by GitLab 28 # Email address used in the "From" field in mails sent by GitLab
@@ -103,21 +102,18 @@ backup: @@ -103,21 +102,18 @@ backup:
103 path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) 102 path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
104 # keep_time: 604800 # default: 0 (forever) (in seconds) 103 # keep_time: 604800 # default: 0 (forever) (in seconds)
105 104
106 -## Gitolite settings  
107 -gitolite: 105 +## GitLab Shell settings
  106 +gitlab_shell:
108 # REPOS_PATH MUST NOT BE A SYMLINK!!! 107 # REPOS_PATH MUST NOT BE A SYMLINK!!!
109 repos_path: /home/git/repositories/ 108 repos_path: /home/git/repositories/
110 hooks_path: /home/git/gitlab-shell/hooks/ 109 hooks_path: /home/git/gitlab-shell/hooks/
111 - admin_key: gitlab 110 +
  111 + # Git over HTTP
112 upload_pack: true 112 upload_pack: true
113 receive_pack: true 113 receive_pack: true
114 - ssh_user: git  
115 - ssh_host: localhost  
116 - # ssh_port: 22  
117 - # config_file: gitolite.conf  
118 114
119 - # Uncomment and customize if you can't use the default group to own the repositories and run Gitolite (default: same as the 'ssh_user' above)  
120 - # owner_group: group123 115 + # If you use non-standart ssh port you need to specify it
  116 + # ssh_port: 22
121 117
122 ## Git settings 118 ## Git settings
123 # CAUTION! 119 # CAUTION!
config/initializers/1_settings.rb
@@ -8,11 +8,11 @@ class Settings &lt; Settingslogic @@ -8,11 +8,11 @@ class Settings &lt; Settingslogic
8 8
9 private 9 private
10 10
11 - def build_gitolite_ssh_path_prefix  
12 - if gitolite.ssh_port != 22  
13 - "ssh://#{gitolite.ssh_user}@#{gitolite.ssh_host}:#{gitolite.ssh_port}/" 11 + def build_gitlab_shell_ssh_path_prefix
  12 + if gitlab_shell.ssh_port != 22
  13 + "ssh://#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:#{gitlab_shell.ssh_port}/"
14 else 14 else
15 - "#{gitolite.ssh_user}@#{gitolite.ssh_host}:" 15 + "#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:"
16 end 16 end
17 end 17 end
18 18
@@ -41,6 +41,9 @@ Settings[&#39;omniauth&#39;] ||= Settingslogic.new({}) @@ -41,6 +41,9 @@ Settings[&#39;omniauth&#39;] ||= Settingslogic.new({})
41 Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil? 41 Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil?
42 Settings.omniauth['providers'] ||= [] 42 Settings.omniauth['providers'] ||= []
43 43
  44 +#
  45 +# GitLab
  46 +#
44 Settings['gitlab'] ||= Settingslogic.new({}) 47 Settings['gitlab'] ||= Settingslogic.new({})
45 Settings.gitlab['default_projects_limit'] ||= 10 48 Settings.gitlab['default_projects_limit'] ||= 10
46 Settings.gitlab['host'] ||= 'localhost' 49 Settings.gitlab['host'] ||= 'localhost'
@@ -54,29 +57,38 @@ Settings.gitlab[&#39;url&#39;] ||= Settings.send(:build_gitlab_url) @@ -54,29 +57,38 @@ Settings.gitlab[&#39;url&#39;] ||= Settings.send(:build_gitlab_url)
54 Settings.gitlab['user'] ||= 'git' 57 Settings.gitlab['user'] ||= 'git'
55 Settings.gitlab['signup_enabled'] ||= false 58 Settings.gitlab['signup_enabled'] ||= false
56 59
  60 +#
  61 +# Gravatar
  62 +#
57 Settings['gravatar'] ||= Settingslogic.new({}) 63 Settings['gravatar'] ||= Settingslogic.new({})
58 Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil? 64 Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil?
59 Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' 65 Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
60 Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' 66 Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
61 67
62 -Settings['gitolite'] ||= Settingslogic.new({})  
63 -Settings.gitolite['admin_key'] ||= 'gitlab'  
64 -Settings.gitolite['admin_uri'] ||= 'git@localhost:gitolite-admin'  
65 -Settings.gitolite['config_file'] ||= 'gitolite.conf'  
66 -Settings.gitolite['hooks_path'] ||= '/home/git/share/gitolite/hooks/'  
67 -Settings.gitolite['receive_pack'] = true if Settings.gitolite['receive_pack'].nil?  
68 -Settings.gitolite['upload_pack'] = true if Settings.gitolite['upload_pack'].nil?  
69 -Settings.gitolite['repos_path'] ||= '/home/git/repositories/'  
70 -Settings.gitolite['ssh_host'] ||= (Settings.gitlab.host || 'localhost')  
71 -Settings.gitolite['ssh_port'] ||= 22  
72 -Settings.gitolite['ssh_user'] ||= 'git'  
73 -Settings.gitolite['owner_group'] ||= Settings.gitolite.ssh_user  
74 -Settings.gitolite['ssh_path_prefix'] ||= Settings.send(:build_gitolite_ssh_path_prefix) 68 +#
  69 +# GitLab Shell
  70 +#
  71 +Settings['gitlab_shell'] ||= Settingslogic.new({})
  72 +Settings.gitlab_shell['hooks_path'] ||= '/home/git/gitlab-shell/hooks/'
  73 +Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil?
  74 +Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil?
  75 +Settings.gitlab_shell['repos_path'] ||= '/home/git/repositories/'
  76 +Settings.gitlab_shell['ssh_host'] ||= (Settings.gitlab.host || 'localhost')
  77 +Settings.gitlab_shell['ssh_port'] ||= 22
  78 +Settings.gitlab_shell['ssh_user'] ||= Settings.gitlab.user
  79 +Settings.gitlab_shell['owner_group'] ||= Settings.gitlab.user
  80 +Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_ssh_path_prefix)
75 81
  82 +#
  83 +# Backup
  84 +#
76 Settings['backup'] ||= Settingslogic.new({}) 85 Settings['backup'] ||= Settingslogic.new({})
77 Settings.backup['keep_time'] ||= 0 86 Settings.backup['keep_time'] ||= 0
78 Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root) 87 Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
79 88
  89 +#
  90 +# Git
  91 +#
80 Settings['git'] ||= Settingslogic.new({}) 92 Settings['git'] ||= Settingslogic.new({})
81 Settings.git['max_size'] ||= 5242880 # 5.megabytes 93 Settings.git['max_size'] ||= 5242880 # 5.megabytes
82 Settings.git['bin_path'] ||= '/usr/bin/git' 94 Settings.git['bin_path'] ||= '/usr/bin/git'
config/routes.rb
@@ -18,9 +18,9 @@ Gitlab::Application.routes.draw do @@ -18,9 +18,9 @@ Gitlab::Application.routes.draw do
18 # Enable Grack support 18 # Enable Grack support
19 mount Grack::Bundle.new({ 19 mount Grack::Bundle.new({
20 git_path: Gitlab.config.git.bin_path, 20 git_path: Gitlab.config.git.bin_path,
21 - project_root: Gitlab.config.gitolite.repos_path,  
22 - upload_pack: Gitlab.config.gitolite.upload_pack,  
23 - receive_pack: Gitlab.config.gitolite.receive_pack 21 + project_root: Gitlab.config.gitlab_shell.repos_path,
  22 + upload_pack: Gitlab.config.gitlab_shell.upload_pack,
  23 + receive_pack: Gitlab.config.gitlab_shell.receive_pack
24 }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) } 24 }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
25 25
26 # 26 #
features/support/env.rb
@@ -31,9 +31,9 @@ DatabaseCleaner.strategy = :truncation @@ -31,9 +31,9 @@ DatabaseCleaner.strategy = :truncation
31 31
32 Spinach.hooks.before_scenario do 32 Spinach.hooks.before_scenario do
33 # Use tmp dir for FS manipulations 33 # Use tmp dir for FS manipulations
34 - Gitlab.config.gitolite.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))  
35 - FileUtils.rm_rf Gitlab.config.gitolite.repos_path  
36 - FileUtils.mkdir_p Gitlab.config.gitolite.repos_path 34 + Gitlab.config.gitlab_shell.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
  35 + FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
  36 + FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
37 end 37 end
38 38
39 Spinach.hooks.after_scenario do 39 Spinach.hooks.after_scenario do
lib/gitlab/backend/shell.rb
@@ -44,7 +44,7 @@ module Gitlab @@ -44,7 +44,7 @@ module Gitlab
44 44
45 45
46 def url_to_repo path 46 def url_to_repo path
47 - Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git" 47 + Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
48 end 48 end
49 end 49 end
50 end 50 end
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.gitolite.repos_path, new_dir) 18 + new_dir_path = File.join(Gitlab.config.gitlab_shell.repos_path, new_dir)
19 FileUtils.mkdir( new_dir_path, mode: 0770 ) unless File.exists?(new_dir_path) 19 FileUtils.mkdir( new_dir_path, mode: 0770 ) unless File.exists?(new_dir_path)
20 20
21 - old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git") 21 + old_path = File.join(Gitlab.config.gitlab_shell.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/gitolited.rb
1 # == Gitolited mixin 1 # == Gitolited mixin
2 # 2 #
3 -# Provide a shortcut to Gitlab::Gitolite instance by gitolite 3 +# Provide a shortcut to Gitlab::Shell instance by gitlab_shell
4 # 4 #
5 # Used by Project, UsersProject, etc 5 # Used by Project, UsersProject, etc
6 # 6 #
7 module Gitolited 7 module Gitolited
8 - def gitolite 8 + def gitlab_shell
9 Gitlab::Shell.new 9 Gitlab::Shell.new
10 end 10 end
11 end 11 end
lib/tasks/gitlab/backup.rake
@@ -144,7 +144,7 @@ namespace :gitlab do @@ -144,7 +144,7 @@ namespace :gitlab do
144 144
145 task :restore => :environment do 145 task :restore => :environment do
146 backup_path_repo = File.join(Gitlab.config.backup.path, "repositories") 146 backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
147 - repos_path = Gitlab.config.gitolite.repos_path 147 + repos_path = Gitlab.config.gitlab_shell.repos_path
148 148
149 puts "Restoring repositories ... " 149 puts "Restoring repositories ... "
150 150
lib/tasks/gitlab/check.rake
1 namespace :gitlab do 1 namespace :gitlab do
2 desc "GITLAB | Check the configuration of GitLab and its environment" 2 desc "GITLAB | Check the configuration of GitLab and its environment"
3 task check: %w{gitlab:env:check 3 task check: %w{gitlab:env:check
4 - gitlab:gitolite:check 4 + gitlab:gitlab_shell:check
5 gitlab:sidekiq:check 5 gitlab:sidekiq:check
6 gitlab:app:check} 6 gitlab:app:check}
7 7
@@ -296,10 +296,10 @@ namespace :gitlab do @@ -296,10 +296,10 @@ namespace :gitlab do
296 296
297 # see https://github.com/gitlabhq/gitlabhq/issues/1059 297 # see https://github.com/gitlabhq/gitlabhq/issues/1059
298 def check_issue_1059_shell_profile_error 298 def check_issue_1059_shell_profile_error
299 - gitolite_ssh_user = Gitlab.config.gitolite.ssh_user  
300 - print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... " 299 + gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
  300 + print "Has no \"-e\" in ~#{gitlab_shell_ssh_user}/.profile ... "
301 301
302 - profile_file = File.join(gitolite_user_home, ".profile") 302 + profile_file = File.join(gitlab_shell_user_home, ".profile")
303 303
304 unless File.read(profile_file) =~ /^-e PATH/ 304 unless File.read(profile_file) =~ /^-e PATH/
305 puts "yes".green 305 puts "yes".green
@@ -367,7 +367,7 @@ namespace :gitlab do @@ -367,7 +367,7 @@ namespace :gitlab do
367 367
368 368
369 369
370 - namespace :gitolite do 370 + namespace :gitlab_shell do
371 desc "GITLAB | Check the configuration of Gitolite" 371 desc "GITLAB | Check the configuration of Gitolite"
372 task check: :environment do 372 task check: :environment do
373 warn_user_is_not_gitlab 373 warn_user_is_not_gitlab
@@ -392,25 +392,25 @@ namespace :gitlab do @@ -392,25 +392,25 @@ namespace :gitlab do
392 print "post-receive hook up-to-date? ... " 392 print "post-receive hook up-to-date? ... "
393 393
394 hook_file = "post-receive" 394 hook_file = "post-receive"
395 - gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")  
396 - gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)  
397 - gitolite_ssh_user = Gitlab.config.gitolite.ssh_user 395 + gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
  396 + gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
  397 + gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
398 398
399 - unless File.exists?(gitolite_hook_file) 399 + unless File.exists?(gitlab_shell_hook_file)
400 puts "can't check because of previous errors".magenta 400 puts "can't check because of previous errors".magenta
401 return 401 return
402 end 402 end
403 403
404 - gitolite_hook_content = File.read(gitolite_hook_file) 404 + gitlab_shell_hook_content = File.read(gitlab_shell_hook_file)
405 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file) 405 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
406 gitlab_hook_content = File.read(gitlab_hook_file) 406 gitlab_hook_content = File.read(gitlab_hook_file)
407 407
408 - if gitolite_hook_content == gitlab_hook_content 408 + if gitlab_shell_hook_content == gitlab_hook_content
409 puts "yes".green 409 puts "yes".green
410 else 410 else
411 puts "no".red 411 puts "no".red
412 try_fixing_it( 412 try_fixing_it(
413 - "sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}" 413 + "sudo -u #{gitlab_shell_ssh_user} cp #{gitlab_hook_file} #{gitlab_shell_hook_file}"
414 ) 414 )
415 for_more_information( 415 for_more_information(
416 see_installation_guide_section "Setup GitLab Hooks" 416 see_installation_guide_section "Setup GitLab Hooks"
@@ -422,7 +422,7 @@ namespace :gitlab do @@ -422,7 +422,7 @@ namespace :gitlab do
422 def check_repo_base_exists 422 def check_repo_base_exists
423 print "Repo base directory exists? ... " 423 print "Repo base directory exists? ... "
424 424
425 - repo_base_path = Gitlab.config.gitolite.repos_path 425 + repo_base_path = Gitlab.config.gitlab_shell.repos_path
426 426
427 if File.exists?(repo_base_path) 427 if File.exists?(repo_base_path)
428 puts "yes".green 428 puts "yes".green
@@ -444,7 +444,7 @@ namespace :gitlab do @@ -444,7 +444,7 @@ namespace :gitlab do
444 def check_repo_base_is_not_symlink 444 def check_repo_base_is_not_symlink
445 print "Repo base directory is a symlink? ... " 445 print "Repo base directory is a symlink? ... "
446 446
447 - repo_base_path = Gitlab.config.gitolite.repos_path 447 + repo_base_path = Gitlab.config.gitlab_shell.repos_path
448 unless File.exists?(repo_base_path) 448 unless File.exists?(repo_base_path)
449 puts "can't check because of previous errors".magenta 449 puts "can't check because of previous errors".magenta
450 return 450 return
@@ -464,7 +464,7 @@ namespace :gitlab do @@ -464,7 +464,7 @@ namespace :gitlab do
464 def check_repo_base_permissions 464 def check_repo_base_permissions
465 print "Repo base access is drwxrws---? ... " 465 print "Repo base access is drwxrws---? ... "
466 466
467 - repo_base_path = Gitlab.config.gitolite.repos_path 467 + repo_base_path = Gitlab.config.gitlab_shell.repos_path
468 unless File.exists?(repo_base_path) 468 unless File.exists?(repo_base_path)
469 puts "can't check because of previous errors".magenta 469 puts "can't check because of previous errors".magenta
470 return 470 return
@@ -487,23 +487,23 @@ namespace :gitlab do @@ -487,23 +487,23 @@ namespace :gitlab do
487 end 487 end
488 488
489 def check_repo_base_user_and_group 489 def check_repo_base_user_and_group
490 - gitolite_ssh_user = Gitlab.config.gitolite.ssh_user  
491 - gitolite_owner_group = Gitlab.config.gitolite.owner_group  
492 - print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_owner_group}? ... " 490 + gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
  491 + gitlab_shell_owner_group = Gitlab.config.gitlab_shell.owner_group
  492 + print "Repo base owned by #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group}? ... "
493 493
494 - repo_base_path = Gitlab.config.gitolite.repos_path 494 + repo_base_path = Gitlab.config.gitlab_shell.repos_path
495 unless File.exists?(repo_base_path) 495 unless File.exists?(repo_base_path)
496 puts "can't check because of previous errors".magenta 496 puts "can't check because of previous errors".magenta
497 return 497 return
498 end 498 end
499 499
500 - if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) &&  
501 - File.stat(repo_base_path).gid == gid_for(gitolite_owner_group) 500 + if File.stat(repo_base_path).uid == uid_for(gitlab_shell_ssh_user) &&
  501 + File.stat(repo_base_path).gid == gid_for(gitlab_shell_owner_group)
502 puts "yes".green 502 puts "yes".green
503 else 503 else
504 puts "no".red 504 puts "no".red
505 try_fixing_it( 505 try_fixing_it(
506 - "sudo chown -R #{gitolite_ssh_user}:#{gitolite_owner_group} #{repo_base_path}" 506 + "sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}"
507 ) 507 )
508 for_more_information( 508 for_more_information(
509 see_installation_guide_section "Gitolite" 509 see_installation_guide_section "Gitolite"
@@ -516,11 +516,11 @@ namespace :gitlab do @@ -516,11 +516,11 @@ namespace :gitlab do
516 print "post-receive hooks in repos are links: ... " 516 print "post-receive hooks in repos are links: ... "
517 517
518 hook_file = "post-receive" 518 hook_file = "post-receive"
519 - gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")  
520 - gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)  
521 - gitolite_ssh_user = Gitlab.config.gitolite.ssh_user 519 + gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
  520 + gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
  521 + gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
522 522
523 - unless File.exists?(gitolite_hook_file) 523 + unless File.exists?(gitlab_shell_hook_file)
524 puts "can't check because of previous errors".magenta 524 puts "can't check because of previous errors".magenta
525 return 525 return
526 end 526 end
@@ -542,7 +542,7 @@ namespace :gitlab do @@ -542,7 +542,7 @@ namespace :gitlab do
542 unless File.exists?(project_hook_file) 542 unless File.exists?(project_hook_file)
543 puts "missing".red 543 puts "missing".red
544 try_fixing_it( 544 try_fixing_it(
545 - "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" 545 + "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
546 ) 546 )
547 for_more_information( 547 for_more_information(
548 "lib/support/rewrite-hooks.sh" 548 "lib/support/rewrite-hooks.sh"
@@ -552,12 +552,12 @@ namespace :gitlab do @@ -552,12 +552,12 @@ namespace :gitlab do
552 end 552 end
553 553
554 if File.lstat(project_hook_file).symlink? && 554 if File.lstat(project_hook_file).symlink? &&
555 - File.realpath(project_hook_file) == File.realpath(gitolite_hook_file) 555 + File.realpath(project_hook_file) == File.realpath(gitlab_shell_hook_file)
556 puts "ok".green 556 puts "ok".green
557 else 557 else
558 puts "not a link to Gitolite's hook".red 558 puts "not a link to Gitolite's hook".red
559 try_fixing_it( 559 try_fixing_it(
560 - "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" 560 + "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
561 ) 561 )
562 for_more_information( 562 for_more_information(
563 "lib/support/rewrite-hooks.sh" 563 "lib/support/rewrite-hooks.sh"
@@ -572,19 +572,19 @@ namespace :gitlab do @@ -572,19 +572,19 @@ namespace :gitlab do
572 # Helper methods 572 # Helper methods
573 ######################## 573 ########################
574 574
575 - def gitolite_user_home  
576 - File.expand_path("~#{Gitlab.config.gitolite.ssh_user}") 575 + def gitlab_shell_user_home
  576 + File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
577 end 577 end
578 578
579 - def gitolite_version  
580 - gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION"  
581 - if File.readable?(gitolite_version_file)  
582 - File.read(gitolite_version_file) 579 + def gitlab_shell_version
  580 + gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab_shell/src/VERSION"
  581 + if File.readable?(gitlab_shell_version_file)
  582 + File.read(gitlab_shell_version_file)
583 end 583 end
584 end 584 end
585 585
586 - def has_gitolite3?  
587 - gitolite_version.try(:start_with?, "v3.") 586 + def has_gitlab_shell3?
  587 + gitlab_shell_version.try(:start_with?, "v3.")
588 end 588 end
589 end 589 end
590 590
lib/tasks/gitlab/cleanup.rake
@@ -7,7 +7,7 @@ namespace :gitlab do @@ -7,7 +7,7 @@ namespace :gitlab do
7 7
8 8
9 namespaces = Namespace.pluck(:path) 9 namespaces = Namespace.pluck(:path)
10 - git_base_path = Gitlab.config.gitolite.repos_path 10 + git_base_path = Gitlab.config.gitlab_shell.repos_path
11 all_dirs = Dir.glob(git_base_path + '/*') 11 all_dirs = Dir.glob(git_base_path + '/*')
12 12
13 puts git_base_path.yellow 13 puts git_base_path.yellow
@@ -48,7 +48,7 @@ namespace :gitlab do @@ -48,7 +48,7 @@ namespace :gitlab do
48 warn_user_is_not_gitlab 48 warn_user_is_not_gitlab
49 remove_flag = ENV['REMOVE'] 49 remove_flag = ENV['REMOVE']
50 50
51 - git_base_path = Gitlab.config.gitolite.repos_path 51 + git_base_path = Gitlab.config.gitlab_shell.repos_path
52 all_dirs = Dir.glob(git_base_path + '/*') 52 all_dirs = Dir.glob(git_base_path + '/*')
53 53
54 global_projects = Project.where(namespace_id: nil).pluck(:path) 54 global_projects = Project.where(namespace_id: nil).pluck(:path)
@@ -68,13 +68,6 @@ namespace :gitlab do @@ -68,13 +68,6 @@ namespace :gitlab do
68 global_projects.include?(path) 68 global_projects.include?(path)
69 end 69 end
70 70
71 - # skip gitolite admin  
72 - all_dirs.reject! do |dir|  
73 - repo_name = File.basename dir  
74 - repo_name == 'gitolite-admin.git'  
75 - end  
76 -  
77 -  
78 all_dirs.each do |dir_path| 71 all_dirs.each do |dir_path|
79 if remove_flag 72 if remove_flag
80 if FileUtils.rm_rf dir_path 73 if FileUtils.rm_rf dir_path
lib/tasks/gitlab/enable_namespaces.rake
@@ -6,11 +6,6 @@ namespace :gitlab do @@ -6,11 +6,6 @@ namespace :gitlab do
6 migrate_user_namespaces 6 migrate_user_namespaces
7 migrate_groups 7 migrate_groups
8 migrate_projects 8 migrate_projects
9 -  
10 - puts "Rebuild Gitolite ... "  
11 - gitolite = Gitlab::Gitolite.new  
12 - gitolite.update_repositories(Project.where('namespace_id IS NOT NULL'))  
13 - puts "... #{"done".green}"  
14 end 9 end
15 10
16 def migrate_user_namespaces 11 def migrate_user_namespaces
@@ -80,7 +75,7 @@ namespace :gitlab do @@ -80,7 +75,7 @@ namespace :gitlab do
80 end 75 end
81 76
82 def migrate_projects 77 def migrate_projects
83 - git_path = Gitlab.config.gitolite.repos_path 78 + git_path = Gitlab.config.gitlab_shell.repos_path
84 puts "\nMove projects in groups into respective directories ... ".blue 79 puts "\nMove projects in groups into respective directories ... ".blue
85 Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project| 80 Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project|
86 next unless project.group 81 next unless project.group
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.gitolite.repos_path 15 + git_base_path = Gitlab.config.gitlab_shell.repos_path
16 repos_to_import = Dir.glob(git_base_path + '/*') 16 repos_to_import = Dir.glob(git_base_path + '/*')
17 17
18 namespaces = Namespace.pluck(:path) 18 namespaces = Namespace.pluck(:path)
@@ -26,7 +26,6 @@ namespace :gitlab do @@ -26,7 +26,6 @@ namespace :gitlab do
26 # skip if not git repo 26 # skip if not git repo
27 next unless repo_name =~ /.git$/ 27 next unless repo_name =~ /.git$/
28 28
29 - # skip gitolite admin  
30 next if repo_name == 'gitolite-admin.git' 29 next if repo_name == 'gitolite-admin.git'
31 30
32 path = repo_name.sub(/\.git$/, '') 31 path = repo_name.sub(/\.git$/, '')
lib/tasks/gitlab/info.rake
@@ -54,16 +54,16 @@ namespace :gitlab do @@ -54,16 +54,16 @@ namespace :gitlab do
54 54
55 55
56 # check Gitolite version 56 # check Gitolite version
57 - gitolite_version_file = "#{Gitlab.config.gitolite.repos_path}/../gitlab-shell/VERSION"  
58 - if File.readable?(gitolite_version_file)  
59 - gitolite_version = File.read(gitolite_version_file) 57 + gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.repos_path}/../gitlab-shell/VERSION"
  58 + if File.readable?(gitlab_shell_version_file)
  59 + gitlab_shell_version = File.read(gitlab_shell_version_file)
60 end 60 end
61 61
62 puts "" 62 puts ""
63 puts "GitLab Shell".yellow 63 puts "GitLab Shell".yellow
64 - puts "Version:\t#{gitolite_version || "unknown".red}"  
65 - puts "Repositories:\t#{Gitlab.config.gitolite.repos_path}"  
66 - puts "Hooks:\t\t#{Gitlab.config.gitolite.hooks_path}" 64 + puts "Version:\t#{gitlab_shell_version || "unknown".red}"
  65 + puts "Repositories:\t#{Gitlab.config.gitlab_shell.repos_path}"
  66 + puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}"
67 puts "Git:\t\t#{Gitlab.config.git.bin_path}" 67 puts "Git:\t\t#{Gitlab.config.git.bin_path}"
68 68
69 end 69 end
lib/tasks/gitlab/shell.rake
@@ -8,7 +8,7 @@ namespace :gitlab do @@ -8,7 +8,7 @@ namespace :gitlab do
8 desc "GITLAB | Build missing projects" 8 desc "GITLAB | Build missing projects"
9 task build_missing_projects: :environment do 9 task build_missing_projects: :environment do
10 Project.find_each(batch_size: 1000) do |project| 10 Project.find_each(batch_size: 1000) do |project|
11 - path_to_repo = File.join(Gitlab.config.gitolite.repos_path, "#{project.path_with_namespace}.git") 11 + path_to_repo = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
12 if File.exists?(path_to_repo) 12 if File.exists?(path_to_repo)
13 print '-' 13 print '-'
14 else 14 else
lib/tasks/sidekiq.rake
@@ -6,7 +6,7 @@ namespace :sidekiq do @@ -6,7 +6,7 @@ namespace :sidekiq do
6 6
7 desc "GITLAB | Start sidekiq" 7 desc "GITLAB | Start sidekiq"
8 task :start do 8 task :start do
9 - run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitolite,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &" 9 + run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &"
10 end 10 end
11 11
12 def pidfile 12 def pidfile
spec/spec_helper.rb
@@ -35,7 +35,7 @@ RSpec.configure do |config| @@ -35,7 +35,7 @@ RSpec.configure do |config|
35 config.before do 35 config.before do
36 # Use tmp dir for FS manipulations 36 # Use tmp dir for FS manipulations
37 temp_repos_path = Rails.root.join('tmp', 'test-git-base-path') 37 temp_repos_path = Rails.root.join('tmp', 'test-git-base-path')
38 - Gitlab.config.gitolite.stub(repos_path: temp_repos_path) 38 + Gitlab.config.gitlab_shell.stub(repos_path: temp_repos_path)
39 FileUtils.rm_rf temp_repos_path 39 FileUtils.rm_rf temp_repos_path
40 FileUtils.mkdir_p temp_repos_path 40 FileUtils.mkdir_p temp_repos_path
41 end 41 end