Commit d64090b8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

No gitolite in project any more

parent 8e0b58d7
v 5.0.0 v 5.0.0
- replaced gitolite with gitlab-shell - Replaced gitolite with gitlab-shell
v 4.2.0 v 4.2.0
- Teams
- User show page. Via /u/username - User show page. Via /u/username
- Show help contents on pages for better navigation - Show help contents on pages for better navigation
......
...@@ -41,9 +41,7 @@ class Admin::ProjectsController < Admin::ApplicationController ...@@ -41,9 +41,7 @@ class Admin::ProjectsController < Admin::ApplicationController
end end
def destroy def destroy
# Delete team first in order to prevent multiple gitolite calls
@project.team.truncate @project.team.truncate
@project.destroy @project.destroy
redirect_to admin_projects_path, notice: 'Project was successfully deleted.' redirect_to admin_projects_path, notice: 'Project was successfully deleted.'
......
class ErrorsController < ApplicationController class ErrorsController < ApplicationController
def githost
render "errors/gitolite"
end
end end
...@@ -93,9 +93,7 @@ class ProjectsController < ProjectResourceController ...@@ -93,9 +93,7 @@ class ProjectsController < ProjectResourceController
def destroy def destroy
return access_denied! unless can?(current_user, :remove_project, project) return access_denied! unless can?(current_user, :remove_project, project)
# Delete team first in order to prevent multiple gitolite calls
project.team.truncate project.team.truncate
project.destroy project.destroy
respond_to do |format| respond_to do |format|
......
...@@ -31,8 +31,6 @@ class Namespace < ActiveRecord::Base ...@@ -31,8 +31,6 @@ class Namespace < ActiveRecord::Base
scope :root, where('type IS NULL') scope :root, where('type IS NULL')
attr_accessor :require_update_gitolite
def self.search query def self.search query
where("name LIKE :query OR path LIKE :query", query: "%#{query}%") where("name LIKE :query OR path LIKE :query", query: "%#{query}%")
end end
...@@ -60,13 +58,13 @@ class Namespace < ActiveRecord::Base ...@@ -60,13 +58,13 @@ class Namespace < ActiveRecord::Base
end end
def namespace_full_path def namespace_full_path
@namespace_full_path ||= File.join(Gitlab.config.gitolite.repos_path, path) @namespace_full_path ||= File.join(Gitlab.config.gitlab_shell.repos_path, path)
end end
def move_dir def move_dir
if path_changed? if path_changed?
old_path = File.join(Gitlab.config.gitolite.repos_path, path_was) old_path = File.join(Gitlab.config.gitlab_shell.repos_path, path_was)
new_path = File.join(Gitlab.config.gitolite.repos_path, path) new_path = File.join(Gitlab.config.gitlab_shell.repos_path, path)
if File.exists?(new_path) if File.exists?(new_path)
raise "Already exists" raise "Already exists"
end end
...@@ -81,7 +79,6 @@ class Namespace < ActiveRecord::Base ...@@ -81,7 +79,6 @@ class Namespace < ActiveRecord::Base
FileUtils.mv( old_path, new_path ) FileUtils.mv( old_path, new_path )
send_update_instructions send_update_instructions
@require_update_gitolite = true
rescue Exception => e rescue Exception => e
raise "Namespace move error #{old_path} #{new_path}" raise "Namespace move error #{old_path} #{new_path}"
end end
...@@ -89,7 +86,7 @@ class Namespace < ActiveRecord::Base ...@@ -89,7 +86,7 @@ class Namespace < ActiveRecord::Base
end end
def rm_dir def rm_dir
dir_path = File.join(Gitlab.config.gitolite.repos_path, path) dir_path = File.join(Gitlab.config.gitlab_shell.repos_path, path)
FileUtils.rm_r( dir_path, force: true ) FileUtils.rm_r( dir_path, force: true )
end end
......
...@@ -140,10 +140,6 @@ class Project < ActiveRecord::Base ...@@ -140,10 +140,6 @@ class Project < ActiveRecord::Base
nil nil
end end
def git_error?
error_code == :gitolite
end
def saved? def saved?
id && valid? id && valid?
end end
...@@ -157,7 +153,7 @@ class Project < ActiveRecord::Base ...@@ -157,7 +153,7 @@ class Project < ActiveRecord::Base
end end
def repo_name def repo_name
denied_paths = %w(gitolite-admin admin dashboard groups help profile projects search) denied_paths = %w(admin dashboard groups help profile projects search)
if denied_paths.include?(path) if denied_paths.include?(path)
errors.add(:path, "like #{path} is not allowed") errors.add(:path, "like #{path} is not allowed")
...@@ -450,7 +446,7 @@ class Project < ActiveRecord::Base ...@@ -450,7 +446,7 @@ class Project < ActiveRecord::Base
end end
def url_to_repo def url_to_repo
gitolite.url_to_repo(path_with_namespace) gitlab_shell.url_to_repo(path_with_namespace)
end end
def namespace_dir def namespace_dir
......
...@@ -25,7 +25,7 @@ class Repository ...@@ -25,7 +25,7 @@ class Repository
end end
def path_to_repo def path_to_repo
@path_to_repo ||= File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git") @path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, "#{path_with_namespace}.git")
end end
def repo def repo
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
%b %b
Path: Path:
%td %td
%span.monospace= File.join(Gitlab.config.gitolite.repos_path, @group.path) %span.monospace= File.join(Gitlab.config.gitlab_shell.repos_path, @group.path)
%tr %tr
%td %td
%b %b
......
%h1.http_status_code 500
%h3.page_title GitLab was unable to access your Gitolite system.
%hr
.git_error_tips
%h4 Tips for Administrator:
%ol
%li
%p
Check git logs in admin area
%li
%p
Check config/gitlab.yml for correct settings.
%li
%p
Diagnostic tool:
%pre
bundle exec rake gitlab:check RAILS_ENV=production
%li
%p
Permissions:
%pre
= preserve do
sudo chown -R git:git #{Gitlab.config.gitolite.repos_path}
sudo chmod -R ug+rwXs #{Gitlab.config.gitolite.repos_path}
...@@ -2,9 +2,9 @@ class GitoliteWorker ...@@ -2,9 +2,9 @@ class GitoliteWorker
include Sidekiq::Worker include Sidekiq::Worker
include Gitolited include Gitolited
sidekiq_options queue: :gitolite sidekiq_options queue: :gitlab_shell
def perform(action, *arg) def perform(action, *arg)
gitolite.send(action, *arg) gitlab_shell.send(action, *arg)
end end
end end
...@@ -5,10 +5,10 @@ class PostReceive ...@@ -5,10 +5,10 @@ class PostReceive
def perform(repo_path, oldrev, newrev, ref, identifier) def perform(repo_path, oldrev, newrev, ref, identifier)
if repo_path.start_with?(Gitlab.config.gitolite.repos_path.to_s) if repo_path.start_with?(Gitlab.config.gitlab_shell.repos_path.to_s)
repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "") repo_path.gsub!(Gitlab.config.gitlab_shell.repos_path.to_s, "")
else else
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}\"") 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}\"")
end end
repo_path.gsub!(/.git$/, "") repo_path.gsub!(/.git$/, "")
...@@ -22,7 +22,8 @@ class PostReceive ...@@ -22,7 +22,8 @@ class PostReceive
end end
# Ignore push from non-gitlab users # Ignore push from non-gitlab users
user = if identifier.eql? Gitlab.config.gitolite.admin_key user = if identifier.nil?
raise identifier.inspect
email = project.repository.commit(newrev).author.email rescue nil email = project.repository.commit(newrev).author.email rescue nil
User.find_by_email(email) if email User.find_by_email(email) if email
elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
# How to use: # How to use:
# 1. copy file as gitlab.yml # 1. copy file as gitlab.yml
# 2. Replace gitlab -> host with your domain # 2. Replace gitlab -> host with your domain
# 3. Replace gitolite -> ssh_host with your domain # 3. Replace gitlab -> email_from
# 4. Replace gitlab -> email_from
# #
# 1. GitLab app settings # 1. GitLab app settings
...@@ -22,8 +21,8 @@ gitlab: ...@@ -22,8 +21,8 @@ gitlab:
# Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed
# relative_url_root: /gitlab # relative_url_root: /gitlab
# Uncomment and customize if you can't use the default user to run GitLab (default: 'gitlab') # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
# user: user123 # user: git
## Email settings ## Email settings
# Email address used in the "From" field in mails sent by GitLab # Email address used in the "From" field in mails sent by GitLab
...@@ -103,21 +102,18 @@ backup: ...@@ -103,21 +102,18 @@ backup:
path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
# keep_time: 604800 # default: 0 (forever) (in seconds) # keep_time: 604800 # default: 0 (forever) (in seconds)
## Gitolite settings ## GitLab Shell settings
gitolite: gitlab_shell:
# REPOS_PATH MUST NOT BE A SYMLINK!!! # REPOS_PATH MUST NOT BE A SYMLINK!!!
repos_path: /home/git/repositories/ repos_path: /home/git/repositories/
hooks_path: /home/git/gitlab-shell/hooks/ hooks_path: /home/git/gitlab-shell/hooks/
admin_key: gitlab
# Git over HTTP
upload_pack: true upload_pack: true
receive_pack: true receive_pack: true
ssh_user: git
ssh_host: localhost
# ssh_port: 22
# config_file: gitolite.conf
# 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) # If you use non-standart ssh port you need to specify it
# owner_group: group123 # ssh_port: 22
## Git settings ## Git settings
# CAUTION! # CAUTION!
......
...@@ -8,11 +8,11 @@ class Settings < Settingslogic ...@@ -8,11 +8,11 @@ class Settings < Settingslogic
private private
def build_gitolite_ssh_path_prefix def build_gitlab_shell_ssh_path_prefix
if gitolite.ssh_port != 22 if gitlab_shell.ssh_port != 22
"ssh://#{gitolite.ssh_user}@#{gitolite.ssh_host}:#{gitolite.ssh_port}/" "ssh://#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:#{gitlab_shell.ssh_port}/"
else else
"#{gitolite.ssh_user}@#{gitolite.ssh_host}:" "#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:"
end end
end end
...@@ -41,6 +41,9 @@ Settings['omniauth'] ||= Settingslogic.new({}) ...@@ -41,6 +41,9 @@ Settings['omniauth'] ||= Settingslogic.new({})
Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil? Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil?
Settings.omniauth['providers'] ||= [] Settings.omniauth['providers'] ||= []
#
# GitLab
#
Settings['gitlab'] ||= Settingslogic.new({}) Settings['gitlab'] ||= Settingslogic.new({})
Settings.gitlab['default_projects_limit'] ||= 10 Settings.gitlab['default_projects_limit'] ||= 10
Settings.gitlab['host'] ||= 'localhost' Settings.gitlab['host'] ||= 'localhost'
...@@ -54,29 +57,38 @@ Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) ...@@ -54,29 +57,38 @@ Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
Settings.gitlab['user'] ||= 'git' Settings.gitlab['user'] ||= 'git'
Settings.gitlab['signup_enabled'] ||= false Settings.gitlab['signup_enabled'] ||= false
#
# Gravatar
#
Settings['gravatar'] ||= Settingslogic.new({}) Settings['gravatar'] ||= Settingslogic.new({})
Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil? Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil?
Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
Settings['gitolite'] ||= Settingslogic.new({}) #
Settings.gitolite['admin_key'] ||= 'gitlab' # GitLab Shell
Settings.gitolite['admin_uri'] ||= 'git@localhost:gitolite-admin' #
Settings.gitolite['config_file'] ||= 'gitolite.conf' Settings['gitlab_shell'] ||= Settingslogic.new({})
Settings.gitolite['hooks_path'] ||= '/home/git/share/gitolite/hooks/' Settings.gitlab_shell['hooks_path'] ||= '/home/git/gitlab-shell/hooks/'
Settings.gitolite['receive_pack'] = true if Settings.gitolite['receive_pack'].nil? Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil?
Settings.gitolite['upload_pack'] = true if Settings.gitolite['upload_pack'].nil? Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil?
Settings.gitolite['repos_path'] ||= '/home/git/repositories/' Settings.gitlab_shell['repos_path'] ||= '/home/git/repositories/'
Settings.gitolite['ssh_host'] ||= (Settings.gitlab.host || 'localhost') Settings.gitlab_shell['ssh_host'] ||= (Settings.gitlab.host || 'localhost')
Settings.gitolite['ssh_port'] ||= 22 Settings.gitlab_shell['ssh_port'] ||= 22
Settings.gitolite['ssh_user'] ||= 'git' Settings.gitlab_shell['ssh_user'] ||= Settings.gitlab.user
Settings.gitolite['owner_group'] ||= Settings.gitolite.ssh_user Settings.gitlab_shell['owner_group'] ||= Settings.gitlab.user
Settings.gitolite['ssh_path_prefix'] ||= Settings.send(:build_gitolite_ssh_path_prefix) Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_ssh_path_prefix)
#
# Backup
#
Settings['backup'] ||= Settingslogic.new({}) Settings['backup'] ||= Settingslogic.new({})
Settings.backup['keep_time'] ||= 0 Settings.backup['keep_time'] ||= 0
Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root) Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
#
# Git
#
Settings['git'] ||= Settingslogic.new({}) Settings['git'] ||= Settingslogic.new({})
Settings.git['max_size'] ||= 5242880 # 5.megabytes Settings.git['max_size'] ||= 5242880 # 5.megabytes
Settings.git['bin_path'] ||= '/usr/bin/git' Settings.git['bin_path'] ||= '/usr/bin/git'
......
...@@ -18,9 +18,9 @@ Gitlab::Application.routes.draw do ...@@ -18,9 +18,9 @@ Gitlab::Application.routes.draw do
# Enable Grack support # Enable Grack support
mount Grack::Bundle.new({ mount Grack::Bundle.new({
git_path: Gitlab.config.git.bin_path, git_path: Gitlab.config.git.bin_path,
project_root: Gitlab.config.gitolite.repos_path, project_root: Gitlab.config.gitlab_shell.repos_path,
upload_pack: Gitlab.config.gitolite.upload_pack, upload_pack: Gitlab.config.gitlab_shell.upload_pack,
receive_pack: Gitlab.config.gitolite.receive_pack receive_pack: Gitlab.config.gitlab_shell.receive_pack
}), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) } }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
# #
......
...@@ -31,9 +31,9 @@ DatabaseCleaner.strategy = :truncation ...@@ -31,9 +31,9 @@ DatabaseCleaner.strategy = :truncation
Spinach.hooks.before_scenario do Spinach.hooks.before_scenario do
# Use tmp dir for FS manipulations # Use tmp dir for FS manipulations
Gitlab.config.gitolite.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path')) Gitlab.config.gitlab_shell.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
FileUtils.rm_rf Gitlab.config.gitolite.repos_path FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
FileUtils.mkdir_p Gitlab.config.gitolite.repos_path FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
end end
Spinach.hooks.after_scenario do Spinach.hooks.after_scenario do
......
...@@ -44,7 +44,7 @@ module Gitlab ...@@ -44,7 +44,7 @@ module Gitlab
def url_to_repo path def url_to_repo path
Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git" Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
end end
end end
end end
...@@ -15,10 +15,10 @@ module Gitlab ...@@ -15,10 +15,10 @@ module Gitlab
def execute def execute
# Create new dir if missing # Create new dir if missing
new_dir_path = File.join(Gitlab.config.gitolite.repos_path, new_dir) new_dir_path = File.join(Gitlab.config.gitlab_shell.repos_path, new_dir)
FileUtils.mkdir( new_dir_path, mode: 0770 ) unless File.exists?(new_dir_path) FileUtils.mkdir( new_dir_path, mode: 0770 ) unless File.exists?(new_dir_path)
old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git") old_path = File.join(Gitlab.config.gitlab_shell.repos_path, old_dir, "#{project.path}.git")
new_path = File.join(new_dir_path, "#{project.path}.git") new_path = File.join(new_dir_path, "#{project.path}.git")
if File.exists? new_path if File.exists? new_path
......
# == Gitolited mixin # == Gitolited mixin
# #
# Provide a shortcut to Gitlab::Gitolite instance by gitolite # Provide a shortcut to Gitlab::Shell instance by gitlab_shell
# #
# Used by Project, UsersProject, etc # Used by Project, UsersProject, etc
# #
module Gitolited module Gitolited
def gitolite def gitlab_shell
Gitlab::Shell.new Gitlab::Shell.new
end end
end end
...@@ -144,7 +144,7 @@ namespace :gitlab do ...@@ -144,7 +144,7 @@ namespace :gitlab do
task :restore => :environment do task :restore => :environment do
backup_path_repo = File.join(Gitlab.config.backup.path, "repositories") backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
repos_path = Gitlab.config.gitolite.repos_path repos_path = Gitlab.config.gitlab_shell.repos_path
puts "Restoring repositories ... " puts "Restoring repositories ... "
......
namespace :gitlab do namespace :gitlab do
desc "GITLAB | Check the configuration of GitLab and its environment" desc "GITLAB | Check the configuration of GitLab and its environment"
task check: %w{gitlab:env:check task check: %w{gitlab:env:check
gitlab:gitolite:check gitlab:gitlab_shell:check
gitlab:sidekiq:check gitlab:sidekiq:check
gitlab:app:check} gitlab:app:check}
...@@ -296,10 +296,10 @@ namespace :gitlab do ...@@ -296,10 +296,10 @@ namespace :gitlab do
# see https://github.com/gitlabhq/gitlabhq/issues/1059 # see https://github.com/gitlabhq/gitlabhq/issues/1059
def check_issue_1059_shell_profile_error def check_issue_1059_shell_profile_error
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... " print "Has no \"-e\" in ~#{gitlab_shell_ssh_user}/.profile ... "
profile_file = File.join(gitolite_user_home, ".profile") profile_file = File.join(gitlab_shell_user_home, ".profile")
unless File.read(profile_file) =~ /^-e PATH/ unless File.read(profile_file) =~ /^-e PATH/
puts "yes".green puts "yes".green
...@@ -367,7 +367,7 @@ namespace :gitlab do ...@@ -367,7 +367,7 @@ namespace :gitlab do
namespace :gitolite do namespace :gitlab_shell do
desc "GITLAB | Check the configuration of Gitolite" desc "GITLAB | Check the configuration of Gitolite"
task check: :environment do task check: :environment do
warn_user_is_not_gitlab warn_user_is_not_gitlab
...@@ -392,25 +392,25 @@ namespace :gitlab do ...@@ -392,25 +392,25 @@ namespace :gitlab do
print "post-receive hook up-to-date? ... " print "post-receive hook up-to-date? ... "
hook_file = "post-receive" hook_file = "post-receive"
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common") gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
unless File.exists?(gitolite_hook_file) unless File.exists?(gitlab_shell_hook_file)
puts "can't check because of previous errors".magenta puts "can't check because of previous errors".magenta
return return
end end
gitolite_hook_content = File.read(gitolite_hook_file) gitlab_shell_hook_content = File.read(gitlab_shell_hook_file)
gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file) gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
gitlab_hook_content = File.read(gitlab_hook_file) gitlab_hook_content = File.read(gitlab_hook_file)
if gitolite_hook_content == gitlab_hook_content if gitlab_shell_hook_content == gitlab_hook_content
puts "yes".green puts "yes".green
else else
puts "no".red puts "no".red
try_fixing_it( try_fixing_it(
"sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}" "sudo -u #{gitlab_shell_ssh_user} cp #{gitlab_hook_file} #{gitlab_shell_hook_file}"
) )
for_more_information( for_more_information(
see_installation_guide_section "Setup GitLab Hooks" see_installation_guide_section "Setup GitLab Hooks"
...@@ -422,7 +422,7 @@ namespace :gitlab do ...@@ -422,7 +422,7 @@ namespace :gitlab do
def check_repo_base_exists def check_repo_base_exists
print "Repo base directory exists? ... " print "Repo base directory exists? ... "
repo_base_path = Gitlab.config.gitolite.repos_path repo_base_path = Gitlab.config.gitlab_shell.repos_path
if File.exists?(repo_base_path) if File.exists?(repo_base_path)
puts "yes".green puts "yes".green
...@@ -444,7 +444,7 @@ namespace :gitlab do ...@@ -444,7 +444,7 @@ namespace :gitlab do
def check_repo_base_is_not_symlink def check_repo_base_is_not_symlink
print "Repo base directory is a symlink? ... " print "Repo base directory is a symlink? ... "
repo_base_path = Gitlab.config.gitolite.repos_path repo_base_path = Gitlab.config.gitlab_shell.repos_path
unless File.exists?(repo_base_path) unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta puts "can't check because of previous errors".magenta
return return
...@@ -464,7 +464,7 @@ namespace :gitlab do ...@@ -464,7 +464,7 @@ namespace :gitlab do
def check_repo_base_permissions def check_repo_base_permissions
print "Repo base access is drwxrws---? ... " print "Repo base access is drwxrws---? ... "
repo_base_path = Gitlab.config.gitolite.repos_path repo_base_path = Gitlab.config.gitlab_shell.repos_path
unless File.exists?(repo_base_path) unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta puts "can't check because of previous errors".magenta
return return
...@@ -487,23 +487,23 @@ namespace :gitlab do ...@@ -487,23 +487,23 @@ namespace :gitlab do
end end
def check_repo_base_user_and_group def check_repo_base_user_and_group
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
gitolite_owner_group = Gitlab.config.gitolite.owner_group gitlab_shell_owner_group = Gitlab.config.gitlab_shell.owner_group
print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_owner_group}? ... " print "Repo base owned by #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group}? ... "
repo_base_path = Gitlab.config.gitolite.repos_path repo_base_path = Gitlab.config.gitlab_shell.repos_path
unless File.exists?(repo_base_path) unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta puts "can't check because of previous errors".magenta
return return
end end
if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) && if File.stat(repo_base_path).uid == uid_for(gitlab_shell_ssh_user) &&
File.stat(repo_base_path).gid == gid_for(gitolite_owner_group) File.stat(repo_base_path).gid == gid_for(gitlab_shell_owner_group)
puts "yes".green puts "yes".green
else else
puts "no".red puts "no".red
try_fixing_it( try_fixing_it(
"sudo chown -R #{gitolite_ssh_user}:#{gitolite_owner_group} #{repo_base_path}" "sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}"
) )
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
...@@ -516,11 +516,11 @@ namespace :gitlab do ...@@ -516,11 +516,11 @@ namespace :gitlab do
print "post-receive hooks in repos are links: ... " print "post-receive hooks in repos are links: ... "
hook_file = "post-receive" hook_file = "post-receive"
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common") gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
unless File.exists?(gitolite_hook_file) unless File.exists?(gitlab_shell_hook_file)
puts "can't check because of previous errors".magenta puts "can't check because of previous errors".magenta
return return
end end
...@@ -542,7 +542,7 @@ namespace :gitlab do ...@@ -542,7 +542,7 @@ namespace :gitlab do
unless File.exists?(project_hook_file) unless File.exists?(project_hook_file)
puts "missing".red puts "missing".red
try_fixing_it( try_fixing_it(
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
) )
for_more_information( for_more_information(
"lib/support/rewrite-hooks.sh" "lib/support/rewrite-hooks.sh"
...@@ -552,12 +552,12 @@ namespace :gitlab do ...@@ -552,12 +552,12 @@ namespace :gitlab do
end end
if File.lstat(project_hook_file).symlink? && if File.lstat(project_hook_file).symlink? &&
File.realpath(project_hook_file) == File.realpath(gitolite_hook_file) File.realpath(project_hook_file) == File.realpath(gitlab_shell_hook_file)
puts "ok".green puts "ok".green
else else
puts "not a link to Gitolite's hook".red puts "not a link to Gitolite's hook".red
try_fixing_it( try_fixing_it(
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
) )
for_more_information( for_more_information(
"lib/support/rewrite-hooks.sh" "lib/support/rewrite-hooks.sh"
...@@ -572,19 +572,19 @@ namespace :gitlab do ...@@ -572,19 +572,19 @@ namespace :gitlab do
# Helper methods # Helper methods
######################## ########################
def gitolite_user_home def gitlab_shell_user_home
File.expand_path("~#{Gitlab.config.gitolite.ssh_user}") File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
end end
def gitolite_version def gitlab_shell_version
gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION" gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab_shell/src/VERSION"
if File.readable?(gitolite_version_file) if File.readable?(gitlab_shell_version_file)
File.read(gitolite_version_file) File.read(gitlab_shell_version_file)
end end
end end
def has_gitolite3? def has_gitlab_shell3?
gitolite_version.try(:start_with?, "v3.") gitlab_shell_version.try(:start_with?, "v3.")
end end
end end
......
...@@ -7,7 +7,7 @@ namespace :gitlab do ...@@ -7,7 +7,7 @@ namespace :gitlab do
namespaces = Namespace.pluck(:path) namespaces = Namespace.pluck(:path)
git_base_path = Gitlab.config.gitolite.repos_path git_base_path = Gitlab.config.gitlab_shell.repos_path
all_dirs = Dir.glob(git_base_path + '/*') all_dirs = Dir.glob(git_base_path + '/*')
puts git_base_path.yellow puts git_base_path.yellow
...@@ -48,7 +48,7 @@ namespace :gitlab do ...@@ -48,7 +48,7 @@ namespace :gitlab do
warn_user_is_not_gitlab warn_user_is_not_gitlab
remove_flag = ENV['REMOVE'] remove_flag = ENV['REMOVE']
git_base_path = Gitlab.config.gitolite.repos_path git_base_path = Gitlab.config.gitlab_shell.repos_path
all_dirs = Dir.glob(git_base_path + '/*') all_dirs = Dir.glob(git_base_path + '/*')
global_projects = Project.where(namespace_id: nil).pluck(:path) global_projects = Project.where(namespace_id: nil).pluck(:path)
...@@ -68,13 +68,6 @@ namespace :gitlab do ...@@ -68,13 +68,6 @@ namespace :gitlab do
global_projects.include?(path) global_projects.include?(path)
end end
# skip gitolite admin
all_dirs.reject! do |dir|
repo_name = File.basename dir
repo_name == 'gitolite-admin.git'
end
all_dirs.each do |dir_path| all_dirs.each do |dir_path|
if remove_flag if remove_flag
if FileUtils.rm_rf dir_path if FileUtils.rm_rf dir_path
......
...@@ -6,11 +6,6 @@ namespace :gitlab do ...@@ -6,11 +6,6 @@ namespace :gitlab do
migrate_user_namespaces migrate_user_namespaces
migrate_groups migrate_groups
migrate_projects migrate_projects
puts "Rebuild Gitolite ... "
gitolite = Gitlab::Gitolite.new
gitolite.update_repositories(Project.where('namespace_id IS NOT NULL'))
puts "... #{"done".green}"
end end
def migrate_user_namespaces def migrate_user_namespaces
...@@ -80,7 +75,7 @@ namespace :gitlab do ...@@ -80,7 +75,7 @@ namespace :gitlab do
end end
def migrate_projects def migrate_projects
git_path = Gitlab.config.gitolite.repos_path git_path = Gitlab.config.gitlab_shell.repos_path
puts "\nMove projects in groups into respective directories ... ".blue puts "\nMove projects in groups into respective directories ... ".blue
Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project| Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project|
next unless project.group next unless project.group
......
...@@ -12,7 +12,7 @@ namespace :gitlab do ...@@ -12,7 +12,7 @@ namespace :gitlab do
desc "GITLAB | Import bare repositories from git_host -> base_path into GitLab project instance" desc "GITLAB | Import bare repositories from git_host -> base_path into GitLab project instance"
task :repos => :environment do task :repos => :environment do
git_base_path = Gitlab.config.gitolite.repos_path git_base_path = Gitlab.config.gitlab_shell.repos_path
repos_to_import = Dir.glob(git_base_path + '/*') repos_to_import = Dir.glob(git_base_path + '/*')
namespaces = Namespace.pluck(:path) namespaces = Namespace.pluck(:path)
...@@ -26,7 +26,6 @@ namespace :gitlab do ...@@ -26,7 +26,6 @@ namespace :gitlab do
# skip if not git repo # skip if not git repo
next unless repo_name =~ /.git$/ next unless repo_name =~ /.git$/
# skip gitolite admin
next if repo_name == 'gitolite-admin.git' next if repo_name == 'gitolite-admin.git'
path = repo_name.sub(/\.git$/, '') path = repo_name.sub(/\.git$/, '')
......
...@@ -54,16 +54,16 @@ namespace :gitlab do ...@@ -54,16 +54,16 @@ namespace :gitlab do
# check Gitolite version # check Gitolite version
gitolite_version_file = "#{Gitlab.config.gitolite.repos_path}/../gitlab-shell/VERSION" gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.repos_path}/../gitlab-shell/VERSION"
if File.readable?(gitolite_version_file) if File.readable?(gitlab_shell_version_file)
gitolite_version = File.read(gitolite_version_file) gitlab_shell_version = File.read(gitlab_shell_version_file)
end end
puts "" puts ""
puts "GitLab Shell".yellow puts "GitLab Shell".yellow
puts "Version:\t#{gitolite_version || "unknown".red}" puts "Version:\t#{gitlab_shell_version || "unknown".red}"
puts "Repositories:\t#{Gitlab.config.gitolite.repos_path}" puts "Repositories:\t#{Gitlab.config.gitlab_shell.repos_path}"
puts "Hooks:\t\t#{Gitlab.config.gitolite.hooks_path}" puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}"
puts "Git:\t\t#{Gitlab.config.git.bin_path}" puts "Git:\t\t#{Gitlab.config.git.bin_path}"
end end
......
...@@ -8,7 +8,7 @@ namespace :gitlab do ...@@ -8,7 +8,7 @@ namespace :gitlab do
desc "GITLAB | Build missing projects" desc "GITLAB | Build missing projects"
task build_missing_projects: :environment do task build_missing_projects: :environment do
Project.find_each(batch_size: 1000) do |project| Project.find_each(batch_size: 1000) do |project|
path_to_repo = File.join(Gitlab.config.gitolite.repos_path, "#{project.path_with_namespace}.git") path_to_repo = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
if File.exists?(path_to_repo) if File.exists?(path_to_repo)
print '-' print '-'
else else
......
...@@ -6,7 +6,7 @@ namespace :sidekiq do ...@@ -6,7 +6,7 @@ namespace :sidekiq do
desc "GITLAB | Start sidekiq" desc "GITLAB | Start sidekiq"
task :start do task :start do
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 &" 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 &"
end end
def pidfile def pidfile
......
...@@ -35,7 +35,7 @@ RSpec.configure do |config| ...@@ -35,7 +35,7 @@ RSpec.configure do |config|
config.before do config.before do
# Use tmp dir for FS manipulations # Use tmp dir for FS manipulations
temp_repos_path = Rails.root.join('tmp', 'test-git-base-path') temp_repos_path = Rails.root.join('tmp', 'test-git-base-path')
Gitlab.config.gitolite.stub(repos_path: temp_repos_path) Gitlab.config.gitlab_shell.stub(repos_path: temp_repos_path)
FileUtils.rm_rf temp_repos_path FileUtils.rm_rf temp_repos_path
FileUtils.mkdir_p temp_repos_path FileUtils.mkdir_p temp_repos_path
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment