From 768da57fe4aeb9fddc96620d5a91d5a2974e438d Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:28:50 -0700 Subject: [PATCH 01/23] clarify when database.yml needs to be updated Clarify that database.yml should be updated if you are running a MySQL Database. Remove wording that de-emphasises importance of update. --- doc/update/7.3-to-7.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67..c50eb01d27 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -101,7 +101,7 @@ timeout 60 * HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting -#### Update database.yml config file(for mysql only) if needed (basically it is required for old gitlab installations) +#### MySQL Databases: Update database.yml config file * Add `collation: utf8_general_ci` to config/database.yml as seen in [config/database.yml.mysql](config/database.yml.mysql) From 35b1a036d79382c9311d4c6fac0cdbefb067e940 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:33:51 -0700 Subject: [PATCH 02/23] stop gitlab before mysql optimizations, run checks Update MySQL optimizations to reflect doing updates after GitLab has already been started back up. --- doc/update/7.3-to-7.4.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67..e8d72bf231 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -134,6 +134,9 @@ More details can be found at the [integration documentation](../integration/goog Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand. ``` +# Stop GitLab +sudo service gitlab stop + # Secure your MySQL installation (added in GitLab 6.2) sudo mysql_secure_installation @@ -195,6 +198,9 @@ mysql> \q # Set production -> username: git # Set production -> password: the password your replaced $password with earlier sudo -u git -H editor /home/git/gitlab/config/database.yml + +# Run thorough check +sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production ``` From 76e2ae8148e8fd72048cc1c9d57e5b5f5452aae9 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:39:01 -0700 Subject: [PATCH 03/23] actually give command necessary to update unicorn Give command to update unicorn.rb rather than just say you need to do it. --- doc/update/7.3-to-7.4.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67..045e611b3e 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -93,8 +93,8 @@ git diff origin/7-3-stable:config/gitlab.yml.example origin/7-4-stable:config/gi #### Change timeout for unicorn ``` -# config/unicorn.rb -timeout 60 +# set timeout to 60 +sudo -u git -H editor config/unicorn.rb ``` #### Change nginx https settings From 9a92e53f622f29388851f25abe191dad38e35516 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:49:59 -0700 Subject: [PATCH 04/23] stop gitlab before backup Stopping gitlab before backup ensures that backup has everything before upgrade incase something goes wrong. Also remove extra cd. --- doc/update/7.3-to-7.4.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67..6ef91913bb 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -1,22 +1,18 @@ # From 7.3 to 7.4 -### 0. Backup +### 0. Stop server + + sudo service gitlab stop + +### 1. Backup ```bash cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production -``` - -### 1. Stop server - -```bash -sudo service gitlab stop -``` ### 2. Get latest code ```bash -cd /home/git/gitlab sudo -u git -H git fetch --all sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically ``` From 3e6b284bd0cf597f6446e1990a53acb806fb359a Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:51:35 -0700 Subject: [PATCH 05/23] stop gitlab before backup --- doc/update/6.x-or-7.x-to-7.4.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index e923060223..c332e5fe26 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -13,7 +13,11 @@ possible to edit the label text and color. The characters `?`, `&` and `,` are no longer allowed however so those will be removed from your tags during the database migrations for GitLab 7.2. -## 0. Backup +## 0. Stop server + + sudo service gitlab stop + +## 1. Backup It's useful to make a backup just in case things go south: (With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) @@ -23,10 +27,6 @@ cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ``` -## 1. Stop server - - sudo service gitlab stop - ## 2. Update Ruby If you are still using Ruby 1.9.3 or below, you will need to update Ruby. From 0ff6105589960bc617b8e974874f1f22a5841ad0 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 02:08:01 -0700 Subject: [PATCH 06/23] add missing configure Redis to use sockets Add details from 7.2-to-7.3.md. Replaces https://github.com/gitlabhq/gitlabhq/pull/8047. --- doc/update/6.x-or-7.x-to-7.4.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index e923060223..4b7ed03f49 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -99,6 +99,8 @@ sudo apt-get install pkg-config cmake sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf # Enable Redis socket for default Debian / Ubuntu path echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf + # Be sure redis group can write to the socket, enable only if supported (>= redis 2.4.0). + sudo sed -i '/# unixsocketperm/ s/^# unixsocketperm.*/unixsocketperm 0775/' /etc/redis/redis.conf # Activate the changes to redis.conf sudo service redis-server restart # Add git to the redis group From 4880b91ff1be9dda28dfe2b3feb0cd746cadf73e Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 02:13:15 -0700 Subject: [PATCH 07/23] add optimizations for mysql to 6.x->7.4 guide Add mysql optimizations from 7.3-to-7.4.md. --- doc/update/6.x-or-7.x-to-7.4.md | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index e923060223..5d2264c108 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -196,6 +196,76 @@ When using Google omniauth login, changes of the Google account required. Ensure that `Contacts API` and the `Google+ API` are enabled in the [Google Developers Console](https://console.developers.google.com/). More details can be found at the [integration documentation](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/integration/google.md). +## 12. Optional optimizations for GitLab setups with MySQL databases + +Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand. + +``` +# Stop GitLab +sudo service gitlab stop + +# Secure your MySQL installation (added in GitLab 6.2) +sudo mysql_secure_installation + +# Login to MySQL +mysql -u root -p + +# do not type the 'mysql>', this is part of the prompt + +# Convert all tables to use the InnoDB storage engine (added in GitLab 6.8) +SELECT CONCAT('ALTER TABLE gitlabhq_production.', table_name, ' ENGINE=InnoDB;') AS 'Copy & run these SQL statements:' FROM information_schema.tables WHERE table_schema = 'gitlabhq_production' AND `ENGINE` <> 'InnoDB' AND `TABLE_TYPE` = 'BASE TABLE'; + +# If previous query returned results, copy & run all outputed SQL statements + +# Convert all tables to correct character set +SET foreign_key_checks = 0; +SELECT CONCAT('ALTER TABLE gitlabhq_production.', table_name, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') AS 'Copy & run these SQL statements:' FROM information_schema.tables WHERE table_schema = 'gitlabhq_production' AND `TABLE_COLLATION` <> 'utf8_unicode_ci' AND `TABLE_TYPE` = 'BASE TABLE'; + +# If previous query returned results, copy & run all outputed SQL statements + +# turn foreign key checks back on +SET foreign_key_checks = 1; + +# Find MySQL users +mysql> SELECT user FROM mysql.user WHERE user LIKE '%git%'; + +# If git user exists and gitlab user does not exist +# you are done with the database cleanup tasks +mysql> \q + +# If both users exist skip to Delete gitlab user + +# Create new user for GitLab (changed in GitLab 6.4) +# change $password in the command below to a real password you pick +mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; + +# Grant the git user necessary permissions on the database +mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost'; + +# Delete the old gitlab user +mysql> DELETE FROM mysql.user WHERE user='gitlab'; + +# Quit the database session +mysql> \q + +# Try connecting to the new database with the new user +sudo -u git -H mysql -u git -p -D gitlabhq_production + +# Type the password you replaced $password with earlier + +# You should now see a 'mysql>' prompt + +# Quit the database session +mysql> \q + +# Update database configuration details +# See config/database.yml.mysql for latest recommended configuration details +# Remove the reaping_frequency setting line if it exists (removed in GitLab 6.8) +# Set production -> pool: 10 (updated in GitLab 5.3) +# Set production -> username: git +# Set production -> password: the password your replaced $password with earlier +sudo -u git -H editor /home/git/gitlab/config/database.yml + ## Things went south? Revert to previous version (6.0) ### 1. Revert the code to the previous version From 082d59d21f7f8857eca2715c1a58fbce30f9b92d Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 20 Oct 2014 10:52:29 +0200 Subject: [PATCH 08/23] Ask the wiki repo, not Gollum, if it's empty We need to skip empty repositories when creating a backup. Before this change, we were asking gollum-lib if the wiki contains any _pages_. Now we ask gitlab_git if the repository contains _files_. This should resolve gollum_lib Grit timeouts in the backup script. --- lib/backup/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 4e99d4bbe5..380beac708 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -30,7 +30,7 @@ module Backup if File.exists?(path_to_repo(wiki)) print " * #{wiki.path_with_namespace} ... " - if wiki.empty? + if wiki.repository.empty? puts " [SKIPPED]".cyan else output, status = Gitlab::Popen.popen(%W(git --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all)) From ebc0a7050afe71f5c30341dcf6b15da76b810408 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 20 Oct 2014 12:59:16 +0300 Subject: [PATCH 09/23] Fix group user removal from admin area Signed-off-by: Dmitriy Zaporozhets --- app/views/admin/groups/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index c1a9214b77..1da6e4c5f1 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -80,7 +80,7 @@ = link_to user.name, admin_user_path(user) %span.pull-right.light = member.human_access - = link_to group_group_members_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + = link_to group_group_member_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do %i.fa.fa-minus.fa-inverse .panel-footer = paginate @members, param_name: 'members_page', theme: 'gitlab' From 644fd232dbe827aaae46068119345c2344495239 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 20 Oct 2014 13:18:07 +0300 Subject: [PATCH 10/23] Add tests for remove group member feature in admin area Signed-off-by: Dmitriy Zaporozhets --- .../groups/group_members_controller.rb | 1 + app/views/admin/groups/show.html.haml | 2 +- features/admin/groups.feature | 7 ++++++ features/steps/admin/groups.rb | 23 +++++++++++++++++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 63c05d4f33..ca88d03387 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -19,6 +19,7 @@ class Groups::GroupMembersController < ApplicationController def destroy @users_group = @group.group_members.find(params[:id]) + if can?(current_user, :destroy, @users_group) # May fail if last owner. @users_group.destroy respond_to do |format| diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 1da6e4c5f1..4494acc484 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -74,7 +74,7 @@ %ul.well-list.group-users-list - @members.each do |member| - user = member.user - %li{class: dom_class(user)} + %li{class: dom_class(member), id: dom_id(user)} .list-item-name %strong = link_to user.name, admin_user_path(user) diff --git a/features/admin/groups.feature b/features/admin/groups.feature index 1a465c1be5..aa365a6ea1 100644 --- a/features/admin/groups.feature +++ b/features/admin/groups.feature @@ -20,3 +20,10 @@ Feature: Admin Groups When I visit admin group page When I select user "John Doe" from user list as "Reporter" Then I should see "John Doe" in team list in every project as "Reporter" + + @javascript + Scenario: Remove user from group + Given we have user "John Doe" in group + When I visit admin group page + And I remove user "John Doe" from group + Then I should not see "John Doe" in team list diff --git a/features/steps/admin/groups.rb b/features/steps/admin/groups.rb index 4f0ba05606..d69a87cd07 100644 --- a/features/steps/admin/groups.rb +++ b/features/steps/admin/groups.rb @@ -37,8 +37,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps end When 'I select user "John Doe" from user list as "Reporter"' do - user = User.find_by(name: "John Doe") - select2(user.id, from: "#user_ids", multiple: true) + select2(user_john.id, from: "#user_ids", multiple: true) within "#new_team_member" do select "Reporter", from: "access_level" end @@ -58,9 +57,29 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps end end + step 'we have user "John Doe" in group' do + current_group.add_user(user_john, Gitlab::Access::REPORTER) + end + + step 'I remove user "John Doe" from group' do + within "#user_#{user_john.id}" do + click_link 'Remove user from group' + end + end + + step 'I should not see "John Doe" in team list' do + within ".group-users-list" do + page.should_not have_content "John Doe" + end + end + protected def current_group @group ||= Group.first end + + def user_john + @user_john ||= User.find_by(name: "John Doe") + end end From 49bd9812000626af71c1b7b00d9f998fcaca2a46 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Fri, 17 Oct 2014 18:03:34 +0200 Subject: [PATCH 11/23] Prevent redeclaration of LDAP strategy --- config/initializers/7_omniauth.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb index b8ac87fbd5..18759f0cfb 100644 --- a/config/initializers/7_omniauth.rb +++ b/config/initializers/7_omniauth.rb @@ -1,7 +1,8 @@ if Gitlab::LDAP::Config.enabled? module OmniAuth::Strategies server = Gitlab.config.ldap.servers.values.first - const_set(server['provider_class'], Class.new(LDAP)) + klass = server['provider_class'] + const_set(klass, Class.new(LDAP)) unless klass == 'LDAP' end OmniauthCallbacksController.class_eval do From 3d3726a026f465a441abd7438de85790d9d84d94 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Fri, 17 Oct 2014 18:08:26 +0200 Subject: [PATCH 12/23] Default the LDAP server label to LDAP --- config/initializers/1_settings.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 7e7c91ced7..88cbaefea7 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -61,7 +61,6 @@ Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil? if Settings.ldap['enabled'] || Rails.env.test? if Settings.ldap['host'].present? server = Settings.ldap.except('sync_time') - server['label'] = 'LDAP' server['provider_name'] = 'ldap' Settings.ldap['servers'] = { 'ldap' => server @@ -69,6 +68,7 @@ if Settings.ldap['enabled'] || Rails.env.test? end Settings.ldap['servers'].each do |key, server| + server['label'] ||= 'LDAP' server['allow_username_or_email_login'] = false if server['allow_username_or_email_login'].nil? server['active_directory'] = true if server['active_directory'].nil? server['provider_name'] ||= "ldap#{key}".downcase From 8beca98d7357d704e1871f6ace27718db86c712c Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 21 Oct 2014 09:55:13 +0200 Subject: [PATCH 13/23] Fix CE-EE LDAP merge conflicts --- config/initializers/1_settings.rb | 10 +--------- config/initializers/7_omniauth.rb | 8 +------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 8b16b1a5cf..6fe5f541d5 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -61,24 +61,16 @@ Settings.ldap['sync_time'] = 3600 if Settings.ldap['sync_time'].nil? if Settings.ldap['enabled'] || Rails.env.test? if Settings.ldap['host'].present? server = Settings.ldap.except('sync_time') -<<<<<<< HEAD - server = Settingslogic.new(server) server['label'] = 'LDAP' -======= ->>>>>>> 7-4-stable server['provider_name'] = 'ldap' Settings.ldap['servers'] = { 'ldap' => server } end -<<<<<<< HEAD - Settings.ldap['servers'].map do |key, server| - server = Settingslogic.new(server) -======= Settings.ldap['servers'].each do |key, server| + server = Settingslogic.new(server) server['label'] ||= 'LDAP' ->>>>>>> 7-4-stable server['allow_username_or_email_login'] = false if server['allow_username_or_email_login'].nil? server['active_directory'] = true if server['active_directory'].nil? server['provider_name'] ||= "ldap#{key}".downcase diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb index 05ab6c310f..c6a46fd617 100644 --- a/config/initializers/7_omniauth.rb +++ b/config/initializers/7_omniauth.rb @@ -1,16 +1,10 @@ if Gitlab::LDAP::Config.enabled? module OmniAuth::Strategies -<<<<<<< HEAD Gitlab::LDAP::Config.servers.each do |server| # do not redeclare LDAP next if server['provider_name'] == 'ldap' const_set(server['provider_class'], Class.new(LDAP)) end -======= - server = Gitlab.config.ldap.servers.values.first - klass = server['provider_class'] - const_set(klass, Class.new(LDAP)) unless klass == 'LDAP' ->>>>>>> 7-4-stable end OmniauthCallbacksController.class_eval do @@ -18,4 +12,4 @@ if Gitlab::LDAP::Config.enabled? alias_method server['provider_name'], :ldap end end -end \ No newline at end of file +end From db5ea013f4a75b6f6b6cf7fd43011f5c2c29fda1 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Thu, 25 Sep 2014 16:43:23 +0200 Subject: [PATCH 14/23] Use :message key, not :error for File::Service. --- app/controllers/projects/blob_controller.rb | 2 +- .../projects/edit_tree_controller.rb | 2 +- app/services/files/base_service.rb | 6 ------ features/project/source/browse_files.feature | 20 +++++++++++++++++++ features/steps/project/source/browse_files.rb | 8 ++++++++ features/steps/shared/paths.rb | 9 +++++++++ lib/api/files.rb | 6 +++--- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 7009e3b1bc..0944c7421e 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -20,7 +20,7 @@ class Projects::BlobController < Projects::ApplicationController flash[:notice] = "Your changes have been successfully committed" redirect_to project_tree_path(@project, @ref) else - flash[:alert] = result[:error] + flash[:alert] = result[:message] render :show end end diff --git a/app/controllers/projects/edit_tree_controller.rb b/app/controllers/projects/edit_tree_controller.rb index 8976d7c7be..fdc1a85d8d 100644 --- a/app/controllers/projects/edit_tree_controller.rb +++ b/app/controllers/projects/edit_tree_controller.rb @@ -22,7 +22,7 @@ class Projects::EditTreeController < Projects::BaseTreeController redirect_to after_edit_path else - flash[:alert] = result[:error] + flash[:alert] = result[:message] render :show end end diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb index db6f0831f8..bd24510095 100644 --- a/app/services/files/base_service.rb +++ b/app/services/files/base_service.rb @@ -10,12 +10,6 @@ module Files private - def success - out = super() - out[:error] = '' - out - end - def repository project.repository end diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature index aca255b944..b7d70881d5 100644 --- a/features/project/source/browse_files.feature +++ b/features/project/source/browse_files.feature @@ -34,6 +34,16 @@ Feature: Project Source Browse Files Then I am redirected to the new file And I should see its new content + @javascript + Scenario: If I enter an illegal file name I see an error message + Given I click on "new file" link in repo + And I fill the new file name with an illegal name + And I edit code + And I fill the commit message + And I click on "Commit changes" + Then I am on the new file page + And I see a commit error message + @javascript Scenario: I can edit file Given I click on ".gitignore" file in repo @@ -50,6 +60,16 @@ Feature: Project Source Browse Files Then I am redirected to the ".gitignore" And I should see its new content + @javascript @wip + Scenario: If I don't change the content of the file I see an error message + Given I click on ".gitignore" file in repo + And I click button "edit" + And I fill the commit message + And I click on "Commit changes" + # Test fails because carriage returns are added to the file. + Then I am on the ".gitignore" edit file page + And I see a commit error message + @javascript Scenario: I can see editing preview Given I click on ".gitignore" file in repo diff --git a/features/steps/project/source/browse_files.rb b/features/steps/project/source/browse_files.rb index 20f8f6c24a..665f5d6d19 100644 --- a/features/steps/project/source/browse_files.rb +++ b/features/steps/project/source/browse_files.rb @@ -61,6 +61,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps fill_in :file_name, with: new_file_name end + step 'I fill the new file name with an illegal name' do + fill_in :file_name, with: '.git' + end + step 'I fill the commit message' do fill_in :commit_message, with: 'Not yet a commit message.' end @@ -151,6 +155,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps expect(page).not_to have_link('permalink') end + step 'I see a commit error message' do + expect(page).to have_content('Your changes could not be committed') + end + private def set_new_content diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 1f238f8bef..5f292255ce 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -265,6 +265,15 @@ module SharedPaths visit project_blob_path(@project, File.join(root_ref, '.gitignore')) end + step 'I am on the new file page' do + current_path.should eq(project_new_tree_path(@project, root_ref)) + end + + step 'I am on the ".gitignore" edit file page' do + current_path.should eq(project_edit_tree_path( + @project, File.join(root_ref, '.gitignore'))) + end + step 'I visit project source page for "6d39438"' do visit project_tree_path(@project, "6d39438") end diff --git a/lib/api/files.rb b/lib/api/files.rb index e63e635a4d..84e1d31178 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -85,7 +85,7 @@ module API branch_name: branch_name } else - render_api_error!(result[:error], 400) + render_api_error!(result[:message], 400) end end @@ -117,7 +117,7 @@ module API branch_name: branch_name } else - render_api_error!(result[:error], 400) + render_api_error!(result[:message], 400) end end @@ -149,7 +149,7 @@ module API branch_name: branch_name } else - render_api_error!(result[:error], 400) + render_api_error!(result[:message], 400) end end end From 159eeecef1bcf56427600e8e4338bba3f655a706 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 21 Oct 2014 11:27:41 +0200 Subject: [PATCH 15/23] Restore `Settingslogic.new` from 18d87dcf9132c1cf --- config/initializers/1_settings.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 6fe5f541d5..4920ce2d09 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -61,6 +61,7 @@ Settings.ldap['sync_time'] = 3600 if Settings.ldap['sync_time'].nil? if Settings.ldap['enabled'] || Rails.env.test? if Settings.ldap['host'].present? server = Settings.ldap.except('sync_time') + server = Settingslogic.new(server) server['label'] = 'LDAP' server['provider_name'] = 'ldap' Settings.ldap['servers'] = { From b1e60cfa1b56d01c2328ebe2a3d49cd82058f981 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 21 Oct 2014 13:20:59 +0300 Subject: [PATCH 16/23] remove unnecessary parts from update doc --- doc/update/7.3-to-7.4.md | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index c1a70ba4e6..b3eaa3bdce 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -52,31 +52,7 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab ``` - -### 4. Configure Redis to use sockets - - # Configure redis to use sockets - sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig - # Disable Redis listening on TCP by setting 'port' to 0 - sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf - # Enable Redis socket for default Debian / Ubuntu path - echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf - # Be sure redis group can write to the socket, enable only if supported (>= redis 2.4.0). - sed -i '/# unixsocketperm/ s/^# unixsocketperm.*/unixsocketperm 0775/' /etc/redis/redis.conf - # Activate the changes to redis.conf - sudo service redis-server restart - # Add git to the redis group - sudo usermod -aG redis git - - # Configure Redis connection settings - sudo -u git -H cp config/resque.yml.example config/resque.yml - # Change the Redis socket path if you are not using the default Debian / Ubuntu configuration - sudo -u git -H editor config/resque.yml - - # Configure gitlab-shell to use Redis sockets - sudo -u git -H sed -i 's|^ # socket.*| socket: /var/run/redis/redis.sock|' /home/git/gitlab-shell/config.yml - -### 5. Update config files +### 4. Update config files #### New configuration options for gitlab.yml @@ -102,12 +78,12 @@ sudo -u git -H editor config/unicorn.rb * Add `collation: utf8_general_ci` to config/database.yml as seen in [config/database.yml.mysql](config/database.yml.mysql) -### 6. Start application +### 5. Start application sudo service gitlab start sudo service nginx restart -### 7. Check application status +### 6. Check application status Check if GitLab and its environment are configured correctly: @@ -119,13 +95,8 @@ To make sure you didn't miss anything run a more thorough check with: If all items are green, then congratulations upgrade is complete! -### 8. Update OmniAuth configuration -When using Google omniauth login, changes of the Google account required. -Ensure that `Contacts API` and the `Google+ API` are enabled in the [Google Developers Console](https://console.developers.google.com/). -More details can be found at the [integration documentation](../integration/google.md). - -### 9. Optional optimizations for GitLab setups with MySQL databases +### 7. Optional optimizations for GitLab setups with MySQL databases Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand. From 9f54397f3a3e094665d25109a63f24757a19df3a Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 21 Oct 2014 11:38:41 +0200 Subject: [PATCH 17/23] Use allowed slack team name. --- app/models/project_services/slack_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 95f3ddcef4..837002ef3c 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -40,7 +40,8 @@ class SlackService < Service project_name: project_name )) - credentials = webhook.match(/(\w*).slack.com.*services\/(.*)/) + credentials = webhook.match(/([\w-]*).slack.com.*services\/(.*)/) + if credentials.present? subdomain = credentials[1] token = credentials[2].split("token=").last From 536f61e0e77227828d363a7008bd39b0e9fd43a7 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 21 Oct 2014 11:33:26 +0200 Subject: [PATCH 18/23] Add test for allowed team name of slack. --- spec/models/slack_service_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb index 95df38d940..526165e397 100644 --- a/spec/models/slack_service_spec.rb +++ b/spec/models/slack_service_spec.rb @@ -77,5 +77,25 @@ describe SlackService do WebMock.should have_requested(:post, api_url).once end end + + context 'with new webhook syntax with slack allowed team name' do + before do + @allowed_webhook = 'https://gitlab-hq-123.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI' + slack_service.stub( + project: project, + project_id: project.id, + service_hook: true, + webhook: @allowed_webhook + ) + + WebMock.stub_request(:post, @allowed_webhook) + end + + it "should call Slack API" do + slack_service.execute(sample_data) + + WebMock.should have_requested(:post, @allowed_webhook).once + end + end end end From e88cf107bcdd284904c02dafc4a08e3272161f88 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 21 Oct 2014 14:07:38 +0200 Subject: [PATCH 19/23] Add instructions for multiple LDAP servers --- doc/integration/ldap.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/doc/integration/ldap.md b/doc/integration/ldap.md index a2f96b5d17..9f0a0b5281 100644 --- a/doc/integration/ldap.md +++ b/doc/integration/ldap.md @@ -135,3 +135,43 @@ Tip: if you want to limit access to the nested members of an Active Directory gr ``` Please note that GitLab does not support the custom filter syntax used by omniauth-ldap. + +## Integrate GitLab with more than one LDAP server (Enterprise Edition) + +Starting with GitLab Enterprise Edition 7.4 it is possible to give users from more than one LDAP server access to the same GitLab server. + +Please use the following steps to enable support for multiple LDAP servers. + +### 1. Check your GitLab version + +Go to gitlab.example.com/help and verify you are running GitLab Enterprise Edition 7.4.0 or newer. + +### 2. Make sure your GitLab server uses the new LDAP syntax + +``` +# For omnibus packages +sudo gitlab-rails runner 'puts (Gitlab.config.ldap["host"] ? :old_syntax : :new_syntax)' + +# For installations from source +cd /home/git/gitlab +bundle exec rails runner -e production 'puts (Gitlab.config.ldap["host"] ? :old_syntax : :new_syntax)' +``` + +### 3. Migrate existing users and groups + +After switching to the new LDAP configuration syntax there will be a mismatch between the LDAP provider linked to your GitLab users and groups and the new LDAP provider defined in GitLab's configuration. +The following command will associate all existing legacy LDAP users and groups on your GitLab server with the first LDAP server listed in `gitlab.rb` (omnibus) or `gitlab.yml`. + +``` +# For omnibus packages +sudo gitlab-rake gitlab:migrate_ldap_providers + +# For installations from source +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:migrate_ldap_providers RAILS_ENV=production +``` + +### 4. Add new LDAP servers + +Now you can add new LDAP servers via `/etc/gitlab/gitlab.rb` (omnibus packages) or `gitlab.yml` (installations from source). +Remember to run `sudo gitlab-ctl reconfigure` or `sudo service gitlab reload` for the new servers to become available. From 6c4c9a8c4cccabf4c2ce4ae040ef108d8044768a Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 21 Oct 2014 17:18:51 +0300 Subject: [PATCH 20/23] Add doc for upgrading CE to EE --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f1af914875..14f2181a62 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # ![logo](https://about.gitlab.com/images/gitlab_logo.png) GitLab +For upgrading from GitLab CE to GitLab EE there is [upgrade guide](doc/update/7.4-ce-to-ee.md) + ## Open source software to collaborate on code ![Animated screenshots](https://about.gitlab.com/images/animated/compiled.gif) From be80837a6941abe48d99acad1c3eb8a9957a0b42 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 21 Oct 2014 19:12:52 +0300 Subject: [PATCH 21/23] Update Guide: Change path to nginx config --- doc/update/6.x-or-7.x-to-7.4.md | 4 ++-- doc/update/7.3-to-7.4.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index 8516c3baba..2fa6889af7 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -160,8 +160,8 @@ git diff 6-0-stable:config/gitlab.yml.example 7-4-stable:config/gitlab.yml.examp * Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/gitlab.yml.example but with your settings. * Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/unicorn.rb.example but with your settings. * Make `/home/git/gitlab-shell/config.yml` the same as https://gitlab.com/gitlab-org/gitlab-shell/blob/v2.0.1/config.yml.example but with your settings. -* HTTP setups: Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab but with your settings. -* HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your settings. +* HTTP setups: Make `/etc/nginx/sites-available/gitlab` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab but with your settings. +* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your settings. * Copy rack attack middleware config ```bash diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index b3eaa3bdce..69d86fb06e 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -71,7 +71,7 @@ sudo -u git -H editor config/unicorn.rb #### Change nginx https settings -* HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting +* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting #### MySQL Databases: Update database.yml config file From 829bd6ff38954117490db8b41cedb89819277f39 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 21 Oct 2014 18:26:40 +0300 Subject: [PATCH 22/23] Fix rake gitlab:ldap:check Signed-off-by: Dmitriy Zaporozhets Conflicts: lib/gitlab/ldap/adapter.rb --- lib/gitlab/ldap/adapter.rb | 6 ++++- lib/tasks/gitlab/check.rake | 44 ++++++++++--------------------------- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 3d1e05bd64..6db1bc3925 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -46,7 +46,7 @@ module Gitlab groups(*args).first end - def users(field, value) + def users(field, value, limit = nil) if field.to_sym == :dn options = { base: value, @@ -69,6 +69,10 @@ module Gitlab end end + if limit.present? + options.merge!(size: limit) + end + entries = ldap_search(options).select do |entry| entry.respond_to? config.uid end diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 9ec368254a..707d236068 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -664,7 +664,7 @@ namespace :gitlab do warn_user_is_not_gitlab start_checking "LDAP" - if ldap_config.enabled + if Gitlab::LDAP::Config.enabled? print_users(args.limit) else puts 'LDAP is disabled in config/gitlab.yml' @@ -675,39 +675,19 @@ namespace :gitlab do def print_users(limit) puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)" - ldap.search(attributes: attributes, filter: filter, size: limit, return_result: false) do |entry| - puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}" + + servers = Gitlab.config.ldap.servers.keys + + servers.each do |server| + puts "Server: #{server}" + Gitlab::LDAP::Adapter.open("ldap#{server}") do |adapter| + users = adapter.users(adapter.config.uid, '*', 100) + users.each do |user| + puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}" + end + end end end - - def attributes - [ldap_config.uid] - end - - def filter - uid_filter = Net::LDAP::Filter.present?(ldap_config.uid) - if user_filter - Net::LDAP::Filter.join(uid_filter, user_filter) - else - uid_filter - end - end - - def user_filter - if ldap_config['user_filter'] && ldap_config.user_filter.present? - Net::LDAP::Filter.construct(ldap_config.user_filter) - else - nil - end - end - - def ldap - @ldap ||= OmniAuth::LDAP::Adaptor.new(ldap_config).connection - end - - def ldap_config - @ldap_config ||= Gitlab.config.ldap - end end # Helper methods From d79c5f78b6ebdafaa892860f365daec8454cca28 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 22 Oct 2014 11:11:18 +0300 Subject: [PATCH 23/23] Make gitlab ldap check work for old and new syntax Signed-off-by: Dmitriy Zaporozhets --- lib/tasks/gitlab/check.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 707d236068..56e8ff4498 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -676,11 +676,11 @@ namespace :gitlab do def print_users(limit) puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)" - servers = Gitlab.config.ldap.servers.keys + servers = Gitlab::LDAP::Config.providers servers.each do |server| puts "Server: #{server}" - Gitlab::LDAP::Adapter.open("ldap#{server}") do |adapter| + Gitlab::LDAP::Adapter.open(server) do |adapter| users = adapter.users(adapter.config.uid, '*', 100) users.each do |user| puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}"