From 7fcd0e836728950b5e78667b5b4187fea689e8ef Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Mon, 15 Dec 2014 09:44:29 +0100 Subject: [PATCH 01/18] Require the ruby racer only in production since installing it on dev machines can cause a lot of problems. Hat tip to Jeroen van Baarsen --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b4ca596927..357ce8f529 100644 --- a/Gemfile +++ b/Gemfile @@ -169,7 +169,6 @@ gem 'semantic-ui-sass', '~> 0.16.1.0' gem "sass-rails", '~> 4.0.2' gem "coffee-rails" gem "uglifier" -gem "therubyracer" gem 'turbolinks' gem 'jquery-turbolinks' @@ -254,6 +253,7 @@ end group :production do gem "gitlab_meta", '7.0' + gem "therubyracer" end gem "newrelic_rpm" From 52bc4e79f83e56f7f90563aa2bd97b98b4cc2715 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 17 Dec 2014 12:18:11 +0100 Subject: [PATCH 02/18] Close standard input in Gitlab::Popen.popen --- CHANGELOG | 1 + lib/gitlab/popen.rb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8052181a96..aaf6c40c02 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ v 7.7.0 - Add alert message in case of outdated browser (IE < 10) - - Added API support for sorting projects + - Close standard input in Gitlab::Popen.popen v 7.6.0 - Fork repository to groups diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index e2fbafb389..fea4d2d55d 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -21,6 +21,9 @@ module Gitlab @cmd_output = "" @cmd_status = 0 Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| + # We are not using stdin so we should close it, in case the command we + # are running waits for input. + stdin.close @cmd_output << stdout.read @cmd_output << stderr.read @cmd_status = wait_thr.value.exitstatus From d02a22ba21f91d2aa4f9cf716dc3aefcf7e7495e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 7 Jan 2015 17:07:36 -0800 Subject: [PATCH 03/18] Redesign signin/singup pages --- app/assets/stylesheets/sections/login.scss | 89 ++++++++++++------- app/helpers/application_helper.rb | 5 ++ app/views/devise/sessions/_new_base.html.haml | 2 +- app/views/devise/sessions/_new_ldap.html.haml | 1 - app/views/devise/sessions/new.html.haml | 52 +++-------- .../_oauth_box.html.haml} | 4 +- app/views/devise/shared/_signin_box.html.haml | 25 ++++++ app/views/devise/shared/_signup_box.html.haml | 17 ++++ .../layouts/_public_head_panel.html.haml | 13 +-- app/views/layouts/devise.html.haml | 53 ++++++----- 10 files changed, 151 insertions(+), 110 deletions(-) rename app/views/devise/{sessions/_oauth_providers.html.haml => shared/_oauth_box.html.haml} (77%) create mode 100644 app/views/devise/shared/_signin_box.html.haml create mode 100644 app/views/devise/shared/_signup_box.html.haml diff --git a/app/assets/stylesheets/sections/login.scss b/app/assets/stylesheets/sections/login.scss index 1bcb1f6d68..901733ef9f 100644 --- a/app/assets/stylesheets/sections/login.scss +++ b/app/assets/stylesheets/sections/login.scss @@ -1,48 +1,66 @@ /* Login Page */ .login-page { - h1 { - font-size: 3em; - font-weight: 200; + .container { + max-width: 960px; + } + + .navbar-gitlab .container { + max-width: none; + } + + .brand-holder { + font-size: 18px; + line-height: 1.5; + + p { + color: #888; + } + + h1:first-child { + font-weight: normal; + margin-bottom: 30px; + } + + img { + max-width: 100%; + margin-bottom: 30px; + } + + a { + font-weight: bold; + } } .login-box{ - padding: 0 15px; + background: #fafafa; + border-radius: 10px; + box-shadow: 0 0px 2px #CCC; + padding: 15px; .login-heading h3 { font-weight: 300; - line-height: 2; + line-height: 1.5; + margin: 0; + display: none; } .login-footer { margin-top: 10px; } - .btn { - padding: 12px !important; - @extend .btn-block; - } - } - - .brand-image { - img { - max-width: 100%; - margin-bottom: 20px; + a.forgot { + float: right; + padding-top: 6px } - &.default-brand-image { - margin: 0 80px; + .nav .active a { + background: transparent; } } - .login-logo { - margin: 10px 0 30px 0; - display: block; - } - .form-control { - background-color: #F5F5F5; - font-size: 16px; - padding: 14px 10px; + font-size: 14px; + padding: 10px 8px; width: 100%; height: auto; @@ -68,11 +86,6 @@ } } - .login-box a.forgot { - float: right; - padding-top: 6px - } - .devise-errors { h2 { font-size: 14px; @@ -80,7 +93,19 @@ } } - .brand-holder { - border-right: 1px solid #EEE; + .remember-me { + margin-top: -10px; + + label { + font-weight: normal; + } + } +} + +@media (max-width: $screen-xs-max) { + .login-page { + .col-sm-5.pull-right { + float: none !important; + } } } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 092a1ba922..f21b0bd1f5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -305,4 +305,9 @@ module ApplicationHelper profile_key_path(key) end end + + def redirect_from_root? + request.env['rack.session']['user_return_to'] == + '/' + end end diff --git a/app/views/devise/sessions/_new_base.html.haml b/app/views/devise/sessions/_new_base.html.haml index e819847e5e..ab9085f0ba 100644 --- a/app/views/devise/sessions/_new_base.html.haml +++ b/app/views/devise/sessions/_new_base.html.haml @@ -2,7 +2,7 @@ = f.text_field :login, class: "form-control top", placeholder: "Username or Email", autofocus: "autofocus" = f.password_field :password, class: "form-control bottom", placeholder: "Password" - if devise_mapping.rememberable? - .clearfix.append-bottom-10 + .remember-me %label.checkbox.remember_me{for: "user_remember_me"} = f.check_box :remember_me %span Remember me diff --git a/app/views/devise/sessions/_new_ldap.html.haml b/app/views/devise/sessions/_new_ldap.html.haml index bf8a593c25..e986989a72 100644 --- a/app/views/devise/sessions/_new_ldap.html.haml +++ b/app/views/devise/sessions/_new_ldap.html.haml @@ -1,5 +1,4 @@ = form_tag(user_omniauth_callback_path(provider), id: 'new_ldap_user' ) do = text_field_tag :username, nil, {class: "form-control top", placeholder: "LDAP Login", autofocus: "autofocus"} = password_field_tag :password, nil, {class: "form-control bottom", placeholder: "Password"} - %br/ = button_tag "LDAP Sign in", class: "btn-save btn" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index ca7e9570b4..5e31d8e818 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,43 +1,15 @@ -.login-box - .login-heading - %h3 Sign in - .login-body - - if ldap_enabled? - %ul.nav.nav-tabs - - @ldap_servers.each_with_index do |server, i| - %li{class: (:active if i.zero?)} - = link_to server['label'], "#tab-#{server['provider_name']}", 'data-toggle' => 'tab' - - if gitlab_config.signin_enabled - %li - = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' - .tab-content - - @ldap_servers.each_with_index do |server, i| - %div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i.zero?)} - = render 'devise/sessions/new_ldap', provider: server['provider_name'] - - if gitlab_config.signin_enabled - %div#tab-signin.tab-pane - = render 'devise/sessions/new_base' +%div + = render 'devise/shared/signin_box' - - elsif gitlab_config.signin_enabled - = render 'devise/sessions/new_base' - - else - %div - No authentication methods configured. + - if Gitlab.config.omniauth.enabled && devise_mapping.omniauthable? + .prepend-top-20 + = render 'devise/shared/oauth_box' - = render 'devise/sessions/oauth_providers' if Gitlab.config.omniauth.enabled && devise_mapping.omniauthable? + - if gitlab_config.signup_enabled + .prepend-top-20 + = render 'devise/shared/signup_box' - .login-footer - - if gitlab_config.signup_enabled - %p - %span.light - Don't have an account? - %strong - = link_to "Sign up", new_registration_path(resource_name) - - %p - %span.light Did not receive confirmation email? - = link_to "Send again", new_confirmation_path(resource_name) - - - if extra_config.has_key?('sign_in_text') - %hr - = markdown(extra_config.sign_in_text) +.clearfix.prepend-top-20 + %p + %span.light Did not receive confirmation email? + = link_to "Send again", new_confirmation_path(resource_name) diff --git a/app/views/devise/sessions/_oauth_providers.html.haml b/app/views/devise/shared/_oauth_box.html.haml similarity index 77% rename from app/views/devise/sessions/_oauth_providers.html.haml rename to app/views/devise/shared/_oauth_box.html.haml index 8d6aaefb9f..c2e1373de3 100644 --- a/app/views/devise/sessions/_oauth_providers.html.haml +++ b/app/views/devise/shared/_oauth_box.html.haml @@ -1,7 +1,7 @@ - providers = additional_providers - if providers.present? - .bs-callout.bs-callout-info{:'data-no-turbolink' => 'data-no-turbolink'} - %span Sign in with:   + .login-box{:'data-no-turbolink' => 'data-no-turbolink'} + %span Sign in with   - providers.each do |provider| %span - if default_providers.include?(provider) diff --git a/app/views/devise/shared/_signin_box.html.haml b/app/views/devise/shared/_signin_box.html.haml new file mode 100644 index 0000000000..3f2161ff6a --- /dev/null +++ b/app/views/devise/shared/_signin_box.html.haml @@ -0,0 +1,25 @@ +.login-box + .login-heading + %h3 Sign in + .login-body + - if ldap_enabled? + %ul.nav.nav-tabs + - @ldap_servers.each_with_index do |server, i| + %li{class: (:active if i.zero?)} + = link_to server['label'], "#tab-#{server['provider_name']}", 'data-toggle' => 'tab' + - if gitlab_config.signin_enabled + %li + = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' + .tab-content + - @ldap_servers.each_with_index do |server, i| + %div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i.zero?)} + = render 'devise/sessions/new_ldap', provider: server['provider_name'] + - if gitlab_config.signin_enabled + %div#tab-signin.tab-pane + = render 'devise/sessions/new_base' + + - elsif gitlab_config.signin_enabled + = render 'devise/sessions/new_base' + - else + %div + No authentication methods configured. diff --git a/app/views/devise/shared/_signup_box.html.haml b/app/views/devise/shared/_signup_box.html.haml new file mode 100644 index 0000000000..5709c66128 --- /dev/null +++ b/app/views/devise/shared/_signup_box.html.haml @@ -0,0 +1,17 @@ +.login-box + .login-heading + %h3 Sign up + .login-body + = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| + .devise-errors + = devise_error_messages! + %div + = f.text_field :name, class: "form-control top", placeholder: "Name", required: true + %div + = f.text_field :username, class: "form-control middle", placeholder: "Username", required: true + %div + = f.email_field :email, class: "form-control middle", placeholder: "Email", required: true + .form-group#password-strength + = f.password_field :password, class: "form-control bottom", id: "user_password_sign_up", placeholder: "Password", required: true + %div + = f.submit "Sign up", class: "btn-create btn" diff --git a/app/views/layouts/_public_head_panel.html.haml b/app/views/layouts/_public_head_panel.html.haml index 02a5e4868d..1d5bbb2aad 100644 --- a/app/views/layouts/_public_head_panel.html.haml +++ b/app/views/layouts/_public_head_panel.html.haml @@ -12,12 +12,13 @@ %span.sr-only Toggle navigation %i.fa.fa-bars - .pull-right.hidden-xs - = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-new' + - unless current_controller?('sessions') + .pull-right.hidden-xs + = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-new' - .navbar-collapse.collapse - %ul.nav.navbar-nav - %li.visible-xs - = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes') + .navbar-collapse.collapse + %ul.nav.navbar-nav + %li.visible-xs + = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes') = render 'shared/outdated_browser' diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 6539a24119..8b3872e535 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -1,36 +1,33 @@ !!! 5 %html{ lang: "en"} = render "layouts/head" - %body.ui_basic.login-page - .container + %body.ui_mars.login-page.application + = render "layouts/broadcast" + = render "layouts/public_head_panel", title: '' + .container.navless-container .content - .login-title - %h1= brand_title - = render 'shared/outdated_browser' - %hr - .container - .content - = render "layouts/flash" - .row - .col-md-7.brand-holder - - if brand_item - .brand-image - = brand_image - .brand_text - = brand_text - - else - .brand-image.default-brand-image.hidden-sm.hidden-xs - = image_tag 'brand_logo.png' - .brand_text.hidden-xs - %h2 Open source software to collaborate on code - - %p.lead - Manage git repositories with fine grained access controls that keep your code secure. - Perform code reviews and enhance collaboration with merge requests. - Each project can also have an issue tracker and a wiki. - - .col-md-5 + - unless redirect_from_root? + = render "layouts/flash" + .row.prepend-top-20 + .col-sm-5.pull-right = yield + .col-sm-7.brand-holder.pull-left + %h1 + = brand_title + - if brand_item + = brand_image + = brand_text + - else + %h3 Open source software to collaborate on code + + %p + Manage git repositories with fine grained access controls that keep your code secure. + Perform code reviews and enhance collaboration with merge requests. + Each project can also have an issue tracker and a wiki. + + - if extra_config.has_key?('sign_in_text') + = markdown(extra_config.sign_in_text) + %hr .container .footer-links From 8589b4e137f50293952923bb07e2814257d7784d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 00:22:50 -0800 Subject: [PATCH 04/18] Init ApplicationSettings resource with defaults from config file --- .../admin/application_settings_controller.rb | 31 +++++++++++++++++++ app/controllers/registrations_controller.rb | 4 ++- app/helpers/application_helper.rb | 8 +++++ app/helpers/application_settings_helper.rb | 2 ++ app/models/application_setting.rb | 5 +++ app/services/gravatar_service.rb | 2 +- .../application_settings/_form.html.haml | 29 +++++++++++++++++ .../admin/application_settings/edit.html.haml | 5 +++ .../admin/application_settings/show.html.haml | 18 +++++++++++ app/views/devise/sessions/new.html.haml | 2 +- app/views/devise/shared/_signin_box.html.haml | 6 ++-- config/initializers/8_application_settings.rb | 12 +++++++ config/routes.rb | 2 ++ ...50108073740_create_application_settings.rb | 13 ++++++++ db/schema.rb | 12 ++++++- 15 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 app/controllers/admin/application_settings_controller.rb create mode 100644 app/helpers/application_settings_helper.rb create mode 100644 app/models/application_setting.rb create mode 100644 app/views/admin/application_settings/_form.html.haml create mode 100644 app/views/admin/application_settings/edit.html.haml create mode 100644 app/views/admin/application_settings/show.html.haml create mode 100644 config/initializers/8_application_settings.rb create mode 100644 db/migrate/20150108073740_create_application_settings.rb diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb new file mode 100644 index 0000000000..d6e950b000 --- /dev/null +++ b/app/controllers/admin/application_settings_controller.rb @@ -0,0 +1,31 @@ +class Admin::ApplicationSettingsController < Admin::ApplicationController + before_filter :set_application_setting + + def show + end + + def edit + end + + def update + @application_setting.update_attributes(application_setting_params) + + redirect_to admin_application_settings_path + end + + private + + def set_application_setting + @application_setting = ApplicationSetting.last + end + + def application_setting_params + params.require(:application_setting).permit( + :default_projects_limit, + :signup_enabled, + :signin_enabled, + :gravatar_enabled, + :sign_in_text, + ) + end +end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 6d3214b70a..7c15eab434 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -26,7 +26,9 @@ class RegistrationsController < Devise::RegistrationsController private def signup_enabled? - redirect_to new_user_session_path unless Gitlab.config.gitlab.signup_enabled + unless ApplicationSetting.current.signup_enabled + redirect_to new_user_session_path + end end def sign_up_params diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f21b0bd1f5..c339b3597e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -310,4 +310,12 @@ module ApplicationHelper request.env['rack.session']['user_return_to'] == '/' end + + def signup_enabled? + ApplicationSetting.current.signup_enabled + end + + def signin_enabled? + ApplicationSetting.current.signin_enabled + end end diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb new file mode 100644 index 0000000000..bb39a3cf4f --- /dev/null +++ b/app/helpers/application_settings_helper.rb @@ -0,0 +1,2 @@ +module ApplicationSettingsHelper +end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb new file mode 100644 index 0000000000..4b885461cb --- /dev/null +++ b/app/models/application_setting.rb @@ -0,0 +1,5 @@ +class ApplicationSetting < ActiveRecord::Base + def self.current + ApplicationSetting.last + end +end diff --git a/app/services/gravatar_service.rb b/app/services/gravatar_service.rb index a69c7c7837..d8c9436aaa 100644 --- a/app/services/gravatar_service.rb +++ b/app/services/gravatar_service.rb @@ -1,6 +1,6 @@ class GravatarService def execute(email, size = nil) - if gravatar_config.enabled && email.present? + if ApplicationSetting.current.gravatar_enabled && email.present? size = 40 if size.nil? || size <= 0 sprintf gravatar_url, diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml new file mode 100644 index 0000000000..846d74d433 --- /dev/null +++ b/app/views/admin/application_settings/_form.html.haml @@ -0,0 +1,29 @@ += form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f| + - if @application_setting.errors.any? + #error_explanation + .alert.alert-danger + - @application_setting.errors.full_messages.each do |msg| + %p= msg + + .form-group + = f.label :default_projects_limit, class: 'control-label' + .col-sm-10 + = f.number_field :default_projects_limit, class: 'form-control' + .form-group + = f.label :signup_enabled, class: 'control-label' + .col-sm-10 + = f.check_box :signup_enabled, class: 'checkbox' + .form-group + = f.label :signin_enabled, class: 'control-label' + .col-sm-10 + = f.check_box :signin_enabled, class: 'checkbox' + .form-group + = f.label :gravatar_enabled, class: 'control-label' + .col-sm-10 + = f.check_box :gravatar_enabled, class: 'checkbox' + .form-group + = f.label :sign_in_text, class: 'control-label' + .col-sm-10 + = f.text_area :sign_in_text, class: 'form-control' + .form-actions + = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/admin/application_settings/edit.html.haml b/app/views/admin/application_settings/edit.html.haml new file mode 100644 index 0000000000..62c0617ca4 --- /dev/null +++ b/app/views/admin/application_settings/edit.html.haml @@ -0,0 +1,5 @@ +%h1 Editing application_setting + += render 'form' + += link_to 'Back', admin_application_settings_path diff --git a/app/views/admin/application_settings/show.html.haml b/app/views/admin/application_settings/show.html.haml new file mode 100644 index 0000000000..1c77886546 --- /dev/null +++ b/app/views/admin/application_settings/show.html.haml @@ -0,0 +1,18 @@ +%table.table + %tr + %td Default projects limit: + %td= @application_setting.default_projects_limit + %tr + %td Signup enabled: + %td= @application_setting.signup_enabled + %tr + %td Signin enabled: + %td= @application_setting.signin_enabled + %tr + %td Gravatar enabled: + %td= @application_setting.gravatar_enabled + %tr + %td Sign in text: + %td= @application_setting.sign_in_text + += link_to 'Edit', edit_admin_application_settings_path diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 5e31d8e818..6d8415613d 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -5,7 +5,7 @@ .prepend-top-20 = render 'devise/shared/oauth_box' - - if gitlab_config.signup_enabled + - if signup_enabled? .prepend-top-20 = render 'devise/shared/signup_box' diff --git a/app/views/devise/shared/_signin_box.html.haml b/app/views/devise/shared/_signin_box.html.haml index 3f2161ff6a..7058732903 100644 --- a/app/views/devise/shared/_signin_box.html.haml +++ b/app/views/devise/shared/_signin_box.html.haml @@ -7,18 +7,18 @@ - @ldap_servers.each_with_index do |server, i| %li{class: (:active if i.zero?)} = link_to server['label'], "#tab-#{server['provider_name']}", 'data-toggle' => 'tab' - - if gitlab_config.signin_enabled + - if signin_enabled? %li = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' .tab-content - @ldap_servers.each_with_index do |server, i| %div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i.zero?)} = render 'devise/sessions/new_ldap', provider: server['provider_name'] - - if gitlab_config.signin_enabled + - if signin_enabled? %div#tab-signin.tab-pane = render 'devise/sessions/new_base' - - elsif gitlab_config.signin_enabled + - elsif signin_enabled? = render 'devise/sessions/new_base' - else %div diff --git a/config/initializers/8_application_settings.rb b/config/initializers/8_application_settings.rb new file mode 100644 index 0000000000..c4706756b6 --- /dev/null +++ b/config/initializers/8_application_settings.rb @@ -0,0 +1,12 @@ +begin + unless ApplicationSetting.any? + ApplicationSetting.create( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end +rescue +end diff --git a/config/routes.rb b/config/routes.rb index d36540024a..7760f32dc3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -109,6 +109,8 @@ Gitlab::Application.routes.draw do end end + resource :application_settings + root to: "dashboard#index" end diff --git a/db/migrate/20150108073740_create_application_settings.rb b/db/migrate/20150108073740_create_application_settings.rb new file mode 100644 index 0000000000..651e35fdf7 --- /dev/null +++ b/db/migrate/20150108073740_create_application_settings.rb @@ -0,0 +1,13 @@ +class CreateApplicationSettings < ActiveRecord::Migration + def change + create_table :application_settings do |t| + t.integer :default_projects_limit + t.boolean :signup_enabled + t.boolean :signin_enabled + t.boolean :gravatar_enabled + t.text :sign_in_text + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index cb945e7166..6cdff16874 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,21 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141226080412) do +ActiveRecord::Schema.define(version: 20150108073740) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "application_settings", force: true do |t| + t.integer "default_projects_limit" + t.boolean "signup_enabled" + t.boolean "signin_enabled" + t.boolean "gravatar_enabled" + t.text "sign_in_text" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "broadcast_messages", force: true do |t| t.text "message", null: false t.datetime "starts_at" From 57a65ede77b7bbae6e3b2a7aa52135de7b0c2f8e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 09:53:35 -0800 Subject: [PATCH 05/18] Improve application settings and write tests --- .../admin/application_settings_controller.rb | 12 ++--- app/controllers/application_controller.rb | 4 +- app/controllers/registrations_controller.rb | 4 +- app/controllers/sessions_controller.rb | 22 +++++----- app/helpers/application_helper.rb | 8 ---- app/helpers/application_settings_helper.rb | 11 +++++ app/models/user.rb | 5 ++- app/services/base_service.rb | 6 +++ app/services/gravatar_service.rb | 4 +- .../application_settings/_form.html.haml | 44 ++++++++++--------- .../admin/application_settings/edit.html.haml | 5 --- .../admin/application_settings/show.html.haml | 21 ++------- app/views/layouts/devise.html.haml | 4 +- app/views/layouts/nav/_admin.html.haml | 5 +++ config/routes.rb | 2 +- features/admin/settings.feature | 9 ++++ features/steps/admin/settings.rb | 16 +++++++ features/steps/shared/paths.rb | 4 ++ lib/gitlab/current_settings.rb | 7 +++ spec/models/application_setting_spec.rb | 7 +++ 20 files changed, 123 insertions(+), 77 deletions(-) delete mode 100644 app/views/admin/application_settings/edit.html.haml create mode 100644 features/admin/settings.feature create mode 100644 features/steps/admin/settings.rb create mode 100644 lib/gitlab/current_settings.rb create mode 100644 spec/models/application_setting_spec.rb diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index d6e950b000..39ca0b4feb 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -4,13 +4,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController def show end - def edit - end - def update - @application_setting.update_attributes(application_setting_params) - - redirect_to admin_application_settings_path + if @application_setting.update_attributes(application_setting_params) + redirect_to admin_application_settings_path, + notice: 'Application settings saved successfully' + else + render :show + end end private diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b8cae469e..b83de68c5d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ require 'gon' class ApplicationController < ActionController::Base + include Gitlab::CurrentSettings + before_filter :authenticate_user_from_token! before_filter :authenticate_user! before_filter :reject_blocked! @@ -13,7 +15,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - helper_method :abilities, :can? + helper_method :abilities, :can?, :current_application_settings rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 7c15eab434..981dc2d802 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -26,8 +26,8 @@ class RegistrationsController < Devise::RegistrationsController private def signup_enabled? - unless ApplicationSetting.current.signup_enabled - redirect_to new_user_session_path + if current_application_settings.signup_enabled? + redirect_to(new_user_session_path) end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 5ced98152a..7b6982c507 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,16 +1,16 @@ class SessionsController < Devise::SessionsController - def new - redirect_path = if request.referer.present? && (params['redirect_to_referer'] == 'yes') - referer_uri = URI(request.referer) - if referer_uri.host == Gitlab.config.gitlab.host - referer_uri.path - else - request.fullpath - end - else - request.fullpath - end + redirect_path = + if request.referer.present? && (params['redirect_to_referer'] == 'yes') + referer_uri = URI(request.referer) + if referer_uri.host == Gitlab.config.gitlab.host + referer_uri.path + else + request.fullpath + end + else + request.fullpath + end # Prevent a 'you are already signed in' message directly after signing: # we should never redirect to '/users/sign_in' after signing in successfully. diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c339b3597e..f21b0bd1f5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -310,12 +310,4 @@ module ApplicationHelper request.env['rack.session']['user_return_to'] == '/' end - - def signup_enabled? - ApplicationSetting.current.signup_enabled - end - - def signin_enabled? - ApplicationSetting.current.signin_enabled - end end diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index bb39a3cf4f..16db33efd3 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -1,2 +1,13 @@ module ApplicationSettingsHelper + def signup_enabled? + current_application_settings.signup_enabled + end + + def signin_enabled? + current_application_settings.signin_enabled + end + + def extra_sign_in_text + current_application_settings.sign_in_text + end end diff --git a/app/models/user.rb b/app/models/user.rb index 7dae318e78..6e5ac9b39c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -51,14 +51,15 @@ require 'file_size_validator' class User < ActiveRecord::Base include Gitlab::ConfigHelper - extend Gitlab::ConfigHelper include TokenAuthenticatable + extend Gitlab::ConfigHelper + extend Gitlab::CurrentSettings default_value_for :admin, false default_value_for :can_create_group, gitlab_config.default_can_create_group default_value_for :can_create_team, false default_value_for :hide_no_ssh_key, false - default_value_for :projects_limit, gitlab_config.default_projects_limit + default_value_for :projects_limit, current_application_settings.default_projects_limit default_value_for :theme_id, gitlab_config.default_theme devise :database_authenticatable, :lockable, :async, diff --git a/app/services/base_service.rb b/app/services/base_service.rb index 0d46eeaa18..bb51795df7 100644 --- a/app/services/base_service.rb +++ b/app/services/base_service.rb @@ -1,4 +1,6 @@ class BaseService + include Gitlab::CurrentSettings + attr_accessor :project, :current_user, :params def initialize(project, user, params = {}) @@ -29,6 +31,10 @@ class BaseService SystemHooksService.new end + def current_application_settings + ApplicationSetting.current + end + private def error(message) diff --git a/app/services/gravatar_service.rb b/app/services/gravatar_service.rb index d8c9436aaa..4bee0c26a6 100644 --- a/app/services/gravatar_service.rb +++ b/app/services/gravatar_service.rb @@ -1,6 +1,8 @@ class GravatarService + include Gitlab::CurrentSettings + def execute(email, size = nil) - if ApplicationSetting.current.gravatar_enabled && email.present? + if current_application_settings.gravatar_enabled? && email.present? size = 40 if size.nil? || size <= 0 sprintf gravatar_url, diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 846d74d433..5ca9585e9a 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -5,25 +5,29 @@ - @application_setting.errors.full_messages.each do |msg| %p= msg - .form-group - = f.label :default_projects_limit, class: 'control-label' - .col-sm-10 - = f.number_field :default_projects_limit, class: 'form-control' - .form-group - = f.label :signup_enabled, class: 'control-label' - .col-sm-10 - = f.check_box :signup_enabled, class: 'checkbox' - .form-group - = f.label :signin_enabled, class: 'control-label' - .col-sm-10 - = f.check_box :signin_enabled, class: 'checkbox' - .form-group - = f.label :gravatar_enabled, class: 'control-label' - .col-sm-10 - = f.check_box :gravatar_enabled, class: 'checkbox' - .form-group - = f.label :sign_in_text, class: 'control-label' - .col-sm-10 - = f.text_area :sign_in_text, class: 'form-control' + %fieldset + %legend Features + .form-group + = f.label :signup_enabled, class: 'control-label' + .col-sm-10 + = f.check_box :signup_enabled, class: 'checkbox' + .form-group + = f.label :signin_enabled, class: 'control-label' + .col-sm-10 + = f.check_box :signin_enabled, class: 'checkbox' + .form-group + = f.label :gravatar_enabled, class: 'control-label' + .col-sm-10 + = f.check_box :gravatar_enabled, class: 'checkbox' + %fieldset + %legend Misc + .form-group + = f.label :default_projects_limit, class: 'control-label' + .col-sm-10 + = f.number_field :default_projects_limit, class: 'form-control' + .form-group + = f.label :sign_in_text, class: 'control-label' + .col-sm-10 + = f.text_area :sign_in_text, class: 'form-control' .form-actions = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/admin/application_settings/edit.html.haml b/app/views/admin/application_settings/edit.html.haml deleted file mode 100644 index 62c0617ca4..0000000000 --- a/app/views/admin/application_settings/edit.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -%h1 Editing application_setting - -= render 'form' - -= link_to 'Back', admin_application_settings_path diff --git a/app/views/admin/application_settings/show.html.haml b/app/views/admin/application_settings/show.html.haml index 1c77886546..39b66647a5 100644 --- a/app/views/admin/application_settings/show.html.haml +++ b/app/views/admin/application_settings/show.html.haml @@ -1,18 +1,3 @@ -%table.table - %tr - %td Default projects limit: - %td= @application_setting.default_projects_limit - %tr - %td Signup enabled: - %td= @application_setting.signup_enabled - %tr - %td Signin enabled: - %td= @application_setting.signin_enabled - %tr - %td Gravatar enabled: - %td= @application_setting.gravatar_enabled - %tr - %td Sign in text: - %td= @application_setting.sign_in_text - -= link_to 'Edit', edit_admin_application_settings_path +%h3.page-title Application settings +%hr += render 'form' diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 8b3872e535..857ebd9b8d 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -25,8 +25,8 @@ Perform code reviews and enhance collaboration with merge requests. Each project can also have an issue tracker and a wiki. - - if extra_config.has_key?('sign_in_text') - = markdown(extra_config.sign_in_text) + - if extra_sign_in_text.present? + = markdown(extra_sign_in_text) %hr .container diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml index ea503a9cc2..fdc517617e 100644 --- a/app/views/layouts/nav/_admin.html.haml +++ b/app/views/layouts/nav/_admin.html.haml @@ -40,3 +40,8 @@ %span Background Jobs + = nav_link(controller: :application_settings) do + = link_to admin_application_settings_path do + %i.fa.fa-cogs + %span + Settings diff --git a/config/routes.rb b/config/routes.rb index 7760f32dc3..c4df4283cb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -109,7 +109,7 @@ Gitlab::Application.routes.draw do end end - resource :application_settings + resource :application_settings, only: [:show, :update] root to: "dashboard#index" end diff --git a/features/admin/settings.feature b/features/admin/settings.feature new file mode 100644 index 0000000000..8799c053ea --- /dev/null +++ b/features/admin/settings.feature @@ -0,0 +1,9 @@ +@admin +Feature: Admin Settings + Background: + Given I sign in as an admin + And I visit admin settings page + + Scenario: Change application settings + When I disable gravatars and save form + Then I should be see gravatar disabled diff --git a/features/steps/admin/settings.rb b/features/steps/admin/settings.rb new file mode 100644 index 0000000000..e8168e85de --- /dev/null +++ b/features/steps/admin/settings.rb @@ -0,0 +1,16 @@ +class Spinach::Features::AdminSettings < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedAdmin + include Gitlab::CurrentSettings + + step 'I disable gravatars and save form' do + uncheck 'Gravatar enabled' + click_button 'Save' + end + + step 'I should be see gravatar disabled' do + current_application_settings.gravatar_enabled.should be_false + page.should have_content 'Application settings saved successfully' + end +end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index e657fceb70..689b297dff 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -167,6 +167,10 @@ module SharedPaths visit admin_teams_path end + step 'I visit admin settings page' do + visit admin_application_settings_path + end + # ---------------------------------------- # Generic Project # ---------------------------------------- diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb new file mode 100644 index 0000000000..3467bb892f --- /dev/null +++ b/lib/gitlab/current_settings.rb @@ -0,0 +1,7 @@ +module Gitlab + module CurrentSettings + def current_application_settings + ApplicationSetting.current + end + end +end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb new file mode 100644 index 0000000000..3a8d52c11c --- /dev/null +++ b/spec/models/application_setting_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe ApplicationSetting, models: true do + describe 'should exists on start' do + it { ApplicationSetting.count.should_not be_zero } + end +end From 8133e44998236438c46e1b662bd284323287f415 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 10:30:35 -0800 Subject: [PATCH 06/18] Hack for migrating to new settings --- config/initializers/8_application_settings.rb | 3 +-- lib/gitlab/current_settings.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config/initializers/8_application_settings.rb b/config/initializers/8_application_settings.rb index c4706756b6..6f1dec7de0 100644 --- a/config/initializers/8_application_settings.rb +++ b/config/initializers/8_application_settings.rb @@ -1,4 +1,4 @@ -begin +if ActiveRecord::Base.connection.table_exists?('application_settings') unless ApplicationSetting.any? ApplicationSetting.create( default_projects_limit: Settings.gitlab['default_projects_limit'], @@ -8,5 +8,4 @@ begin sign_in_text: Settings.extra['sign_in_text'], ) end -rescue end diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 3467bb892f..60efc70aa4 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -1,7 +1,17 @@ module Gitlab module CurrentSettings def current_application_settings - ApplicationSetting.current + if ActiveRecord::Base.connection.table_exists?('application_settings') + ApplicationSetting.current + else + OpenStruct.new( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end end end end From d0a50985ec613584821806062df4eaa39337449c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 11:26:16 -0800 Subject: [PATCH 07/18] Create ApplicationSettings if does not exist in runtime --- .../admin/application_settings_controller.rb | 2 +- app/models/application_setting.rb | 10 +++++++++ config/initializers/8_application_settings.rb | 11 ---------- lib/gitlab/current_settings.rb | 21 ++++++++++++------- 4 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 config/initializers/8_application_settings.rb diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 39ca0b4feb..5116f1f177 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -16,7 +16,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController private def set_application_setting - @application_setting = ApplicationSetting.last + @application_setting = ApplicationSetting.current end def application_setting_params diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 4b885461cb..47fa6f1071 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -2,4 +2,14 @@ class ApplicationSetting < ActiveRecord::Base def self.current ApplicationSetting.last end + + def self.create_from_defaults + create( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end end diff --git a/config/initializers/8_application_settings.rb b/config/initializers/8_application_settings.rb deleted file mode 100644 index 6f1dec7de0..0000000000 --- a/config/initializers/8_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -if ActiveRecord::Base.connection.table_exists?('application_settings') - unless ApplicationSetting.any? - ApplicationSetting.create( - default_projects_limit: Settings.gitlab['default_projects_limit'], - signup_enabled: Settings.gitlab['signup_enabled'], - signin_enabled: Settings.gitlab['signin_enabled'], - gravatar_enabled: Settings.gravatar['enabled'], - sign_in_text: Settings.extra['sign_in_text'], - ) - end -end diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 60efc70aa4..f3b9dcacde 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -2,16 +2,21 @@ module Gitlab module CurrentSettings def current_application_settings if ActiveRecord::Base.connection.table_exists?('application_settings') - ApplicationSetting.current + ApplicationSetting.current || + ApplicationSetting.create_from_defaults else - OpenStruct.new( - default_projects_limit: Settings.gitlab['default_projects_limit'], - signup_enabled: Settings.gitlab['signup_enabled'], - signin_enabled: Settings.gitlab['signin_enabled'], - gravatar_enabled: Settings.gravatar['enabled'], - sign_in_text: Settings.extra['sign_in_text'], - ) + fake_application_settings end end + + def fake_application_settings + OpenStruct.new( + default_projects_limit: Settings.gitlab['default_projects_limit'], + signup_enabled: Settings.gitlab['signup_enabled'], + signin_enabled: Settings.gitlab['signin_enabled'], + gravatar_enabled: Settings.gravatar['enabled'], + sign_in_text: Settings.extra['sign_in_text'], + ) + end end end From 939c046a9872c1d7c38d73dc08860681ecebd1f1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 13:21:00 -0800 Subject: [PATCH 08/18] Fix feature and tests --- app/controllers/registrations_controller.rb | 2 +- spec/helpers/application_helper_spec.rb | 2 +- spec/models/application_setting_spec.rb | 4 +--- spec/requests/api/users_spec.rb | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 981dc2d802..52db44bf82 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -26,7 +26,7 @@ class RegistrationsController < Devise::RegistrationsController private def signup_enabled? - if current_application_settings.signup_enabled? + unless current_application_settings.signup_enabled? redirect_to(new_user_session_path) end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 07dd33b211..9cdbc846b1 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -87,7 +87,7 @@ describe ApplicationHelper do let(:user_email) { 'user@email.com' } it "should return a generic avatar path when Gravatar is disabled" do - Gitlab.config.gravatar.stub(:enabled).and_return(false) + ApplicationSetting.any_instance.stub(gravatar_enabled?: false) gravatar_icon(user_email).should match('no_avatar.png') end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 3a8d52c11c..039775dddd 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -1,7 +1,5 @@ require 'spec_helper' describe ApplicationSetting, models: true do - describe 'should exists on start' do - it { ApplicationSetting.count.should_not be_zero } - end + it { ApplicationSetting.create_from_defaults.should be_valid } end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 1ecc79ea7e..dec488c6d0 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -186,7 +186,7 @@ describe API::API, api: true do describe "GET /users/sign_up" do context 'enabled' do before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) + ApplicationSetting.any_instance.stub(signup_enabled?: true) end it "should return sign up page if signup is enabled" do @@ -197,7 +197,7 @@ describe API::API, api: true do context 'disabled' do before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(false) + ApplicationSetting.any_instance.stub(signup_enabled?: false) end it "should redirect to sign in page if signup is disabled" do From 08c9cb4cabab648d90e6fcf055f1143fbbc994e8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 14:26:43 -0800 Subject: [PATCH 09/18] Finally fix stuff related to dynamic config --- app/helpers/application_settings_helper.rb | 8 ++++++-- app/helpers/profile_helper.rb | 2 +- app/views/admin/dashboard/index.html.haml | 4 ++-- spec/features/profile_spec.rb | 4 ++-- spec/features/users_spec.rb | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 16db33efd3..0429931610 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -1,10 +1,14 @@ module ApplicationSettingsHelper + def gravatar_enabled? + current_application_settings.gravatar_enabled? + end + def signup_enabled? - current_application_settings.signup_enabled + current_application_settings.signup_enabled? end def signin_enabled? - current_application_settings.signin_enabled + current_application_settings.signin_enabled? end def extra_sign_in_text diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index 6480fd3886..9e37e44732 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -14,6 +14,6 @@ module ProfileHelper end def show_profile_remove_tab? - gitlab_config.signup_enabled + signup_enabled? end end diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 7427cea7e8..c6badeb4bd 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -104,7 +104,7 @@ %p Sign up %span.light.pull-right - = boolean_to_icon gitlab_config.signup_enabled + = boolean_to_icon signup_enabled? %p LDAP %span.light.pull-right @@ -112,7 +112,7 @@ %p Gravatar %span.light.pull-right - = boolean_to_icon Gitlab.config.gravatar.enabled + = boolean_to_icon gravatar_enabled? %p OmniAuth %span.light.pull-right diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index bdf7b59114..4a76e89fd3 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -9,7 +9,7 @@ describe "Profile account page", feature: true do describe "when signup is enabled" do before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) + ApplicationSetting.any_instance.stub(signup_enabled?: true) visit profile_account_path end @@ -23,7 +23,7 @@ describe "Profile account page", feature: true do describe "when signup is disabled" do before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(false) + ApplicationSetting.any_instance.stub(signup_enabled?: false) visit profile_account_path end diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index a1206989d3..e2b631001c 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'Users', feature: true do describe "GET /users/sign_up" do before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) + ApplicationSetting.any_instance.stub(signup_enabled?: true) end it "should create a new user account" do From ff39821935d04f50beff8f15c789bd0f327dca10 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 15:43:34 -0800 Subject: [PATCH 10/18] Update CHANGELOG --- CHANGELOG | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index b7e85f2e5e..a69acdaae8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,23 @@ v 7.7.0 - - Added API support for sorting projects - Update gitlab_git to version 7.0.0.rc13 + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - Change some of application settings on fly in admin area UI + - Redesign signin/signup pages v 7.6.0 - Fork repository to groups From bc95576e2cbbd2def7a6fce1bde2d0263a3d7da1 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 9 Jan 2015 11:26:26 +0100 Subject: [PATCH 11/18] Rescue missing database errors While loading the Rails app we cannot assume that the gitlabhq_xxx database exists already. If we do, `rake gitlab:setup` breaks! This is a quick hack to make sure that fresh development setups of GitLab (from master) will work again. --- lib/gitlab/current_settings.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index f3b9dcacde..5d88a601de 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -1,10 +1,14 @@ module Gitlab module CurrentSettings def current_application_settings - if ActiveRecord::Base.connection.table_exists?('application_settings') - ApplicationSetting.current || - ApplicationSetting.create_from_defaults - else + begin + if ActiveRecord::Base.connection.table_exists?('application_settings') + ApplicationSetting.current || + ApplicationSetting.create_from_defaults + else + fake_application_settings + end + rescue ActiveRecord::NoDatabaseError fake_application_settings end end From 3c19929c757e5ff45f5afa3713002ee1862c0b75 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 9 Jan 2015 12:29:48 -0800 Subject: [PATCH 12/18] Cleanup and refactor release doc. Follow issue as a todo list --- doc/release/howto_rc1.md | 126 ++++++++++++++++++ doc/release/monthly.md | 271 ++++++++++----------------------------- 2 files changed, 194 insertions(+), 203 deletions(-) create mode 100644 doc/release/howto_rc1.md diff --git a/doc/release/howto_rc1.md b/doc/release/howto_rc1.md new file mode 100644 index 0000000000..2bfc23951e --- /dev/null +++ b/doc/release/howto_rc1.md @@ -0,0 +1,126 @@ +# How to create RC1 + +The RC1 release comes with the task to update the installation and upgrade docs. Be mindful that there might already be merge requests for this on GitLab or GitHub. + +### **1. Update the installation guide** + +1. Check if it references the correct branch `x-x-stable` (doesn't exist yet, but that is okay) +1. Check the [GitLab Shell version](/lib/tasks/gitlab/check.rake#L782) +1. Check the [Git version](/lib/tasks/gitlab/check.rake#L794) +1. There might be other changes. Ask around. + +### **2. Create update guides** + +1. Create: CE update guide from previous version. Like `7.3-to-7.4.md` +1. Create: CE to EE update guide in EE repository for latest version. +1. Update: `6.x-or-7.x-to-7.x.md` to latest version. +1. Create: CI update guide from previous version + +It's best to copy paste the previous guide and make changes where necessary. +The typical steps are listed below with any points you should specifically look at. + +#### 0. Any major changes? + +List any major changes here, so the user is aware of them before starting to upgrade. For instance: + +- Database updates +- Web server changes +- File structure changes + +#### 1. Stop server + +#### 2. Make backup + +#### 3. Do users need to update dependencies like `git`? + +- Check if the [GitLab Shell version](/lib/tasks/gitlab/check.rake#L782) changed since the last release. + +- Check if the [Git version](/lib/tasks/gitlab/check.rake#L794) changed since the last release. + +#### 4. Get latest code + +#### 5. Does GitLab shell need to be updated? + +#### 6. Install libs, migrations, etc. + +#### 7. Any config files updated since last release? + +Check if any of these changed since last release: + +- [lib/support/nginx/gitlab](/lib/support/nginx/gitlab) +- [lib/support/nginx/gitlab-ssl](/lib/support/nginx/gitlab-ssl) +- +- [config/gitlab.yml.example](/config/gitlab.yml.example) +- [config/unicorn.rb.example](/config/unicorn.rb.example) +- [config/database.yml.mysql](/config/database.yml.mysql) +- [config/database.yml.postgresql](/config/database.yml.postgresql) +- [config/initializers/rack_attack.rb.example](/config/initializers/rack_attack.rb.example) +- [config/resque.yml.example](/config/resque.yml.example) + +#### 8. Need to update init script? + +Check if the `init.d/gitlab` script changed since last release: [lib/support/init.d/gitlab](/lib/support/init.d/gitlab) + +#### 9. Start application + +#### 10. Check application status + +### **3. Code quality indicators** + +Make sure the code quality indicators are green / good. + +- [![Build status](http://ci.gitlab.org/projects/1/status.png?ref=master)](http://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) + +- [![Build Status](https://semaphoreapp.com/api/v1/projects/2f1a5809-418b-4cc2-a1f4-819607579fe7/243338/badge.png)](https://semaphoreapp.com/gitlabhq/gitlabhq) (master branch) + +- [![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.png)](https://codeclimate.com/github/gitlabhq/gitlabhq) + +- [![Dependency Status](https://gemnasium.com/gitlabhq/gitlabhq.png)](https://gemnasium.com/gitlabhq/gitlabhq) this button can be yellow (small updates are available) but must not be red (a security fix or an important update is available) + +- [![Coverage Status](https://coveralls.io/repos/gitlabhq/gitlabhq/badge.png?branch=master)](https://coveralls.io/r/gitlabhq/gitlabhq) + +### 4. Run release tool for CE and EE + +**Make sure EE `master` has latest changes from CE `master`** + +Get release tools + +``` +git clone git@dev.gitlab.org:gitlab/release-tools.git +cd release-tools +``` + +Release candidate creates stable branch from master. +So we need to sync master branch between all CE remotes. Also do same for EE. + +``` +bundle exec rake sync +``` + +Create release candidate and stable branch: + +``` +bundle exec rake release["x.x.0.rc1"] +``` + +Now developers can use master for merging new features. +So you should use stable branch for future code chages related to release. + + +### 5. Release GitLab CI RC1 + +Add to your local `gitlab-ci/.git/config`: + +``` +[remote "public"] + url = none + pushurl = git@dev.gitlab.org:gitlab/gitlab-ci.git + pushurl = git@gitlab.com:gitlab-org/gitlab-ci.git + pushurl = git@github.com:gitlabhq/gitlab-ci.git +``` + +* Create a stable branch `x-y-stable` +* Bump VERSION to `x.y.0.rc1` +* `git tag -a v$(cat VERSION) -m "Version $(cat VERSION)" +* `git push public x-y-stable v$(cat VERSION)` + diff --git a/doc/release/monthly.md b/doc/release/monthly.md index b31fd88540..810f992caf 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -2,209 +2,90 @@ NOTE: This is a guide for GitLab developers. -# **7 workdays before release - Code Freeze & Release Manager** +It starts 7 days before release. Current release manager must choose next release manager. +New release manager should create overall issue at GitLab -### **1. Stop merging in code, except for important bug fixes** -### **2. Release Manager** +## Release Manager A release manager is selected that coordinates all releases the coming month, including the patch releases for previous releases. The release manager has to make sure all the steps below are done and delegated where necessary. This person should also make sure this document is kept up to date and issues are created and updated. -### **3. Create an overall issue** +## Take weekend and vacations into account + +Ensure that there is enough time to incorporate the findings of the release candidate, etc. + +## Create an overall issue and follow it Create issue for GitLab CE project(internal). Name it "Release x.x.x" for easier searching. Replace the dates with actual dates based on the number of workdays before the release. +All steps from issue template are explained below ``` -Xth: +Xth: (7 working days befor 22th) +- [ ] Code freeze - [ ] Update the CE changelog (#LINK) - [ ] Update the EE changelog (#LINK) - [ ] Update the CI changelog (#LINK) - [ ] Triage the omnibus-gitlab milestone -Xth: +Xth: (6 working days befor 22th) + +- [ ] Merge CE master in to EE master via merge request (#LINK) +- [ ] Create CE, EE, CI RC1 versions (#LINK) + +Xth: (5 working days befor 22th) -- [ ] Merge CE in to EE (#LINK) - [ ] Close the omnibus-gitlab milestone +- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) -Xth: - -- [ ] Create x.x.0.rc1 (#LINK) -- [ ] Create x.x.0.rc1-ee (#LINK) -- [ ] Create CI y.y.0.rc1 (#LINK) -- [ ] Build package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) - -Xth: +Xth: (4 working days befor 22th) - [ ] Update GitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) -- [ ] Regression issues (CE, CI) and tweet about rc1 (#LINK) +- [ ] Create regression issues (CE, CI) (#LINK) +- [ ] Tweet about rc1 (#LINK) - [ ] Start blog post (#LINK) +- [ ] Determine QA person and notify him -Xth: +Xth: (2 working days befor 22th) +- [ ] Merge CE stable branch into EE stable branch - [ ] Do QA and fix anything coming out of it (#LINK) +Xth: (1 working day befor 22th) + +- [ ] Create CE, EE, CI stable versions (#LINK) +- [ ] Create Omnibus tags and build packages + 22nd: - [ ] Release CE, EE and CI (#LINK) -Xth: +Xth: (1 working day after 22th) - [ ] Deploy to GitLab.com (#LINK) ``` -### **4. Update changelog** +- - - + +## Code Freeze + +Stop merging code in master, except for important bug fixes + +## Update changelog Any changes not yet added to the changelog are added by lead developer and in that merge request the complete team is asked if there is anything missing. There are three changelogs that need to be updated: CE, EE and CI. -### **5. Take weekend and vacations into account** +## Create RC1 (CE, EE, CI) -Ensure that there is enough time to incorporate the findings of the release candidate, etc. +[Follow this How-to guide](howto_rc1.md) to create RC1. -# **6 workdays before release- Merge the CE into EE** - -Do this via a merge request. - -# **5 workdays before release - Create RC1** - -The RC1 release comes with the task to update the installation and upgrade docs. Be mindful that there might already be merge requests for this on GitLab or GitHub. - -### **1. Update the installation guide** - -1. Check if it references the correct branch `x-x-stable` (doesn't exist yet, but that is okay) -1. Check the [GitLab Shell version](/lib/tasks/gitlab/check.rake#L782) -1. Check the [Git version](/lib/tasks/gitlab/check.rake#L794) -1. There might be other changes. Ask around. - -### **2. Create update guides** - -1. Create: CE update guide from previous version. Like `7.3-to-7.4.md` -1. Create: CE to EE update guide in EE repository for latest version. -1. Update: `6.x-or-7.x-to-7.x.md` to latest version. -1. Create: CI update guide from previous version - -It's best to copy paste the previous guide and make changes where necessary. -The typical steps are listed below with any points you should specifically look at. - -#### 0. Any major changes? - -List any major changes here, so the user is aware of them before starting to upgrade. For instance: - -- Database updates -- Web server changes -- File structure changes - -#### 1. Stop server - -#### 2. Make backup - -#### 3. Do users need to update dependencies like `git`? - -- Check if the [GitLab Shell version](/lib/tasks/gitlab/check.rake#L782) changed since the last release. - -- Check if the [Git version](/lib/tasks/gitlab/check.rake#L794) changed since the last release. - -#### 4. Get latest code - -#### 5. Does GitLab shell need to be updated? - -#### 6. Install libs, migrations, etc. - -#### 7. Any config files updated since last release? - -Check if any of these changed since last release: - -- [lib/support/nginx/gitlab](/lib/support/nginx/gitlab) -- [lib/support/nginx/gitlab-ssl](/lib/support/nginx/gitlab-ssl) -- -- [config/gitlab.yml.example](/config/gitlab.yml.example) -- [config/unicorn.rb.example](/config/unicorn.rb.example) -- [config/database.yml.mysql](/config/database.yml.mysql) -- [config/database.yml.postgresql](/config/database.yml.postgresql) -- [config/initializers/rack_attack.rb.example](/config/initializers/rack_attack.rb.example) -- [config/resque.yml.example](/config/resque.yml.example) - -#### 8. Need to update init script? - -Check if the `init.d/gitlab` script changed since last release: [lib/support/init.d/gitlab](/lib/support/init.d/gitlab) - -#### 9. Start application - -#### 10. Check application status - -### **3. Code quality indicators** - -Make sure the code quality indicators are green / good. - -- [![Build status](http://ci.gitlab.org/projects/1/status.png?ref=master)](http://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) - -- [![Build Status](https://semaphoreapp.com/api/v1/projects/2f1a5809-418b-4cc2-a1f4-819607579fe7/243338/badge.png)](https://semaphoreapp.com/gitlabhq/gitlabhq) (master branch) - -- [![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.png)](https://codeclimate.com/github/gitlabhq/gitlabhq) - -- [![Dependency Status](https://gemnasium.com/gitlabhq/gitlabhq.png)](https://gemnasium.com/gitlabhq/gitlabhq) this button can be yellow (small updates are available) but must not be red (a security fix or an important update is available) - -- [![Coverage Status](https://coveralls.io/repos/gitlabhq/gitlabhq/badge.png?branch=master)](https://coveralls.io/r/gitlabhq/gitlabhq) - -### **4. Run release tool** - -**Make sure EE `master` has latest changes from CE `master`** - -Get release tools - -``` -git clone git@dev.gitlab.org:gitlab/release-tools.git -cd release-tools -``` - -Release candidate creates stable branch from master. -So we need to sync master branch between all CE remotes. Also do same for EE. - -``` -bundle exec rake sync -``` - -Create release candidate and stable branch: - -``` -bundle exec rake release["x.x.0.rc1"] -``` - -Now developers can use master for merging new features. -So you should use stable branch for future code chages related to release. - - -### 5. Release GitLab CI RC1 - -Add to your local `gitlab-ci/.git/config`: - -``` -[remote "public"] - url = none - pushurl = git@dev.gitlab.org:gitlab/gitlab-ci.git - pushurl = git@gitlab.com:gitlab-org/gitlab-ci.git - pushurl = git@github.com:gitlabhq/gitlab-ci.git -``` - -* Create a stable branch `x-y-stable` -* Bump VERSION to `x.y.0.rc1` -* `git tag -a v$(cat VERSION) -m "Version $(cat VERSION)" -* `git push public x-y-stable v$(cat VERSION)` - - -# **4 workdays before release - Release RC1** - -### **1. Determine QA person** - -Notify person of QA day. - -### **2. Update GitLab.com** +## Update GitLab.com with RC1 Merge the RC1 EE code into GitLab.com. Once the build is green, create a package. @@ -212,7 +93,24 @@ If there are big database migrations consider testing them with the production d Try to deploy in the morning. It is important to do this as soon as possible, so we can catch any errors before we release the full version. -### **3. Prepare the blog post** +## Create a regressions issue + +On [the GitLab CE issue tracker on GitLab.com](https://gitlab.com/gitlab-org/gitlab-ce/issues/) create an issue titled "GitLab X.X regressions" add the following text: + +This is a meta issue to discuss possible regressions in this monthly release and any patch versions. +Please do not raise issues directly in this issue but link to issues that might warrant a patch release. +The decision to create a patch release or not is with the release manager who is assigned to this issue. +The release manager will comment here about the plans for patch releases. + +Assign the issue to the release manager and /cc all the core-team members active on the issue tracker. If there are any known bugs in the release add them immediately. + +## Tweet about RC1 + +Tweet about the RC release: + +> GitLab x.x.0.rc1 is out. This release candidate is only suitable for testing. Please link regressions issues from LINK_TO_REGRESSION_ISSUE + +## Prepare the blog post - Start with a complete copy of the [release blog template](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/doc/release_blog_template.md) and fill it out. - Make sure the blog post contains information about the GitLab CI release. @@ -228,34 +126,7 @@ It is important to do this as soon as possible, so we can catch any errors befor - Assign to one reviewer who will fix spelling issues by editing the branch (either with a git client or by using the online editor) - Comment to the reviewer: '@person Please mention the whole team as soon as you are done (3 workdays before release at the latest)' -### **4. Create a regressions issue** - -On [the GitLab CE issue tracker on GitLab.com](https://gitlab.com/gitlab-org/gitlab-ce/issues/) create an issue titled "GitLab X.X regressions" add the following text: - -This is a meta issue to discuss possible regressions in this monthly release and any patch versions. -Please do not raise issues directly in this issue but link to issues that might warrant a patch release. -The decision to create a patch release or not is with the release manager who is assigned to this issue. -The release manager will comment here about the plans for patch releases. - -Assign the issue to the release manager and /cc all the core-team members active on the issue tracker. If there are any known bugs in the release add them immediately. - -### **5. Tweet** - -Tweet about the RC release: - -> GitLab x.x.0.rc1 is out. This release candidate is only suitable for testing. Please link regressions issues from LINK_TO_REGRESSION_ISSUE - -# **1 workdays before release - Preparation** - -### **0. Doublecheck blog post** - -Doublecheck the everyone has been mentioned in the blog post. - -### **1. Pre QA merge** - -Merge CE into EE before doing the QA. - -### **2. QA** +## QA Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. @@ -263,19 +134,14 @@ Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gi **NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. -### **3. Fix anything coming out of the QA** +#### Fix anything coming out of the QA Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. **NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, create an issue about it in order to discuss the next steps after the release. -# **Workday before release - Create Omnibus tags and build packages** - -**Make sure EE `x-x-stable-ee` has latest changes from CE `x-x-stable`** - - -### **1. Release code** +## Create CE, EE, CI stable versions Get release tools @@ -296,28 +162,27 @@ Also perform these steps for GitLab CI: - create annotated tag - push the stable branch and the annotated tag to the public repositories -### **2. Update installation.md** - Update [installation.md](/doc/install/installation.md) to the newest version in master. -### **3. Build the Omnibus packages** +## Create Omnibus tags and build packages Follow the [release doc in the Omnibus repository](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/release.md). This can happen before tagging because Omnibus uses tags in its own repo and SHA1's to refer to the GitLab codebase. -# **22nd - Release CE, EE and CI** +## Release CE, EE and CI -### **1. Publish packages for new release** +### 1. Publish packages for new release Update `downloads/index.html` and `downloads/archive/index.html` in `www-gitlab-com` repository. -### **2. Publish blog for new release** +### 2. Publish blog for new release +Doublecheck the everyone has been mentioned in the blog post. Merge the [blog merge request](#1-prepare-the-blog-post) in `www-gitlab-com` repository. -### **3. Tweet to blog** +### 3. Tweet to blog Send out a tweet to share the good news with the world. List the most important features and link to the blog post. @@ -326,7 +191,7 @@ Proposed tweet "Release of GitLab X.X & CI Y.Y! FEATURE, FEATURE and FEATURE
  • Date: Sat, 10 Jan 2015 02:12:00 +0000 Subject: [PATCH 13/18] Improve monthly.md with fixes proposed from @sytse --- doc/release/monthly.md | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 810f992caf..917dc7f693 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -14,7 +14,9 @@ This person should also make sure this document is kept up to date and issues ar ## Take weekend and vacations into account -Ensure that there is enough time to incorporate the findings of the release candidate, etc. +The time is measured in weekdays to compensate for weekends. +Do things on time to prevent problems due to rush jobs or too little testing time. +Make sure that you take into account vacations of maintainers. ## Create an overall issue and follow it @@ -35,24 +37,29 @@ Xth: (6 working days befor 22th) - [ ] Merge CE master in to EE master via merge request (#LINK) - [ ] Create CE, EE, CI RC1 versions (#LINK) +- [ ] Determine QA person and notify this person Xth: (5 working days befor 22th) +- [ ] Do QA and fix anything coming out of it (#LINK) - [ ] Close the omnibus-gitlab milestone -- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) Xth: (4 working days befor 22th) +- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) - [ ] Update GitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) + +Xth: (3 working days befor 22th) + - [ ] Create regression issues (CE, CI) (#LINK) - [ ] Tweet about rc1 (#LINK) -- [ ] Start blog post (#LINK) -- [ ] Determine QA person and notify him +- [ ] Prepare the blog post (#LINK) + Xth: (2 working days befor 22th) - [ ] Merge CE stable branch into EE stable branch -- [ ] Do QA and fix anything coming out of it (#LINK) +- [ ] Check that everyone is mentioned on the blog post (the reviewer should have done this one working day ago) Xth: (1 working day befor 22th) @@ -85,6 +92,21 @@ There are three changelogs that need to be updated: CE, EE and CI. [Follow this How-to guide](howto_rc1.md) to create RC1. +## QA + +Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. + +Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md). + +**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. + +#### Fix anything coming out of the QA + +Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. + +**NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, +create an issue about it in order to discuss the next steps after the release. + ## Update GitLab.com with RC1 Merge the RC1 EE code into GitLab.com. @@ -126,21 +148,6 @@ Tweet about the RC release: - Assign to one reviewer who will fix spelling issues by editing the branch (either with a git client or by using the online editor) - Comment to the reviewer: '@person Please mention the whole team as soon as you are done (3 workdays before release at the latest)' -## QA - -Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. - -Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md). - -**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. - -#### Fix anything coming out of the QA - -Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. - -**NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, -create an issue about it in order to discuss the next steps after the release. - ## Create CE, EE, CI stable versions Get release tools @@ -193,5 +200,4 @@ Consider creating a post on Hacker News. ## Update GitLab.com with stable version -- Build a package for gitlab.com based on the official release instead of RC1 - Deploy the package (should not need downtime because of the small difference with RC1) From b9dd52dd14a98b69db0537fa3431fe6a01a3284d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 10 Jan 2015 02:13:09 +0000 Subject: [PATCH 14/18] Improve monthly.md with fixes proposed from Sytse --- doc/release/monthly.md | 48 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 917dc7f693..810f992caf 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -14,9 +14,7 @@ This person should also make sure this document is kept up to date and issues ar ## Take weekend and vacations into account -The time is measured in weekdays to compensate for weekends. -Do things on time to prevent problems due to rush jobs or too little testing time. -Make sure that you take into account vacations of maintainers. +Ensure that there is enough time to incorporate the findings of the release candidate, etc. ## Create an overall issue and follow it @@ -37,29 +35,24 @@ Xth: (6 working days befor 22th) - [ ] Merge CE master in to EE master via merge request (#LINK) - [ ] Create CE, EE, CI RC1 versions (#LINK) -- [ ] Determine QA person and notify this person Xth: (5 working days befor 22th) -- [ ] Do QA and fix anything coming out of it (#LINK) - [ ] Close the omnibus-gitlab milestone +- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) Xth: (4 working days befor 22th) -- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) - [ ] Update GitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) - -Xth: (3 working days befor 22th) - - [ ] Create regression issues (CE, CI) (#LINK) - [ ] Tweet about rc1 (#LINK) -- [ ] Prepare the blog post (#LINK) - +- [ ] Start blog post (#LINK) +- [ ] Determine QA person and notify him Xth: (2 working days befor 22th) - [ ] Merge CE stable branch into EE stable branch -- [ ] Check that everyone is mentioned on the blog post (the reviewer should have done this one working day ago) +- [ ] Do QA and fix anything coming out of it (#LINK) Xth: (1 working day befor 22th) @@ -92,21 +85,6 @@ There are three changelogs that need to be updated: CE, EE and CI. [Follow this How-to guide](howto_rc1.md) to create RC1. -## QA - -Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. - -Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md). - -**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. - -#### Fix anything coming out of the QA - -Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. - -**NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, -create an issue about it in order to discuss the next steps after the release. - ## Update GitLab.com with RC1 Merge the RC1 EE code into GitLab.com. @@ -148,6 +126,21 @@ Tweet about the RC release: - Assign to one reviewer who will fix spelling issues by editing the branch (either with a git client or by using the online editor) - Comment to the reviewer: '@person Please mention the whole team as soon as you are done (3 workdays before release at the latest)' +## QA + +Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. + +Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md). + +**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. + +#### Fix anything coming out of the QA + +Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. + +**NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, +create an issue about it in order to discuss the next steps after the release. + ## Create CE, EE, CI stable versions Get release tools @@ -200,4 +193,5 @@ Consider creating a post on Hacker News. ## Update GitLab.com with stable version +- Build a package for gitlab.com based on the official release instead of RC1 - Deploy the package (should not need downtime because of the small difference with RC1) From c736968695d2b2e0bd3be16fda2287e02966d9b2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 10 Jan 2015 02:14:45 +0000 Subject: [PATCH 15/18] Improve monthly.md with fixes proposed from Sytse --- doc/release/monthly.md | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 810f992caf..917dc7f693 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -14,7 +14,9 @@ This person should also make sure this document is kept up to date and issues ar ## Take weekend and vacations into account -Ensure that there is enough time to incorporate the findings of the release candidate, etc. +The time is measured in weekdays to compensate for weekends. +Do things on time to prevent problems due to rush jobs or too little testing time. +Make sure that you take into account vacations of maintainers. ## Create an overall issue and follow it @@ -35,24 +37,29 @@ Xth: (6 working days befor 22th) - [ ] Merge CE master in to EE master via merge request (#LINK) - [ ] Create CE, EE, CI RC1 versions (#LINK) +- [ ] Determine QA person and notify this person Xth: (5 working days befor 22th) +- [ ] Do QA and fix anything coming out of it (#LINK) - [ ] Close the omnibus-gitlab milestone -- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) Xth: (4 working days befor 22th) +- [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) - [ ] Update GitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) + +Xth: (3 working days befor 22th) + - [ ] Create regression issues (CE, CI) (#LINK) - [ ] Tweet about rc1 (#LINK) -- [ ] Start blog post (#LINK) -- [ ] Determine QA person and notify him +- [ ] Prepare the blog post (#LINK) + Xth: (2 working days befor 22th) - [ ] Merge CE stable branch into EE stable branch -- [ ] Do QA and fix anything coming out of it (#LINK) +- [ ] Check that everyone is mentioned on the blog post (the reviewer should have done this one working day ago) Xth: (1 working day befor 22th) @@ -85,6 +92,21 @@ There are three changelogs that need to be updated: CE, EE and CI. [Follow this How-to guide](howto_rc1.md) to create RC1. +## QA + +Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. + +Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md). + +**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. + +#### Fix anything coming out of the QA + +Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. + +**NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, +create an issue about it in order to discuss the next steps after the release. + ## Update GitLab.com with RC1 Merge the RC1 EE code into GitLab.com. @@ -126,21 +148,6 @@ Tweet about the RC release: - Assign to one reviewer who will fix spelling issues by editing the branch (either with a git client or by using the online editor) - Comment to the reviewer: '@person Please mention the whole team as soon as you are done (3 workdays before release at the latest)' -## QA - -Create issue on dev.gitlab.org `gitlab` repository, named "GitLab X.X QA" in order to keep track of the progress. - -Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md). - -**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue. - -#### Fix anything coming out of the QA - -Create an issue with description of a problem, if it is quick fix fix it yourself otherwise contact the team for advice. - -**NOTE** If there is a problem that cannot be fixed in a timely manner, reverting the feature is an option! If the feature is reverted, -create an issue about it in order to discuss the next steps after the release. - ## Create CE, EE, CI stable versions Get release tools @@ -193,5 +200,4 @@ Consider creating a post on Hacker News. ## Update GitLab.com with stable version -- Build a package for gitlab.com based on the official release instead of RC1 - Deploy the package (should not need downtime because of the small difference with RC1) From 9c03c1c545d1afeaf12d8ee1c204936cdf8c55e1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 9 Jan 2015 19:10:01 -0800 Subject: [PATCH 16/18] Make automerge via satellite --- app/assets/javascripts/merge_request.js.coffee | 13 +++++++++++++ .../projects/merge_requests_controller.rb | 7 ++++--- app/views/projects/merge_requests/_show.html.haml | 2 +- app/views/projects/merge_requests/automerge.js.haml | 3 +-- app/workers/auto_merge_worker.rb | 13 +++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 app/workers/auto_merge_worker.rb diff --git a/app/assets/javascripts/merge_request.js.coffee b/app/assets/javascripts/merge_request.js.coffee index 9e3ca45ce0..5bcbd56852 100644 --- a/app/assets/javascripts/merge_request.js.coffee +++ b/app/assets/javascripts/merge_request.js.coffee @@ -135,3 +135,16 @@ class @MergeRequest this.$('.automerge_widget').hide() this.$('.merge-in-progress').hide() this.$('.automerge_widget.already_cannot_be_merged').show() + + mergeInProgress: -> + $.ajax + type: 'GET' + url: $('.merge-request').data('url') + success: (data) => + switch data.state + when 'merged' + location.reload() + else + setTimeout(merge_request.mergeInProgress, 3000) + dataType: 'json' + diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index d23461821d..3f702b0af9 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -27,6 +27,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController respond_to do |format| format.html + format.json { render json: @merge_request } format.diff { render text: @merge_request.to_diff(current_user) } format.patch { render text: @merge_request.to_patch(current_user) } end @@ -104,15 +105,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController if @merge_request.unchecked? @merge_request.check_if_can_be_merged end - render json: {merge_status: @merge_request.merge_status_name} + + render json: { merge_status: @merge_request.merge_status_name } end def automerge return access_denied! unless allowed_to_merge? if @merge_request.open? && @merge_request.can_be_merged? - @merge_request.should_remove_source_branch = params[:should_remove_source_branch] - @merge_request.automerge!(current_user, params[:commit_message]) + AutoMergeWorker.perform_async(@merge_request.id, current_user.id, params) @status = true else @status = false diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml index f8d2673335..8e31a7e3fe 100644 --- a/app/views/projects/merge_requests/_show.html.haml +++ b/app/views/projects/merge_requests/_show.html.haml @@ -1,4 +1,4 @@ -.merge-request +.merge-request{'data-url' => project_merge_request_path(@project, @merge_request)} = render "projects/merge_requests/show/mr_title" %hr = render "projects/merge_requests/show/mr_box" diff --git a/app/views/projects/merge_requests/automerge.js.haml b/app/views/projects/merge_requests/automerge.js.haml index e01ff662e7..a53cbb150a 100644 --- a/app/views/projects/merge_requests/automerge.js.haml +++ b/app/views/projects/merge_requests/automerge.js.haml @@ -1,7 +1,6 @@ -if @status :plain - location.reload(); + merge_request.mergeInProgress(); -else :plain merge_request.alreadyOrCannotBeMerged() - diff --git a/app/workers/auto_merge_worker.rb b/app/workers/auto_merge_worker.rb new file mode 100644 index 0000000000..a6dd73eee5 --- /dev/null +++ b/app/workers/auto_merge_worker.rb @@ -0,0 +1,13 @@ +class AutoMergeWorker + include Sidekiq::Worker + + sidekiq_options queue: :default + + def perform(merge_request_id, current_user_id, params) + params = params.with_indifferent_access + current_user = User.find(current_user_id) + merge_request = MergeRequest.find(merge_request_id) + merge_request.should_remove_source_branch = params[:should_remove_source_branch] + merge_request.automerge!(current_user, params[:commit_message]) + end +end From 2e3749cdccfd2eb2e596980e16b88a604e97834e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 11 Jan 2015 01:32:42 +0000 Subject: [PATCH 17/18] Replace befor with before --- doc/release/monthly.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 917dc7f693..20a9392747 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -25,7 +25,7 @@ Replace the dates with actual dates based on the number of workdays before the r All steps from issue template are explained below ``` -Xth: (7 working days befor 22th) +Xth: (7 working days before 22th) - [ ] Code freeze - [ ] Update the CE changelog (#LINK) @@ -33,35 +33,35 @@ Xth: (7 working days befor 22th) - [ ] Update the CI changelog (#LINK) - [ ] Triage the omnibus-gitlab milestone -Xth: (6 working days befor 22th) +Xth: (6 working days before 22th) - [ ] Merge CE master in to EE master via merge request (#LINK) - [ ] Create CE, EE, CI RC1 versions (#LINK) - [ ] Determine QA person and notify this person -Xth: (5 working days befor 22th) +Xth: (5 working days before 22th) - [ ] Do QA and fix anything coming out of it (#LINK) - [ ] Close the omnibus-gitlab milestone -Xth: (4 working days befor 22th) +Xth: (4 working days before 22th) - [ ] Build rc1 package for GitLab.com (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#build-a-package) - [ ] Update GitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) -Xth: (3 working days befor 22th) +Xth: (3 working days before 22th) - [ ] Create regression issues (CE, CI) (#LINK) - [ ] Tweet about rc1 (#LINK) - [ ] Prepare the blog post (#LINK) -Xth: (2 working days befor 22th) +Xth: (2 working days before 22th) - [ ] Merge CE stable branch into EE stable branch - [ ] Check that everyone is mentioned on the blog post (the reviewer should have done this one working day ago) -Xth: (1 working day befor 22th) +Xth: (1 working day before 22th) - [ ] Create CE, EE, CI stable versions (#LINK) - [ ] Create Omnibus tags and build packages From 1c3c8a9c55457a3147d5da7431505ecf87f70007 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 11 Jan 2015 01:34:35 +0000 Subject: [PATCH 18/18] Make ordered lists for release doc --- doc/release/monthly.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 20a9392747..c0f66964a9 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -134,19 +134,19 @@ Tweet about the RC release: ## Prepare the blog post -- Start with a complete copy of the [release blog template](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/doc/release_blog_template.md) and fill it out. -- Make sure the blog post contains information about the GitLab CI release. -- Check the changelog of CE and EE for important changes. -- Also check the CI changelog -- Add a proposed tweet text to the blog post WIP MR description. -- Create a WIP MR for the blog post -- Ask Dmitriy to add screenshots to the WIP MR. -- Decide with team who will be the MVP user. -- Create WIP MR for adding MVP to MVP page on website -- Add a note if there are security fixes: This release fixes an important security issue and we advise everyone to upgrade as soon as possible. -- Create a merge request on [GitLab.com](https://gitlab.com/gitlab-com/www-gitlab-com/tree/master) -- Assign to one reviewer who will fix spelling issues by editing the branch (either with a git client or by using the online editor) -- Comment to the reviewer: '@person Please mention the whole team as soon as you are done (3 workdays before release at the latest)' +1. Start with a complete copy of the [release blog template](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/doc/release_blog_template.md) and fill it out. +1. Make sure the blog post contains information about the GitLab CI release. +1. Check the changelog of CE and EE for important changes. +1. Also check the CI changelog +1. Add a proposed tweet text to the blog post WIP MR description. +1. Create a WIP MR for the blog post +1. Ask Dmitriy to add screenshots to the WIP MR. +1. Decide with team who will be the MVP user. +1. Create WIP MR for adding MVP to MVP page on website +1. Add a note if there are security fixes: This release fixes an important security issue and we advise everyone to upgrade as soon as possible. +1. Create a merge request on [GitLab.com](https://gitlab.com/gitlab-com/www-gitlab-com/tree/master) +1. Assign to one reviewer who will fix spelling issues by editing the branch (either with a git client or by using the online editor) +1. Comment to the reviewer: '@person Please mention the whole team as soon as you are done (3 workdays before release at the latest)' ## Create CE, EE, CI stable versions @@ -165,9 +165,9 @@ bundle exec rake release["x.x.0"] Also perform these steps for GitLab CI: -- bump version in the stable branch -- create annotated tag -- push the stable branch and the annotated tag to the public repositories +1. bump version in the stable branch +1. create annotated tag +1. push the stable branch and the annotated tag to the public repositories Update [installation.md](/doc/install/installation.md) to the newest version in master. @@ -180,16 +180,16 @@ This can happen before tagging because Omnibus uses tags in its own repo and SHA ## Release CE, EE and CI -### 1. Publish packages for new release +__1. Publish packages for new release__ Update `downloads/index.html` and `downloads/archive/index.html` in `www-gitlab-com` repository. -### 2. Publish blog for new release +__2. Publish blog for new release__ Doublecheck the everyone has been mentioned in the blog post. Merge the [blog merge request](#1-prepare-the-blog-post) in `www-gitlab-com` repository. -### 3. Tweet to blog +__3. Tweet to blog__ Send out a tweet to share the good news with the world. List the most important features and link to the blog post.