Commit d64090b8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

No gitolite in project any more

parent 9b487c0aeeb8
v 5.0.0
- replaced gitolite with gitlab-shell
- Replaced gitolite with gitlab-shell
v 4.2.0
- Teams
- User show page. Via /u/username
- Show help contents on pages for better navigation
......
......@@ -41,9 +41,7 @@ def update
end
def destroy
# Delete team first in order to prevent multiple gitolite calls
@project.team.truncate
@project.destroy
redirect_to admin_projects_path, notice: 'Project was successfully deleted.'
......
class ErrorsController < ApplicationController
def githost
render "errors/gitolite"
end
end
......@@ -93,9 +93,7 @@ def wall
def destroy
return access_denied! unless can?(current_user, :remove_project, project)
# Delete team first in order to prevent multiple gitolite calls
project.team.truncate
project.destroy
respond_to do |format|
......
......@@ -31,8 +31,6 @@ class Namespace < ActiveRecord::Base
scope :root, where('type IS NULL')
attr_accessor :require_update_gitolite
def self.search query
where("name LIKE :query OR path LIKE :query", query: "%#{query}%")
end
......@@ -60,13 +58,13 @@ def dir_exists?
end
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
def move_dir
if path_changed?
old_path = File.join(Gitlab.config.gitolite.repos_path, path_was)
new_path = File.join(Gitlab.config.gitolite.repos_path, path)
old_path = File.join(Gitlab.config.gitlab_shell.repos_path, path_was)
new_path = File.join(Gitlab.config.gitlab_shell.repos_path, path)
if File.exists?(new_path)
raise "Already exists"
end
......@@ -81,7 +79,6 @@ def move_dir
FileUtils.mv( old_path, new_path )
send_update_instructions
@require_update_gitolite = true
rescue Exception => e
raise "Namespace move error #{old_path} #{new_path}"
end
......@@ -89,7 +86,7 @@ def move_dir
end
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 )
end
......
......@@ -140,10 +140,6 @@ def repository
nil
end
def git_error?
error_code == :gitolite
end
def saved?
id && valid?
end
......@@ -157,7 +153,7 @@ def check_limit
end
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)
errors.add(:path, "like #{path} is not allowed")
......@@ -450,7 +446,7 @@ def repo
end
def url_to_repo
gitolite.url_to_repo(path_with_namespace)
gitlab_shell.url_to_repo(path_with_namespace)
end
def namespace_dir
......
......@@ -25,7 +25,7 @@ def raw
end
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
def repo
......
......@@ -22,7 +22,7 @@
%b
Path:
%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
%td
%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
include Sidekiq::Worker
include Gitolited
sidekiq_options queue: :gitolite
sidekiq_options queue: :gitlab_shell
def perform(action, *arg)
gitolite.send(action, *arg)
gitlab_shell.send(action, *arg)
end
end
......@@ -5,10 +5,10 @@ class PostReceive
def perform(repo_path, oldrev, newrev, ref, identifier)
if repo_path.start_with?(Gitlab.config.gitolite.repos_path.to_s)
repo_path.gsub!(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.gitlab_shell.repos_path.to_s, "")
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
repo_path.gsub!(/.git$/, "")
......@@ -22,7 +22,8 @@ def perform(repo_path, oldrev, newrev, ref, identifier)
end
# 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
User.find_by_email(email) if email
elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
......
......@@ -5,8 +5,7 @@
# How to use:
# 1. copy file as gitlab.yml
# 2. Replace gitlab -> host with your domain
# 3. Replace gitolite -> ssh_host with your domain
# 4. Replace gitlab -> email_from
# 3. Replace gitlab -> email_from
#
# 1. GitLab app settings
......@@ -22,8 +21,8 @@ gitlab:
# Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed
# relative_url_root: /gitlab
# Uncomment and customize if you can't use the default user to run GitLab (default: 'gitlab')
# user: user123
# Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
# user: git
## Email settings
# Email address used in the "From" field in mails sent by GitLab
......@@ -103,21 +102,18 @@ backup:
path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
# keep_time: 604800 # default: 0 (forever) (in seconds)
## Gitolite settings
gitolite:
## GitLab Shell settings
gitlab_shell:
# REPOS_PATH MUST NOT BE A SYMLINK!!!
repos_path: /home/git/repositories/
hooks_path: /home/git/gitlab-shell/hooks/
admin_key: gitlab
# Git over HTTP
upload_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)
# owner_group: group123
# If you use non-standart ssh port you need to specify it
# ssh_port: 22
## Git settings
# CAUTION!
......
......@@ -8,11 +8,11 @@ def gitlab_on_non_standard_port?
private
def build_gitolite_ssh_path_prefix
if gitolite.ssh_port != 22
"ssh://#{gitolite.ssh_user}@#{gitolite.ssh_host}:#{gitolite.ssh_port}/"
def build_gitlab_shell_ssh_path_prefix
if gitlab_shell.ssh_port != 22
"ssh://#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:#{gitlab_shell.ssh_port}/"
else
"#{gitolite.ssh_user}@#{gitolite.ssh_host}:"
"#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:"
end
end
......@@ -41,6 +41,9 @@ def build_gitlab_url
Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil?
Settings.omniauth['providers'] ||= []
#
# GitLab
#
Settings['gitlab'] ||= Settingslogic.new({})
Settings.gitlab['default_projects_limit'] ||= 10
Settings.gitlab['host'] ||= 'localhost'
......@@ -54,29 +57,38 @@ def build_gitlab_url
Settings.gitlab['user'] ||= 'git'
Settings.gitlab['signup_enabled'] ||= false
#
# Gravatar
#
Settings['gravatar'] ||= Settingslogic.new({})
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['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
Settings['gitolite'] ||= Settingslogic.new({})
Settings.gitolite['admin_key'] ||= 'gitlab'
Settings.gitolite['admin_uri'] ||= 'git@localhost:gitolite-admin'
Settings.gitolite['config_file'] ||= 'gitolite.conf'
Settings.gitolite['hooks_path'] ||= '/home/git/share/gitolite/hooks/'
Settings.gitolite['receive_pack'] = true if Settings.gitolite['receive_pack'].nil?
Settings.gitolite['upload_pack'] = true if Settings.gitolite['upload_pack'].nil?
Settings.gitolite['repos_path'] ||= '/home/git/repositories/'
Settings.gitolite['ssh_host'] ||= (Settings.gitlab.host || 'localhost')
Settings.gitolite['ssh_port'] ||= 22
Settings.gitolite['ssh_user'] ||= 'git'
Settings.gitolite['owner_group'] ||= Settings.gitolite.ssh_user
Settings.gitolite['ssh_path_prefix'] ||= Settings.send(:build_gitolite_ssh_path_prefix)
#
# GitLab Shell
#
Settings['gitlab_shell'] ||= Settingslogic.new({})
Settings.gitlab_shell['hooks_path'] ||= '/home/git/gitlab-shell/hooks/'
Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil?
Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil?
Settings.gitlab_shell['repos_path'] ||= '/home/git/repositories/'
Settings.gitlab_shell['ssh_host'] ||= (Settings.gitlab.host || 'localhost')
Settings.gitlab_shell['ssh_port'] ||= 22
Settings.gitlab_shell['ssh_user'] ||= Settings.gitlab.user
Settings.gitlab_shell['owner_group'] ||= Settings.gitlab.user
Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_ssh_path_prefix)
#
# Backup
#
Settings['backup'] ||= Settingslogic.new({})
Settings.backup['keep_time'] ||= 0
Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
#
# Git
#
Settings['git'] ||= Settingslogic.new({})
Settings.git['max_size'] ||= 5242880 # 5.megabytes
Settings.git['bin_path'] ||= '/usr/bin/git'
......
......@@ -18,9 +18,9 @@
# Enable Grack support
mount Grack::Bundle.new({
git_path: Gitlab.config.git.bin_path,
project_root: Gitlab.config.gitolite.repos_path,
upload_pack: Gitlab.config.gitolite.upload_pack,
receive_pack: Gitlab.config.gitolite.receive_pack
project_root: Gitlab.config.gitlab_shell.repos_path,
upload_pack: Gitlab.config.gitlab_shell.upload_pack,
receive_pack: Gitlab.config.gitlab_shell.receive_pack
}), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
#
......
......@@ -31,9 +31,9 @@
Spinach.hooks.before_scenario do
# Use tmp dir for FS manipulations
Gitlab.config.gitolite.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
FileUtils.rm_rf Gitlab.config.gitolite.repos_path
FileUtils.mkdir_p Gitlab.config.gitolite.repos_path
Gitlab.config.gitlab_shell.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
end
Spinach.hooks.after_scenario do
......
......@@ -44,7 +44,7 @@ def remove_key(key_id, key_content)
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
......@@ -15,10 +15,10 @@ def initialize(project, old_dir, new_dir)
def execute
# 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)
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")
if File.exists? new_path
......
# == 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
#
module Gitolited
def gitolite
def gitlab_shell
Gitlab::Shell.new
end
end
......@@ -144,7 +144,7 @@ namespace :gitlab do
task :restore => :environment do
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 ... "
......
namespace :gitlab do
desc "GITLAB | Check the configuration of GitLab and its environment"
task check: %w{gitlab:env:check
gitlab:gitolite:check
gitlab:gitlab_shell:check
gitlab:sidekiq:check
gitlab:app:check}
......@@ -296,10 +296,10 @@ namespace :gitlab do
# see https://github.com/gitlabhq/gitlabhq/issues/1059
def check_issue_1059_shell_profile_error
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
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/
puts "yes".green
......@@ -367,7 +367,7 @@ namespace :gitlab do
namespace :gitolite do
namespace :gitlab_shell do
desc "GITLAB | Check the configuration of Gitolite"
task check: :environment do
warn_user_is_not_gitlab
......@@ -392,25 +392,25 @@ namespace :gitlab do
print "post-receive hook up-to-date? ... "
hook_file = "post-receive"
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
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
return
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_content = File.read(gitlab_hook_file)
if gitolite_hook_content == gitlab_hook_content
if gitlab_shell_hook_content == gitlab_hook_content
puts "yes".green
else
puts "no".red
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(
see_installation_guide_section "Setup GitLab Hooks"
......@@ -422,7 +422,7 @@ namespace :gitlab do
def check_repo_base_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)
puts "yes".green
......@@ -444,7 +444,7 @@ namespace :gitlab do
def check_repo_base_is_not_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)
puts "can't check because of previous errors".magenta
return
......@@ -464,7 +464,7 @@ namespace :gitlab do
def check_repo_base_permissions
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)
puts "can't check because of previous errors".magenta
return
......@@ -487,23 +487,23 @@ namespace :gitlab do
end
def check_repo_base_user_and_group
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
gitolite_owner_group = Gitlab.config.gitolite.owner_group
print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_owner_group}? ... "
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
gitlab_shell_owner_group = Gitlab.config.gitlab_shell.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)
puts "can't check because of previous errors".magenta
return
end
if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) &&
File.stat(repo_base_path).gid == gid_for(gitolite_owner_group)
if File.stat(repo_base_path).uid == uid_for(gitlab_shell_ssh_user) &&
File.stat(repo_base_path).gid == gid_for(gitlab_shell_owner_group)
puts "yes".green
else
puts "no".red
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(
see_installation_guide_section "Gitolite"
......@@ -516,11 +516,11 @@ namespace :gitlab do
print "post-receive hooks in repos are links: ... "
hook_file = "post-receive"
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
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
return
end
......@@ -542,7 +542,7 @@ namespace :gitlab do
unless File.exists?(project_hook_file)
puts "missing".red
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(
"lib/support/rewrite-hooks.sh"
......@@ -552,12 +552,12 @@ namespace :gitlab do
end
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
else
puts "not a link to Gitolite's hook".red
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(
"lib/support/rewrite-hooks.sh"
......@@ -572,19 +572,19 @@ namespace :gitlab do
# Helper methods
########################
def gitolite_user_home
File.expand_path("~#{Gitlab.config.gitolite.ssh_user}")
def gitlab_shell_user_home
File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
end
def gitolite_version
gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION"
if File.readable?(gitolite_version_file)
File.read(gitolite_version_file)
def gitlab_shell_version
gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab_shell/src/VERSION"
if File.readable?(gitlab_shell_version_file)
File.read(gitlab_shell_version_file)
end
end
def has_gitolite3?
gitolite_version.try(:start_with?, "v3.")
def has_gitlab_shell3?
gitlab_shell_version.try(:start_with?, "v3.")
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