From 6daa97f47212d89bfa0dcbb7f549ecb68d1b3783 Mon Sep 17 00:00:00 2001 From: Nilton Moura Date: Thu, 26 Dec 2013 17:13:25 -0200 Subject: Changed sudo by su -c The sudo command needs a tty to run. If you put this file on a CentOS 6, for example, it will not run in the host startup process. Instead, the 'su -c' runs the command apart if it has or not a tty. I tested this change in a fresh install of gitlab on a CentOS 6.5 with successful. --- lib/support/init.d/gitlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index f1b94087b6a..42bd4785d56 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -41,7 +41,7 @@ test -f /etc/default/gitlab && . /etc/default/gitlab # Switch to the app_user if it is not he/she who is running the script. if [ "$USER" != "$app_user" ]; then - sudo -u "$app_user" -H -i $0 "$@"; exit; + eval su - "$app_user" -c $(echo \")$0 "$@"$(echo \"); exit; fi # Switch to the gitlab path, exit on failure. -- cgit v1.2.1 From ec225ae1cbbdd413749dc43545ada4662cb1aa3f Mon Sep 17 00:00:00 2001 From: Andrew Kumanyaev Date: Fri, 21 Feb 2014 20:25:29 +0300 Subject: Update merge_request_observer_spec.rb --- spec/observers/merge_request_observer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb index 6ad7c4d81da..18df8b78513 100644 --- a/spec/observers/merge_request_observer_spec.rb +++ b/spec/observers/merge_request_observer_spec.rb @@ -120,7 +120,7 @@ describe MergeRequestObserver do end before do - @merge_request = create(:merge_request, source_project: project, source_project: project) + @merge_request = create(:merge_request, source_project: project, target_project: project) @event = Event.last end -- cgit v1.2.1 From 62b227b2f359c168447d24d1c099fa174329fcc9 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 24 Feb 2014 16:37:36 +0900 Subject: Fix another instance of "created at" Replace it with "created on". Change-Id: Ibd26bf82d2e64f142a4f3be6da7701e5b035602f --- app/views/projects/deploy_keys/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/deploy_keys/show.html.haml b/app/views/projects/deploy_keys/show.html.haml index 67615e1781f..c66e6bc69c3 100644 --- a/app/views/projects/deploy_keys/show.html.haml +++ b/app/views/projects/deploy_keys/show.html.haml @@ -2,7 +2,7 @@ Deploy key: = @key.title %small - created at + created on = @key.created_at.stamp("Aug 21, 2011") .back-link = link_to project_deploy_keys_path(@project) do -- cgit v1.2.1 From 5818cf063bda5f6a96ccefe086b64a3699dd2c67 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 24 Feb 2014 15:31:58 +0100 Subject: Don't send an email for "mentioned in" notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, an email is sent every time a mentionable is referenced by an issue, a commit or a merge request: if I comment "This MR is related to #5", watchers get one email for the comment, and another one stating "Issue #5 was mentioned by issue #13". This is annoying — but the biggest issue is when pushing an existing branch. Every issue referenced by commit messages in this branch will get a new mention (which is fine), and dozens of emails will be sent for all these new mentions (which is not). This commit fixes the spam by avoiding to send an email when a new mention is created. In most cases the email notification for the mentioner is enough. --- app/services/notification_service.rb | 1 + spec/services/notification_service_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 9d7bb9639ac..ee867a1da0c 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -111,6 +111,7 @@ class NotificationService # ignore gitlab service messages return true if note.note =~ /\A_Status changed to closed_/ + return true if note.note =~ /\A_mentioned in / && note.system == true opts = { noteable_type: note.noteable_type, project_id: note.project_id } diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index e378be04255..0869ebc9e0f 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -32,6 +32,7 @@ describe NotificationService do describe 'Notes' do context 'issue note' do let(:issue) { create(:issue, assignee: create(:user)) } + let(:mentioned_issue) { create(:issue, assignee: issue.assignee) } let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@mention referenced') } before do @@ -50,6 +51,13 @@ describe NotificationService do notification.new_note(note) end + it 'filters out "mentioned in" notes' do + mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author, issue.project) + + Notify.should_not_receive(:note_issue_email) + notification.new_note(mentioned_note) + end + def should_email(user_id) Notify.should_receive(:note_issue_email).with(user_id, note.id) end -- cgit v1.2.1 From fdd8b9e32a2a394c7dcd71e64e6bca8c25eda730 Mon Sep 17 00:00:00 2001 From: Ben Tomasik Date: Fri, 28 Feb 2014 00:10:17 -0600 Subject: Update user_management.md Believe the intention was to say 'groups' instead of 'projects' here. --- doc/raketasks/user_management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/raketasks/user_management.md b/doc/raketasks/user_management.md index 38474104852..e8232082916 100644 --- a/doc/raketasks/user_management.md +++ b/doc/raketasks/user_management.md @@ -15,7 +15,7 @@ Notes: bundle exec rake gitlab:import:all_users_to_all_projects ``` -### Add user as a developer to all projects +### Add user as a developer to all groups ``` bundle exec rake gitlab:import:user_to_groups[username@domain.tld] -- cgit v1.2.1 From 39bb54feb3685d74f57109553e032b041644dc43 Mon Sep 17 00:00:00 2001 From: lol768 Date: Sun, 2 Mar 2014 18:45:38 +0000 Subject: Fix registration error info typo --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 855fe58ffe8..0ed3ab4521e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -249,7 +249,7 @@ class User < ActiveRecord::Base def namespace_uniq namespace_name = self.username if Namespace.find_by(path: namespace_name) - self.errors.add :username, "already exist" + self.errors.add :username, "already exists" end end -- cgit v1.2.1 From 4239e457ac1a5293c260b0102e1ae9538544d839 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Tue, 4 Mar 2014 16:08:48 -0700 Subject: Add .adoc file extension for AsciiDoc Add .adoc file extension for AsciiDoc as it's a very popular extension to use and the one recommended by the Asciidoctor project. --- app/helpers/tree_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 2dbc1cffb16..50501dffefb 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -40,7 +40,7 @@ module TreeHelper # Returns boolean def markup?(filename) filename.downcase.end_with?(*%w(.textile .rdoc .org .creole - .mediawiki .rst .asciidoc .pod)) + .mediawiki .rst .adoc .asciidoc .pod)) end def gitlab_markdown?(filename) -- cgit v1.2.1 From 498a4e6b0c8b7cc9266f71dd3337669a9442934d Mon Sep 17 00:00:00 2001 From: esmail Date: Fri, 7 Mar 2014 19:57:05 -0500 Subject: Database doc changes to address #2412 and #6451. --- doc/install/database_mysql.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/install/database_mysql.md b/doc/install/database_mysql.md index 4cf9b94c1a0..bf8183729e7 100644 --- a/doc/install/database_mysql.md +++ b/doc/install/database_mysql.md @@ -6,6 +6,9 @@ We do not recommend using MySQL due to various issues. For example, case [(in)se # Install the database packages sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev + + # Ensure you have MySQL version 5.5.14 or later + mysql --version # Pick a database root password (can be anything), type it and press enter # Retype the database root password and press enter @@ -23,6 +26,10 @@ We do not recommend using MySQL due to various issues. For example, case [(in)se # change $password in the command below to a real password you pick mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; + # Ensure you can use the InnoDB engine which is necessary to support long indexes. + # If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`) for the setting "innodb = off" + mysql> SET storage_engine=INNODB; + # Create the GitLab production database mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; -- cgit v1.2.1 From 058aae5940762c18b3f099a6c3cb734041641390 Mon Sep 17 00:00:00 2001 From: Kyle Fazzari Date: Tue, 25 Feb 2014 19:10:35 -0500 Subject: Fixed Unicorn-Sidekiq confusion in GitLab init script. There were a few places in the included init script where Unicorn was referred to as Sidekiq and vice-versa. This fixes #126. --- lib/support/init.d/gitlab | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index c6e570784e0..d6716cdecce 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -131,7 +131,7 @@ check_stale_pids(){ fi fi if [ "$spid" != "0" -a "$sidekiq_status" != "0" ]; then - echo "Removing stale Sidekiq web server pid. This is most likely caused by the Sidekiq crashing the last time it ran." + echo "Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran." if ! rm "$sidekiq_pid_path"; then echo "Unable to remove stale pid, exiting" exit 1 @@ -155,9 +155,9 @@ start() { if [ "$web_status" != "0" -a "$sidekiq_status" != "0" ]; then echo -n "Starting both the GitLab Unicorn and Sidekiq" elif [ "$web_status" != "0" ]; then - echo -n "Starting GitLab Sidekiq" - elif [ "$sidekiq_status" != "0" ]; then echo -n "Starting GitLab Unicorn" + elif [ "$sidekiq_status" != "0" ]; then + echo -n "Starting GitLab Sidekiq" fi # Then check if the service is running. If it is: don't start again. @@ -190,9 +190,9 @@ stop() { if [ "$web_status" = "0" -a "$sidekiq_status" = "0" ]; then echo -n "Shutting down both Unicorn and Sidekiq" elif [ "$web_status" = "0" ]; then - echo -n "Shutting down Sidekiq" - elif [ "$sidekiq_status" = "0" ]; then echo -n "Shutting down Unicorn" + elif [ "$sidekiq_status" = "0" ]; then + echo -n "Shutting down Sidekiq" fi # If the Unicorn web server is running, tell it to stop; -- cgit v1.2.1 From 901976d9729fe5fb91929c463b0ad3a68e457c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ho=CC=88ltje?= Date: Fri, 14 Mar 2014 14:53:43 -0400 Subject: Switched line endings to LF for system_hooks.md It was checked in with Windows style line endings. --- doc/api/system_hooks.md | 140 ++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/doc/api/system_hooks.md b/doc/api/system_hooks.md index 355ce31c126..2e87ada1d70 100644 --- a/doc/api/system_hooks.md +++ b/doc/api/system_hooks.md @@ -1,70 +1,70 @@ -All methods require admin authorization. - -The url endpoint of the system hooks can be configured in [the admin area under hooks](/admin/hooks). - -## List system hooks - -Get list of system hooks - -``` -GET /hooks -``` - -Parameters: - -+ **none** - -```json -[ - { - "id":3, - "url":"http://example.com/hook", - "created_at":"2013-10-02T10:15:31Z" - } -] -``` - -## Add new system hook hook - -``` -POST /hooks -``` - -Parameters: - -+ `url` (required) - The hook URL - - -## Test system hook - -``` -GET /hooks/:id -``` - -Parameters: - -+ `id` (required) - The ID of hook - -```json -{ - "event_name":"project_create", - "name":"Ruby", - "path":"ruby", - "project_id":1, - "owner_name":"Someone", - "owner_email":"example@gitlabhq.com" -} -``` - -## Delete system hook - -Deletes a system hook. This is an idempotent API function and returns `200 Ok` even if the hook -is not available. If the hook is deleted it is also returned as JSON. - -``` -DELETE /hooks/:id -``` - -Parameters: - -+ `id` (required) - The ID of hook +All methods require admin authorization. + +The url endpoint of the system hooks can be configured in [the admin area under hooks](/admin/hooks). + +## List system hooks + +Get list of system hooks + +``` +GET /hooks +``` + +Parameters: + ++ **none** + +```json +[ + { + "id":3, + "url":"http://example.com/hook", + "created_at":"2013-10-02T10:15:31Z" + } +] +``` + +## Add new system hook hook + +``` +POST /hooks +``` + +Parameters: + ++ `url` (required) - The hook URL + + +## Test system hook + +``` +GET /hooks/:id +``` + +Parameters: + ++ `id` (required) - The ID of hook + +```json +{ + "event_name":"project_create", + "name":"Ruby", + "path":"ruby", + "project_id":1, + "owner_name":"Someone", + "owner_email":"example@gitlabhq.com" +} +``` + +## Delete system hook + +Deletes a system hook. This is an idempotent API function and returns `200 Ok` even if the hook +is not available. If the hook is deleted it is also returned as JSON. + +``` +DELETE /hooks/:id +``` + +Parameters: + ++ `id` (required) - The ID of hook -- cgit v1.2.1 From a740e2d6d16271c2e3d06252e35e65b10d002834 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 18 Mar 2014 12:25:49 +0100 Subject: Do not allow password reset for ldap user. --- app/controllers/passwords_controller.rb | 18 ++++++++++++++++++ config/routes.rb | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 app/controllers/passwords_controller.rb diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb new file mode 100644 index 00000000000..988ede3007b --- /dev/null +++ b/app/controllers/passwords_controller.rb @@ -0,0 +1,18 @@ +class PasswordsController < Devise::PasswordsController + + def create + email = resource_params[:email] + resource_found = resource_class.find_by_email(email) + if resource_found && resource_found.ldap_user? + flash[:alert] = "Cannot reset password for LDAP user." + respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) and return + end + + self.resource = resource_class.send_reset_password_instructions(resource_params) + if successfully_sent?(resource) + respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) + else + respond_with(resource) + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 628d1f631bc..709b66d3e06 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -167,7 +167,7 @@ Gitlab::Application.routes.draw do resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] - devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations } + devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords} # # Project Area -- cgit v1.2.1 From 257aa851d27076453b2dcfee2cc77a75f0e05acf Mon Sep 17 00:00:00 2001 From: dosire Date: Tue, 18 Mar 2014 16:24:49 +0100 Subject: Deploy key needed documentation. --- doc/ssh/deploy_keys.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/ssh/deploy_keys.md diff --git a/doc/ssh/deploy_keys.md b/doc/ssh/deploy_keys.md new file mode 100644 index 00000000000..245d71ed9a5 --- /dev/null +++ b/doc/ssh/deploy_keys.md @@ -0,0 +1,7 @@ +Deploy keys allow read-only access one or multiple projects with a single SSH key. + +This is really useful for cloning repositories to your Continuous Integration (CI) server. By using a deploy keys you don't have to setup a dummy user account. + +If you are a project master or owner you can add a deploy key in the project settings under the section Deploy Keys. Press the 'New Deploy Key' button and upload a public ssh key. After this the machine that uses the corresponding private key has read-only access to the project. + +You can't add the same deploy key twice with the 'New Deploy Key' option. If you want to add the same key to another project please enable it in the list that says 'Deploy keys from projects available to you'. You need to be the owner of the deploy key to see it in this list. -- cgit v1.2.1 From d09f5796bff136c463edf45f621fab6cfeb660b6 Mon Sep 17 00:00:00 2001 From: dosire Date: Tue, 18 Mar 2014 16:25:54 +0100 Subject: Split up the lines for Jacob. --- doc/ssh/deploy_keys.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/ssh/deploy_keys.md b/doc/ssh/deploy_keys.md index 245d71ed9a5..56fe98bb101 100644 --- a/doc/ssh/deploy_keys.md +++ b/doc/ssh/deploy_keys.md @@ -1,7 +1,12 @@ Deploy keys allow read-only access one or multiple projects with a single SSH key. -This is really useful for cloning repositories to your Continuous Integration (CI) server. By using a deploy keys you don't have to setup a dummy user account. +This is really useful for cloning repositories to your Continuous Integration (CI) server. +By using a deploy keys you don't have to setup a dummy user account. -If you are a project master or owner you can add a deploy key in the project settings under the section Deploy Keys. Press the 'New Deploy Key' button and upload a public ssh key. After this the machine that uses the corresponding private key has read-only access to the project. +If you are a project master or owner you can add a deploy key in the project settings under the section Deploy Keys. +Press the 'New Deploy Key' button and upload a public ssh key. +After this the machine that uses the corresponding private key has read-only access to the project. -You can't add the same deploy key twice with the 'New Deploy Key' option. If you want to add the same key to another project please enable it in the list that says 'Deploy keys from projects available to you'. You need to be the owner of the deploy key to see it in this list. +You can't add the same deploy key twice with the 'New Deploy Key' option. +If you want to add the same key to another project please enable it in the list that says 'Deploy keys from projects available to you'. +You need to be the owner of the deploy key to see it in this list. -- cgit v1.2.1 From e3fc01b3eaa13a51aef380dc21f1e7d259706227 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Tue, 18 Mar 2014 18:27:03 +0100 Subject: Added Slack service integration. --- CHANGELOG | 1 + Gemfile | 3 + Gemfile.lock | 2 + app/models/project.rb | 3 +- app/models/project_services/slack_message.rb | 95 ++++++++++++++++++++++++++++ app/models/project_services/slack_service.rb | 67 ++++++++++++++++++++ features/project/service.feature | 6 ++ features/steps/project/services.rb | 18 ++++++ spec/models/project_spec.rb | 1 + spec/models/slack_message_spec.rb | 56 ++++++++++++++++ spec/models/slack_service_spec.rb | 69 ++++++++++++++++++++ 11 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 app/models/project_services/slack_message.rb create mode 100644 app/models/project_services/slack_service.rb create mode 100644 spec/models/slack_message_spec.rb create mode 100644 spec/models/slack_service_spec.rb diff --git a/CHANGELOG b/CHANGELOG index 031536816a5..7d61fef39a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ v 6.7.0 - Faster authorized_keys rebuilding in `rake gitlab:shell:setup` (requires gitlab-shell 1.8.5) - Create and Update MR calls now support the description parameter (Greg Messner) - Markdown relative links in the wiki link to wiki pages, markdown relative links in repositories link to files in the repository + - Added Slack service integration (Federico Ravasio) v 6.6.5 - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) diff --git a/Gemfile b/Gemfile index e3acf4a153d..6a587d1d279 100644 --- a/Gemfile +++ b/Gemfile @@ -132,6 +132,9 @@ gem "gitlab-flowdock-git-hook", "~> 0.4.2" # Gemnasium integration gem "gemnasium-gitlab-service", "~> 0.2" +# Slack integration +gem "slack-notifier", "~> 0.2.0" + # d3 gem "d3_rails", "~> 3.1.4" diff --git a/Gemfile.lock b/Gemfile.lock index 52d6ac31463..de1ef59712e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -468,6 +468,7 @@ GEM rack-protection (~> 1.4) tilt (~> 1.3, >= 1.3.4) six (0.2.0) + slack-notifier (0.2.0) slim (2.0.2) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) @@ -652,6 +653,7 @@ DEPENDENCIES simplecov sinatra six + slack-notifier (~> 0.2.0) slim spinach-rails spork (~> 1.0rc) diff --git a/app/models/project.rb b/app/models/project.rb index 7d7edc45739..769ab217625 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -56,6 +56,7 @@ class Project < ActiveRecord::Base has_one :flowdock_service, dependent: :destroy has_one :assembla_service, dependent: :destroy has_one :gemnasium_service, dependent: :destroy + has_one :slack_service, dependent: :destroy has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id" has_one :forked_from_project, through: :forked_project_link # Merge Requests for target project should be removed with it @@ -304,7 +305,7 @@ class Project < ActiveRecord::Base end def available_services_names - %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium) + %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack) end def gitlab_ci? diff --git a/app/models/project_services/slack_message.rb b/app/models/project_services/slack_message.rb new file mode 100644 index 00000000000..b2b8d6fed7a --- /dev/null +++ b/app/models/project_services/slack_message.rb @@ -0,0 +1,95 @@ +require 'slack-notifier' + +class SlackMessage + def initialize(params) + @after = params.fetch(:after) + @before = params.fetch(:before) + @commits = params.fetch(:commits, []) + @project_name = params.fetch(:project_name) + @project_url = params.fetch(:project_url) + @ref = params.fetch(:ref).gsub('refs/heads/', '') + @username = params.fetch(:user_name) + end + + def compose + format(message) + end + + private + + attr_reader :after + attr_reader :before + attr_reader :commits + attr_reader :project_name + attr_reader :project_url + attr_reader :ref + attr_reader :username + + def message + if new_branch? + new_branch_message + elsif removed_branch? + removed_branch_message + else + push_message << commit_messages + end + end + + def format(string) + Slack::Notifier::LinkFormatter.format(string) + end + + def new_branch_message + "#{username} pushed new branch #{branch_link} to #{project_link}" + end + + def removed_branch_message + "#{username} removed branch #{ref} from #{project_link}" + end + + def push_message + "#{username} pushed to branch #{branch_link} of #{project_link} (#{compare_link})" + end + + def commit_messages + commits.each_with_object('') do |commit, str| + str << compose_commit_message(commit) + end + end + + def compose_commit_message(commit) + id = commit.fetch(:id)[0..5] + message = commit.fetch(:message) + url = commit.fetch(:url) + + "\n - #{message} ([#{id}](#{url}))" + end + + def new_branch? + before =~ /000000/ + end + + def removed_branch? + after =~ /000000/ + end + + def branch_url + "#{project_url}/commits/#{ref}" + end + + def compare_url + "#{project_url}/compare/#{before}...#{after}" + end + + def branch_link + "[#{ref}](#{branch_url})" + end + + def project_link + "[#{project_name}](#{project_url})" + end + + def compare_link + "[Compare changes](#{compare_url})" + end +end diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb new file mode 100644 index 00000000000..27648acf6d0 --- /dev/null +++ b/app/models/project_services/slack_service.rb @@ -0,0 +1,67 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# api_key :string(255) +# + +class SlackService < Service + attr_accessible :room + attr_accessible :subdomain + + validates :room, presence: true, if: :activated? + validates :subdomain, presence: true, if: :activated? + validates :token, presence: true, if: :activated? + + def title + 'Slack' + end + + def description + 'A team communication tool for the 21st century' + end + + def to_param + 'slack' + end + + def fields + [ + { type: 'text', name: 'subdomain', placeholder: '' }, + { type: 'text', name: 'token', placeholder: '' }, + { type: 'text', name: 'room', placeholder: '' }, + ] + end + + def execute(push_data) + message = SlackMessage.new(push_data.merge( + project_url: project_url, + project_name: project_name + )) + + notifier = Slack::Notifier.new(subdomain, token) + notifier.channel = room + notifier.ping(message.compose) + end + + private + + def project_name + project.name_with_namespace.gsub(/\s/, '') + end + + def project_url + project.web_url + end +end diff --git a/features/project/service.feature b/features/project/service.feature index 46b983e8f9a..a5af065c9e7 100644 --- a/features/project/service.feature +++ b/features/project/service.feature @@ -37,6 +37,12 @@ Feature: Project Services And I fill Assembla settings Then I should see Assembla service settings saved + Scenario: Activate Slack service + When I visit project "Shop" services page + And I click Slack service link + And I fill Slack settings + Then I should see Slack service settings saved + Scenario: Activate email on push service When I visit project "Shop" services page And I click email on push service link diff --git a/features/steps/project/services.rb b/features/steps/project/services.rb index 54b3f18e084..0594a08a5e7 100644 --- a/features/steps/project/services.rb +++ b/features/steps/project/services.rb @@ -100,4 +100,22 @@ class ProjectServices < Spinach::FeatureSteps step 'I should see email on push service settings saved' do find_field('Recipients').value.should == 'qa@company.name' end + + step 'I click Slack service link' do + click_link 'Slack' + end + + step 'I fill Slack settings' do + check 'Active' + fill_in 'Subdomain', with: 'gitlab' + fill_in 'Room', with: '#gitlab' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see Slack service settings saved' do + find_field('Subdomain').value.should == 'gitlab' + find_field('Room').value.should == '#gitlab' + find_field('Token').value.should == 'verySecret' + end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6bae5951b7b..839350bafbf 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -47,6 +47,7 @@ describe Project do it { should have_many(:hooks).dependent(:destroy) } it { should have_many(:protected_branches).dependent(:destroy) } it { should have_one(:forked_project_link).dependent(:destroy) } + it { should have_one(:slack_service).dependent(:destroy) } end describe "Mass assignment" do diff --git a/spec/models/slack_message_spec.rb b/spec/models/slack_message_spec.rb new file mode 100644 index 00000000000..b39cd4edf82 --- /dev/null +++ b/spec/models/slack_message_spec.rb @@ -0,0 +1,56 @@ +require_relative '../../app/models/project_services/slack_message' + +describe SlackMessage do + subject { SlackMessage.new(args) } + + let(:args) { + { + after: 'after', + before: 'before', + project_name: 'project_name', + ref: 'refs/heads/master', + user_name: 'user_name', + project_url: 'url' + } + } + + context 'push' do + before do + args[:commits] = [ + { message: 'message1', url: 'url1', id: 'abcdefghi' }, + { message: 'message2', url: 'url2', id: '123456789' }, + ] + end + + it 'returns a message regarding pushes' do + subject.compose.should == + 'user_name pushed to branch of ' << + ' ()' << + "\n - message1 ()" << + "\n - message2 ()" + end + end + + context 'new branch' do + before do + args[:before] = '000000' + end + + it 'returns a message regarding a new branch' do + subject.compose.should == + 'user_name pushed new branch to ' << + '' + end + end + + context 'removed branch' do + before do + args[:after] = '000000' + end + + it 'returns a message regarding a removed branch' do + subject.compose.should == + 'user_name removed branch master from ' + end + end +end diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb new file mode 100644 index 00000000000..387455cb25e --- /dev/null +++ b/spec/models/slack_service_spec.rb @@ -0,0 +1,69 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# api_key :string(255) +# + +require 'spec_helper' + +describe SlackService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Validations" do + context "active" do + before do + subject.active = true + end + + it { should validate_presence_of :room } + it { should validate_presence_of :subdomain } + it { should validate_presence_of :token } + end + end + + describe "Execute" do + let(:slack) { SlackService.new } + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:sample_data) { GitPushService.new.sample_data(project, user) } + let(:subdomain) { 'gitlab' } + let(:token) { 'verySecret' } + let(:api_url) { + "https://#{subdomain}.slack.com/services/hooks/incoming-webhook?token=#{token}" + } + + before do + slack.stub( + project: project, + project_id: project.id, + room: '#gitlab', + service_hook: true, + subdomain: subdomain, + token: token + ) + + WebMock.stub_request(:post, api_url) + end + + it "should call Slack API" do + slack.execute(sample_data) + + WebMock.should have_requested(:post, api_url).once + end + end +end -- cgit v1.2.1 From b6778cb2ea0888b6b0e20584366518e2a128d1a5 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 18 Mar 2014 22:21:25 -0400 Subject: Fix travis setup --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7c65286cfe..6bff3752b2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,10 @@ rvm: services: - redis-server before_script: - - "bundle exec rake db:setup" - - "bundle exec rake db:seed_fu" - "cp config/database.yml.$DB config/database.yml" - "cp config/gitlab.yml.example config/gitlab.yml" + - "bundle exec rake db:setup" + - "bundle exec rake db:seed_fu" script: "bundle exec rake $TASK --trace" notifications: email: false -- cgit v1.2.1 From 53d3294d1de6a3ded84532c1874ca48910fd69b0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 18 Mar 2014 21:32:40 -0400 Subject: Speed up features/notes_on_merge_requests_spec This spec featured the slowest tests in the entire suite. After some debugging, the cause was found to be the large commit diff generated by comparing the stable and master branches. To fix this, the seed repository was modified to create a simple branch off of master that consists of three simple commits and minor changes. The spec was then updated to compare master to this branch instead of stable. The result is a spec group that runs in under 30 seconds, down from about 90. --- spec/factories.rb | 6 +++- spec/features/notes_on_merge_requests_spec.rb | 49 +++++++++++--------------- spec/seed_project.tar.gz | Bin 9789938 -> 9769010 bytes 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 7fc2b7c5e97..373c2a5acff 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -146,6 +146,11 @@ FactoryGirl.define do state :reopened end + trait :simple do + source_branch "simple_merge_request" + target_branch "master" + end + factory :closed_merge_request, traits: [:closed] factory :reopened_merge_request, traits: [:reopened] factory :merge_request_with_diffs, traits: [:with_diffs] @@ -161,7 +166,6 @@ FactoryGirl.define do factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note] factory :note_on_merge_request, traits: [:on_merge_request] factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff] - factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment] trait :on_commit do project factory: :project diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index a3d8c462bf6..25a86b11fa9 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -1,14 +1,12 @@ require 'spec_helper' describe "On a merge request", js: true do - let!(:project) { create(:project) } - let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } - let!(:note) { create(:note_on_merge_request_with_attachment, project: project) } + let!(:merge_request) { create(:merge_request, :simple) } + let!(:project) { merge_request.source_project } + let!(:note) { create(:note_on_merge_request, :with_attachment, project: project) } before do - login_as :user - project.team << [@user, :master] - + login_as :admin visit project_merge_request_path(project, merge_request) end @@ -134,22 +132,20 @@ describe "On a merge request", js: true do end end -describe "On a merge request diff", js: true, focus: true do - let!(:project) { create(:project) } - let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } +describe "On a merge request diff", js: true do + let(:merge_request) { create(:merge_request, :with_diffs, :simple) } + let(:project) { merge_request.source_project } before do - login_as :user - project.team << [@user, :master] + login_as :admin visit diffs_project_merge_request_path(project, merge_request) end - subject { page } describe "when adding a note" do before do - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click end describe "the notes holder" do @@ -160,13 +156,13 @@ describe "On a merge request diff", js: true, focus: true do describe "the note form" do it "shouldn't add a second form for same row" do - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click - should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder form", count: 1) + should have_css("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7'] + .js-temp-notes-holder form", count: 1) end it "should be removed when canceled" do - within(".diff-file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185']") do + within(".diff-file form[rel$='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7']") do find(".js-close-discussion-note-form").trigger("click") end @@ -176,12 +172,9 @@ describe "On a merge request diff", js: true, focus: true do end describe "with muliple note forms" do - let!(:project) { create(:project) } - let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } - before do - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click - find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10"]').click end it { should have_css(".js-temp-notes-holder", count: 2) } @@ -189,12 +182,12 @@ describe "On a merge request diff", js: true, focus: true do describe "previewing them separately" do before do # add two separate texts and trigger previews on both - within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder") do - fill_in "note[note]", with: "One comment on line 185" + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7'] + .js-temp-notes-holder") do + fill_in "note[note]", with: "One comment on line 7" find(".js-note-preview-button").trigger("click") end - within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do - fill_in "note[note]", with: "Another comment on line 17" + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10'] + .js-temp-notes-holder") do + fill_in "note[note]", with: "Another comment on line 10" find(".js-note-preview-button").trigger("click") end end @@ -202,14 +195,14 @@ describe "On a merge request diff", js: true, focus: true do describe "posting a note" do before do - within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do - fill_in "note[note]", with: "Another comment on line 17" + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10'] + .js-temp-notes-holder") do + fill_in "note[note]", with: "Another comment on line 10" click_button("Add Comment") end end it 'should be added as discussion' do - should have_content("Another comment on line 17") + should have_content("Another comment on line 10") should have_css(".notes_holder") should have_css(".notes_holder .note", count: 1) should have_link("Reply") diff --git a/spec/seed_project.tar.gz b/spec/seed_project.tar.gz index 92b9587e3f7..8d32a927da8 100644 Binary files a/spec/seed_project.tar.gz and b/spec/seed_project.tar.gz differ -- cgit v1.2.1 From a90574fab290233225375b1c9e9c232b0e540b52 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 19 Mar 2014 03:55:59 -0400 Subject: Speed up finders/merge_requests_finder_spec Uses the :simple merge request factory trait introduced by d166e70; cuts execution time of this spec in half. --- spec/finders/merge_requests_finder_spec.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb index 76f9e753dd2..0bd2ccafcc1 100644 --- a/spec/finders/merge_requests_finder_spec.rb +++ b/spec/finders/merge_requests_finder_spec.rb @@ -1,13 +1,15 @@ require 'spec_helper' describe MergeRequestsFinder do - let(:user) { create :user } + let(:user) { create :user } let(:user2) { create :user } + let(:project1) { create(:project) } let(:project2) { create(:project) } - let(:merge_request1) { create(:merge_request, author: user, source_project: project1, target_project: project2) } - let(:merge_request2) { create(:merge_request, author: user, source_project: project2, target_project: project1) } - let(:merge_request3) { create(:merge_request, author: user, source_project: project2, target_project: project2) } + + let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project1, target_project: project2) } + let!(:merge_request2) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) } + let!(:merge_request3) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project2) } before do project1.team << [user, :master] @@ -15,13 +17,7 @@ describe MergeRequestsFinder do project2.team << [user2, :developer] end - describe :execute do - before :each do - merge_request1 - merge_request2 - merge_request3 - end - + describe "#execute" do it 'should filter by scope' do params = { scope: 'authored', state: 'opened' } merge_requests = MergeRequestsFinder.new.execute(user, params) -- cgit v1.2.1 From 65d634706cf833fc4b0b2f263f9d8fb35219858e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 19 Mar 2014 05:14:27 -0400 Subject: Add public/private/internal traits to :project Factory --- spec/factories.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index 7fc2b7c5e97..adde72d2e1e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -32,6 +32,18 @@ FactoryGirl.define do path { name.downcase.gsub(/\s/, '_') } namespace creator + + trait :public do + visibility_level Gitlab::VisibilityLevel::PUBLIC + end + + trait :internal do + visibility_level Gitlab::VisibilityLevel::INTERNAL + end + + trait :private do + visibility_level Gitlab::VisibilityLevel::PRIVATE + end end # Generates a test repository from the repository stored under `spec/seed_project.tar.gz`. -- cgit v1.2.1 From 1897fb00b8d804cffa40da074f83575489beddb0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 19 Mar 2014 05:15:24 -0400 Subject: Make use of project factory traits --- features/steps/project/redirects.rb | 2 +- features/steps/public/projects.rb | 2 +- features/steps/shared/project.rb | 8 +++--- .../security/group/internal_group_access_spec.rb | 2 +- .../security/group/mixed_group_access_spec.rb | 4 +-- .../security/group/public_group_access_spec.rb | 2 +- .../security/project/internal_access_spec.rb | 7 +---- spec/finders/projects_finder_spec.rb | 8 +++--- spec/requests/api/projects_spec.rb | 28 +++++++++--------- spec/services/search_service_spec.rb | 33 +++++++++------------- 10 files changed, 42 insertions(+), 54 deletions(-) diff --git a/features/steps/project/redirects.rb b/features/steps/project/redirects.rb index 76ffea1bb6f..cfa4ce82be3 100644 --- a/features/steps/project/redirects.rb +++ b/features/steps/project/redirects.rb @@ -4,7 +4,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps include SharedProject step 'public project "Community"' do - create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC + create :project, :public, name: 'Community' end step 'private project "Enterprise"' do diff --git a/features/steps/public/projects.rb b/features/steps/public/projects.rb index eb1d235f435..7c7311bb91c 100644 --- a/features/steps/public/projects.rb +++ b/features/steps/public/projects.rb @@ -4,7 +4,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps include SharedProject step 'public empty project "Empty Public Project"' do - create :empty_project, name: 'Empty Public Project', visibility_level: Gitlab::VisibilityLevel::PUBLIC + create :empty_project, :public, name: 'Empty Public Project' end step 'I should see project "Empty Public Project"' do diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index f35beab8af2..f8cb753b78f 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -79,7 +79,7 @@ module SharedProject end step 'internal project "Internal"' do - create :project, name: 'Internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL + create :project, :internal, name: 'Internal' end step 'I should see project "Internal"' do @@ -91,7 +91,7 @@ module SharedProject end step 'public project "Community"' do - create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC + create :project, :public, name: 'Community' end step 'I should see project "Community"' do @@ -112,14 +112,14 @@ module SharedProject step '"John Doe" is authorized to internal project "Internal"' do user = user_exists("John Doe", username: "john_doe") project = Project.find_by(name: "Internal") - project ||= create :project, name: 'Internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL + project ||= create :project, :internal, name: 'Internal' project.team << [user, :master] end step '"John Doe" is authorized to public project "Community"' do user = user_exists("John Doe", username: "john_doe") project = Project.find_by(name: "Community") - project ||= create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC + project ||= create :project, :public, name: 'Community' project.team << [user, :master] end end diff --git a/spec/features/security/group/internal_group_access_spec.rb b/spec/features/security/group/internal_group_access_spec.rb index 0c354f02456..79a6aee41b5 100644 --- a/spec/features/security/group/internal_group_access_spec.rb +++ b/spec/features/security/group/internal_group_access_spec.rb @@ -16,7 +16,7 @@ describe "Group with internal project access" do group.add_user(reporter, Gitlab::Access::REPORTER) group.add_user(guest, Gitlab::Access::GUEST) - create(:project, group: group, visibility_level: Gitlab::VisibilityLevel::INTERNAL) + create(:project, :internal, group: group) end describe "GET /groups/:path" do diff --git a/spec/features/security/group/mixed_group_access_spec.rb b/spec/features/security/group/mixed_group_access_spec.rb index 82e816e388a..028cd32d2bb 100644 --- a/spec/features/security/group/mixed_group_access_spec.rb +++ b/spec/features/security/group/mixed_group_access_spec.rb @@ -16,8 +16,8 @@ describe "Group access" do group.add_user(reporter, Gitlab::Access::REPORTER) group.add_user(guest, Gitlab::Access::GUEST) - create(:project, path: "internal_project", group: group, visibility_level: Gitlab::VisibilityLevel::INTERNAL) - create(:project, path: "public_project", group: group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) + create(:project, :internal, path: "internal_project", group: group) + create(:project, :public, path: "public_project", group: group) end describe "GET /groups/:path" do diff --git a/spec/features/security/group/public_group_access_spec.rb b/spec/features/security/group/public_group_access_spec.rb index a9c0afbb60f..f0ed7649eb5 100644 --- a/spec/features/security/group/public_group_access_spec.rb +++ b/spec/features/security/group/public_group_access_spec.rb @@ -16,7 +16,7 @@ describe "Group with public project access" do group.add_user(reporter, Gitlab::Access::REPORTER) group.add_user(guest, Gitlab::Access::GUEST) - create(:project, group: group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) + create(:project, :public, group: group) end describe "GET /groups/:path" do diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 8bb1e259efa..152cf66dcfd 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -1,23 +1,18 @@ require 'spec_helper' describe "Internal Project Access" do - let(:project) { create(:project) } + let(:project) { create(:project, :internal) } let(:master) { create(:user) } let(:guest) { create(:user) } let(:reporter) { create(:user) } before do - # internal project - project.visibility_level = Gitlab::VisibilityLevel::INTERNAL - project.save! - # full access project.team << [master, :master] # readonly project.team << [reporter, :reporter] - end describe "Project should be internal" do diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb index cc6ee82ab75..6e3ae4d615b 100644 --- a/spec/finders/projects_finder_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -4,10 +4,10 @@ describe ProjectsFinder do let(:user) { create :user } let(:group) { create :group } - let(:project1) { create(:empty_project, group: group, visibility_level: Project::PUBLIC) } - let(:project2) { create(:empty_project, group: group, visibility_level: Project::INTERNAL) } - let(:project3) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) } - let(:project4) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) } + let(:project1) { create(:empty_project, :public, group: group) } + let(:project2) { create(:empty_project, :internal, group: group) } + let(:project3) { create(:empty_project, :private, group: group) } + let(:project4) { create(:empty_project, :private, group: group) } context 'non authenticated' do subject { ProjectsFinder.new.execute(nil, group: group) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index cb30c98b4d2..149c5bffcda 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -133,7 +133,7 @@ describe API::API do end it "should set a project as public" do - project = attributes_for(:project, { visibility_level: Gitlab::VisibilityLevel::PUBLIC }) + project = attributes_for(:project, :public) post api("/projects", user), project json_response['public'].should be_true json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC @@ -147,21 +147,21 @@ describe API::API do end it "should set a project as internal" do - project = attributes_for(:project, { visibility_level: Gitlab::VisibilityLevel::INTERNAL }) + project = attributes_for(:project, :internal) post api("/projects", user), project json_response['public'].should be_false json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL end it "should set a project as internal overriding :public" do - project = attributes_for(:project, { public: true, visibility_level: Gitlab::VisibilityLevel::INTERNAL }) + project = attributes_for(:project, :internal, { public: true }) post api("/projects", user), project json_response['public'].should be_false json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL end it "should set a project as private" do - project = attributes_for(:project, { visibility_level: Gitlab::VisibilityLevel::PRIVATE }) + project = attributes_for(:project, :private) post api("/projects", user), project json_response['public'].should be_false json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE @@ -215,7 +215,7 @@ describe API::API do end it "should set a project as public" do - project = attributes_for(:project, { visibility_level: Gitlab::VisibilityLevel::PUBLIC }) + project = attributes_for(:project, :public) post api("/projects/user/#{user.id}", admin), project json_response['public'].should be_true json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC @@ -229,21 +229,21 @@ describe API::API do end it "should set a project as internal" do - project = attributes_for(:project, { visibility_level: Gitlab::VisibilityLevel::INTERNAL }) + project = attributes_for(:project, :internal) post api("/projects/user/#{user.id}", admin), project json_response['public'].should be_false json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL end it "should set a project as internal overriding :public" do - project = attributes_for(:project, { public: true, visibility_level: Gitlab::VisibilityLevel::INTERNAL }) + project = attributes_for(:project, :internal, { public: true }) post api("/projects/user/#{user.id}", admin), project json_response['public'].should be_false json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL end it "should set a project as private" do - project = attributes_for(:project, { visibility_level: Gitlab::VisibilityLevel::PRIVATE }) + project = attributes_for(:project, :private) post api("/projects/user/#{user.id}", admin), project json_response['public'].should be_false json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE @@ -490,10 +490,10 @@ describe API::API do describe :fork_admin do let(:project_fork_target) { create(:project) } - let(:project_fork_source) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:project_fork_source) { create(:project, :public) } describe "POST /projects/:id/fork/:forked_from_id" do - let(:new_project_fork_source) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:new_project_fork_source) { create(:project, :public) } it "shouldn't available for non admin users" do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) @@ -562,10 +562,10 @@ describe API::API do let!(:post) { create(:empty_project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) } let!(:pre_post) { create(:empty_project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) } let!(:unfound) { create(:empty_project, name: 'unfound', creator_id: user.id, namespace: user.namespace) } - let!(:internal) { create(:empty_project, name: "internal #{query}", visibility_level: Gitlab::VisibilityLevel::INTERNAL) } - let!(:unfound_internal) { create(:empty_project, name: 'unfound internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL) } - let!(:public) { create(:empty_project, name: "public #{query}", visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let!(:unfound_public) { create(:empty_project, name: 'unfound public', visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let!(:internal) { create(:empty_project, :internal, name: "internal #{query}") } + let!(:unfound_internal) { create(:empty_project, :internal, name: 'unfound internal') } + let!(:public) { create(:empty_project, :public, name: "public #{query}") } + let!(:unfound_public) { create(:empty_project, :public, name: 'unfound public') } context "when unauthenticated" do it "should return authentication error" do diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 457cb3c0ca3..b467282a5d6 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -1,28 +1,26 @@ require 'spec_helper' describe 'Search::GlobalService' do - let(:found_namespace) { create(:namespace, name: 'searchable namespace', path:'another_thing') } let(:user) { create(:user, namespace: found_namespace) } - let!(:found_project) { create(:project, name: 'searchable_project', creator_id: user.id, namespace: found_namespace, visibility_level: Gitlab::VisibilityLevel::PRIVATE) } + let(:public_user) { create(:user, namespace: public_namespace) } + let(:internal_user) { create(:user, namespace: internal_namespace) } + let(:found_namespace) { create(:namespace, name: 'searchable namespace', path:'another_thing') } let(:unfound_namespace) { create(:namespace, name: 'unfound namespace', path: 'yet_something_else') } - let!(:unfound_project) { create(:project, name: 'unfound_project', creator_id: user.id, namespace: unfound_namespace, visibility_level: Gitlab::VisibilityLevel::PRIVATE) } + let(:internal_namespace) { create(:namespace, name: 'searchable internal namespace', path: 'something_internal') } + let(:public_namespace) { create(:namespace, name: 'searchable public namespace', path: 'something_public') } - let(:internal_namespace) { create(:namespace, path: 'something_internal',name: 'searchable internal namespace') } - let(:internal_user) { create(:user, namespace: internal_namespace) } - let!(:internal_project) { create(:project, name: 'searchable_internal_project', creator_id: internal_user.id, namespace: internal_namespace, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } - - let(:public_namespace) { create(:namespace, path: 'something_public',name: 'searchable public namespace') } - let(:public_user) { create(:user, namespace: public_namespace) } - let!(:public_project) { create(:project, name: 'searchable_public_project', creator_id: public_user.id, namespace: public_namespace, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let!(:found_project) { create(:project, :private, name: 'searchable_project', creator_id: user.id, namespace: found_namespace) } + let!(:unfound_project) { create(:project, :private, name: 'unfound_project', creator_id: user.id, namespace: unfound_namespace) } + let!(:internal_project) { create(:project, :internal, name: 'searchable_internal_project', creator_id: internal_user.id, namespace: internal_namespace) } + let!(:public_project) { create(:project, :public, name: 'searchable_public_project', creator_id: public_user.id, namespace: public_namespace) } describe '#execute' do context 'unauthenticated' do it 'should return public projects only' do context = Search::GlobalService.new(nil, search: "searchable") results = context.execute - results[:projects].should have(1).items - results[:projects].should include(public_project) + results[:projects].should match_array [public_project] end end @@ -30,24 +28,19 @@ describe 'Search::GlobalService' do it 'should return public, internal and private projects' do context = Search::GlobalService.new(user, search: "searchable") results = context.execute - results[:projects].should have(3).items - results[:projects].should include(public_project) - results[:projects].should include(found_project) - results[:projects].should include(internal_project) + results[:projects].should match_array [public_project, found_project, internal_project] end it 'should return only public & internal projects' do context = Search::GlobalService.new(internal_user, search: "searchable") results = context.execute - results[:projects].should have(2).items - results[:projects].should include(internal_project) - results[:projects].should include(public_project) + results[:projects].should match_array [internal_project, public_project] end it 'namespace name should be searchable' do context = Search::GlobalService.new(user, search: "searchable namespace") results = context.execute - results[:projects].should == [found_project] + results[:projects].should match_array [found_project] end end end -- cgit v1.2.1 From c1fd25ce6ed28ad19fe4928be018a189c06cc3d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 12:59:23 +0200 Subject: Replace turbolink spinner with nprogress Signed-off-by: Dmitriy Zaporozhets --- Gemfile | 1 + Gemfile.lock | 2 ++ app/assets/javascripts/application.js | 2 ++ app/assets/javascripts/main.js.coffee | 8 -------- app/assets/stylesheets/application.scss | 2 ++ app/views/layouts/_head_panel.html.haml | 4 ---- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 6a587d1d279..63f5e6d057c 100644 --- a/Gemfile +++ b/Gemfile @@ -167,6 +167,7 @@ gem 'bootstrap-sass', '~> 3.0' gem "font-awesome-rails", '~> 3.2' gem "gemoji", "~> 1.3.0" gem "gon", '~> 5.0.0' +gem 'nprogress-rails' group :development do gem "annotate", "~> 2.6.0.beta2" diff --git a/Gemfile.lock b/Gemfile.lock index de1ef59712e..46540fc7b03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -297,6 +297,7 @@ GEM net-ssh (>= 1.99.1) net-ssh (2.7.0) nokogiri (1.5.10) + nprogress-rails (0.1.2.3) oauth (0.4.7) oauth2 (0.8.1) faraday (~> 0.8) @@ -621,6 +622,7 @@ DEPENDENCIES minitest (~> 4.7.0) modernizr (= 2.6.2) mysql2 + nprogress-rails omniauth (~> 1.1.3) omniauth-github omniauth-google-oauth2 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4a393dbfe81..f69b750bb69 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -29,3 +29,5 @@ //= require_tree . //= require d3 //= require underscore +//= require nprogress +//= require nprogress-turbolinks diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 70e8972d24d..89f6a547ff8 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -41,19 +41,11 @@ window.linkify = (str) -> window.simpleFormat = (str) -> linkify(sanitize(str).replace(/\n/g, '
')) -window.startSpinner = -> - $('.turbolink-spinner').fadeIn() - -window.stopSpinner = -> - $('.turbolink-spinner').fadeOut() - window.unbindEvents = -> $(document).unbind('scroll') $(document).off('scroll') -document.addEventListener("page:fetch", startSpinner) document.addEventListener("page:fetch", unbindEvents) -document.addEventListener("page:change", stopSpinner) $ -> # Click a .one_click_select field, select the contents diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 33466714681..4b7103010bb 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -7,6 +7,8 @@ *= require select2 *= require highlightjs.min *= require_self + *= require nprogress + *= require nprogress-bootstrap */ @import "main/variables.scss"; diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index 5080a1b7ef6..d8001fd76d7 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -14,10 +14,6 @@ .navbar-collapse.collapse %ul.nav.navbar-nav - %li.hidden-sm.hidden-xs - %a - %div.hide.turbolink-spinner - %i.icon-refresh.icon-spin %li.hidden-sm.hidden-xs = render "layouts/search" %li.visible-sm.visible-xs -- cgit v1.2.1 From 7d36d71d97923aa3c73609a839c106cb03ee15fa Mon Sep 17 00:00:00 2001 From: dosire Date: Wed, 19 Mar 2014 12:46:18 +0100 Subject: Run the RC on Cloud. --- doc/release/monthly.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 28fc260b334..e440f5d5abc 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -61,11 +61,11 @@ After making the release branch new commits are cherry-picked from master. When * 17th: feature freeze (stop merging new features in master) * 18th: UI freeze (stop merging changes to the user interface) * 19th: code freeze (stop merging non-essential code improvements) -* 20th: release candidate 1 (VERSION x.x.0.rc1, tag and tweet about x.x.0.rc1) +* 20th: release candidate 1 (VERSION x.x.0.rc1, tag, tweet and upgrade Cloud) * 21st: optional release candidate 2 (x.x.0.rc2, only if rc1 had problems) * 22nd: release (VERSION x.x.0, create x-x-stable branch, tag, blog and tweet) -* 23nd: optional patch releases (x.x.1, x.x.2, etc., only if there are serious problems) -* 24-end of month: release Enterprise Edition and upgrade GitLab Cloud +* 23nd: optional patch releases (x.x.1, x.x.2, etc., only if there are serious regressions) +* 24-end of month: release Enterprise Edition and upgrade GitLab Cloud to latest patch * 1-7th: official merge window (see contributing guide) * 8-16th: bugfixes and sponsored features -- cgit v1.2.1 From 1921a934a9373884133eb3859efa250794b0ea92 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 14:42:13 +0200 Subject: Add room placeholder for Slack integration Signed-off-by: Dmitriy Zaporozhets --- app/models/project_services/slack_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 27648acf6d0..754fd87db02 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -40,7 +40,7 @@ class SlackService < Service [ { type: 'text', name: 'subdomain', placeholder: '' }, { type: 'text', name: 'token', placeholder: '' }, - { type: 'text', name: 'room', placeholder: '' }, + { type: 'text', name: 'room', placeholder: 'Ex. #general' }, ] end -- cgit v1.2.1 From 0e31cb40d3998f8bad3e0a1e35985e28ef825e19 Mon Sep 17 00:00:00 2001 From: Job van der Voort Date: Wed, 19 Mar 2014 14:01:13 +0100 Subject: require public email with oauth provider message --- app/views/devise/sessions/_oauth_providers.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/devise/sessions/_oauth_providers.html.haml b/app/views/devise/sessions/_oauth_providers.html.haml index 935bc6af505..9a112f56643 100644 --- a/app/views/devise/sessions/_oauth_providers.html.haml +++ b/app/views/devise/sessions/_oauth_providers.html.haml @@ -2,10 +2,11 @@ - if providers.present? %hr %div{:'data-no-turbolink' => 'data-no-turbolink'} - %span Sign in with:   + %span Sign in with*:   - providers.each do |provider| %span - if default_providers.include?(provider) = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) - else = link_to provider.to_s.titleize, omniauth_authorize_path(resource_name, provider), class: "btn" + %small * Make sure your email address is public -- cgit v1.2.1 From 622bbf9629d2f5f081fbad6bbd9f0e3b6f092be6 Mon Sep 17 00:00:00 2001 From: Job van der Voort Date: Wed, 19 Mar 2014 14:07:42 +0100 Subject: line break --- app/views/devise/sessions/_oauth_providers.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/devise/sessions/_oauth_providers.html.haml b/app/views/devise/sessions/_oauth_providers.html.haml index 9a112f56643..2b1cb9c694f 100644 --- a/app/views/devise/sessions/_oauth_providers.html.haml +++ b/app/views/devise/sessions/_oauth_providers.html.haml @@ -9,4 +9,5 @@ = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) - else = link_to provider.to_s.titleize, omniauth_authorize_path(resource_name, provider), class: "btn" + %br %small * Make sure your email address is public -- cgit v1.2.1 From 2e33a820722b03645c755e1b710d1226a0f72f45 Mon Sep 17 00:00:00 2001 From: dosire Date: Wed, 19 Mar 2014 17:10:22 +0100 Subject: Spinner in changelog. --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index c8bbce73f5a..5bf60b3d3fb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ v 6.7.0 - Show contribution guide link for new issue form (Jeroen van Baarsen) - Fix CI status for merge requests from fork - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) + - New page load indicator that includes a spinner that scrolls with the page - Converted all the help sections into markdown v 6.6.2 -- cgit v1.2.1 From 4f68e15d9e89f338cde64fcfa3e14c0b9bc04afd Mon Sep 17 00:00:00 2001 From: Evgeniy Sokovikov Date: Wed, 19 Mar 2014 20:08:26 +0300 Subject: typo fix --- doc/development/architecture.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/development/architecture.md b/doc/development/architecture.md index ab74af4faf9..805e115047a 100644 --- a/doc/development/architecture.md +++ b/doc/development/architecture.md @@ -18,7 +18,7 @@ New releases are generally around the same time as GitLab CE releases with excep # System Layout -When referring to ~git in the picures it means the home directory of the git user which is typically /home/git. +When referring to ~git in the pictures it means the home directory of the git user which is typically /home/git. GitLab is primarily installed within the `/home/git` user home directory as `git` user. Within the home directory is where the gitlabhq server software resides as well as the repositories (though the repository location is configurable). -- cgit v1.2.1 From 9886998f24b3d6e44aafc412b87980cb1755544c Mon Sep 17 00:00:00 2001 From: Stuart Pook Date: Wed, 19 Mar 2014 19:07:51 +0100 Subject: Add method to get the comments on a merge request Add method to get the comments for a merge request and document that you can change the status of a merge request. --- doc/api/merge_requests.md | 42 ++++++++++++++++++++++++++++++++ lib/api/merge_requests.rb | 16 ++++++++++++ spec/requests/api/merge_requests_spec.rb | 17 +++++++++++++ 3 files changed, 75 insertions(+) diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index 2ddaea5a584..3ce0fb84917 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -150,6 +150,7 @@ Parameters: + `target_branch` - The target branch + `assignee_id` - Assignee user ID + `title` - Title of MR ++ `state_event` - New state (close|reopen|merge) ```json @@ -210,3 +211,44 @@ Parameters: "note":"text1" } ``` + + +## Get the comments on a MR + +Gets all the comments associated with a merge request. + +``` +GET /projects/:id/merge_request/:merge_request_id/comments +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `merge_request_id` (required) - ID of merge request + +```json +[ + { + "note":"this is the 1st comment on the 2merge merge request", + "author":{ + "id":11, + "username":"admin", + "email":"admin@local.host", + "name":"Administrator", + "state":"active", + "created_at":"2014-03-06T08:17:35.000Z" + } + }, + { + "note":"_Status changed to closed_", + "author":{ + "id":11, + "username":"admin", + "email":"admin@local.host", + "name":"Administrator", + "state":"active", + "created_at":"2014-03-06T08:17:35.000Z" + } + } +] +``` diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index e2458198411..3a1a00d0719 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -125,6 +125,22 @@ module API end end + # Get a merge request's comments + # + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - ID of MR + # Examples: + # GET /projects/:id/merge_request/:merge_request_id/comments + # + get ":id/merge_request/:merge_request_id/comments" do + merge_request = user_project.merge_requests.find(params[:merge_request_id]) + + authorize! :read_merge_request, merge_request + + present paginate(merge_request.notes), with: Entities::MRNote + end + # Post comment to merge request # # Parameters: diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 1a9e4809e7d..138f218d46c 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -7,6 +7,7 @@ describe API::API do let(:user) { create(:user) } let!(:project) {create(:project, creator_id: user.id, namespace: user.namespace) } let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } + let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") } before { project.team << [user, :reporters] } @@ -205,4 +206,20 @@ describe API::API do response.status.should == 404 end end + + describe "GET :id/merge_request/:merge_request_id/comments" do + it "should return merge_request comments" do + get api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 1 + json_response.first['note'].should == "a comment on a MR" + json_response.first['author']['id'].should == user.id + end + + it "should return a 404 error if merge_request_id not found" do + get api("/projects/#{project.id}/merge_request/999/comments", user) + response.status.should == 404 + end + end end -- cgit v1.2.1 From 189f88de5b6a85d1bae43cc4625e5d6604bbe6a8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Mar 2014 10:03:02 +0200 Subject: rc1 Signed-off-by: Dmitriy Zaporozhets --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 998707b421c..13f32397641 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.7.0.pre +6.7.0.rc1 -- cgit v1.2.1 From 19c28822ef60da0f4eda380e6cab3be4a4cb18e5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 21:01:00 +0200 Subject: Add Gitlab::GitAccess class to resolve auth issues during pull/push Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/git_access.rb | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 lib/gitlab/git_access.rb diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb new file mode 100644 index 00000000000..5fb5505743f --- /dev/null +++ b/lib/gitlab/git_access.rb @@ -0,0 +1,74 @@ +module Gitlab + class GitAccess + DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } + PUSH_COMMANDS = %w{ git-receive-pack } + + attr_reader :params, :project, :git_cmd, :user + + def allowed?(actor, cmd, project, ref = nil, oldrev = nil, newrev = nil) + case cmd + when *DOWNLOAD_COMMANDS + if actor.is_a? User + download_allowed?(actor, project) + elsif actor.is_a? DeployKey + actor.projects.include?(project) + elsif actor.is_a? Key + download_allowed?(actor.user, project) + else + raise 'Wrong actor' + end + when *PUSH_COMMANDS + if actor.is_a? User + push_allowed?(actor, project, ref, oldrev, newrev) + elsif actor.is_a? DeployKey + # Deploy key not allowed to push + return false + elsif actor.is_a? Key + push_allowed?(actor.user, project, ref, oldrev, newrev) + else + raise 'Wrong actor' + end + else + false + end + end + + def download_allowed?(user, project) + if user_allowed?(user) + user.can?(:download_code, project) + else + false + end + end + + def push_allowed?(user, project, ref, oldrev, newrev) + if user_allowed?(user) + action = if project.protected_branch?(ref) + :push_code_to_protected_branches + else + :push_code + end + user.can?(action, project) + else + false + end + end + + private + + def user_allowed?(user) + return false if user.blocked? + + if Gitlab.config.ldap.enabled + if user.ldap_user? + # Check if LDAP user exists and match LDAP user_filter + unless Gitlab::LDAP::Access.new.allowed?(user) + return false + end + end + end + + true + end + end +end -- cgit v1.2.1 From f18a714f357405a87031250f4350343ae54d528f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 21:02:12 +0200 Subject: Use GitAccess in internal api Signed-off-by: Dmitriy Zaporozhets --- lib/api/internal.rb | 60 +++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 69aad3748b3..bcf97574673 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,16 +1,12 @@ module API # Internal access API class Internal < Grape::API - - DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } - PUSH_COMMANDS = %w{ git-receive-pack } - namespace 'internal' do - # - # Check if ssh key has access to project code + # Check if git command is allowed to project # # Params: - # key_id - SSH Key id + # key_id - ssh key id for Git over SSH + # user_id - user id for Git over HTTP # project - project path with namespace # action - git action (git-upload-pack or git-receive-pack) # ref - branch name @@ -22,43 +18,25 @@ module API # the wiki repository as well. project_path = params[:project] project_path.gsub!(/\.wiki/,'') if project_path =~ /\.wiki/ - - key = Key.find(params[:key_id]) project = Project.find_with_namespace(project_path) - git_cmd = params[:action] return false unless project - - if key.is_a? DeployKey - key.projects.include?(project) && DOWNLOAD_COMMANDS.include?(git_cmd) - else - user = key.user - - return false if user.blocked? - - if Gitlab.config.ldap.enabled - if user.ldap_user? - # Check if LDAP user exists and match LDAP user_filter - unless Gitlab::LDAP::Access.new.allowed?(user) - return false - end - end - end - - action = case git_cmd - when *DOWNLOAD_COMMANDS - then :download_code - when *PUSH_COMMANDS - then - if project.protected_branch?(params[:ref]) - :push_code_to_protected_branches - else - :push_code - end - end - - user.can?(action, project) - end + actor = if params[:key_id] + Key.find(params[:key_id]) + elsif params[:user_id] + User.find(params[:user_id]) + end + + return false unless actor + + Gitlab::GitAccess.new.allowed?( + actor, + params[:action], + project, + params[:ref], + params[:oldrev], + params[:newrev] + ) end # -- cgit v1.2.1 From 729b358ff2981d8931e27fdc33d29b9528232c32 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 21:02:39 +0200 Subject: push via http now served via /allowed API Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 47 +++++----------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 60c03ce1c04..ee99bd5f7de 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -5,7 +5,7 @@ module Grack class Auth < Rack::Auth::Basic include Helpers - attr_accessor :user, :project, :ref, :env + attr_accessor :user, :project, :env def call(env) @env = env @@ -80,24 +80,11 @@ module Grack def authorize_request(service) case service when 'git-upload-pack' - can?(user, :download_code, project) - when'git-receive-pack' - refs.each do |ref| - action = if project.protected_branch?(ref) - :push_code_to_protected_branches - else - :push_code - end - - return false unless can?(user, action, project) - end - - # Never let git-receive-pack trough unauthenticated; it's - # harmless but git < 1.8 doesn't like it - return false if user.nil? - true + # Serve only upload request. + # Authorization on push will be serverd by update hook in repository + Gitlab::GitAccess.new.download_allowed?(user, project) else - false + true end end @@ -114,29 +101,5 @@ module Grack def project @project ||= project_by_path(@request.path_info) end - - def refs - @refs ||= parse_refs - end - - def parse_refs - input = if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/ - Zlib::GzipReader.new(@request.body).read - else - @request.body.read - end - - # Need to reset seek point - @request.body.rewind - - # Parse refs - refs = input.force_encoding('ascii-8bit').scan(/refs\/heads\/([\/\w\.-]+)/n).flatten.compact - - # Cleanup grabare from refs - # if push to multiple branches - refs.map do |ref| - ref.gsub(/00.*/, "") - end - end end end -- cgit v1.2.1 From 41e981740ffc54f68ae5f8fe7b719183cd125094 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 20:56:31 +0200 Subject: Use 2 workers in development Signed-off-by: Dmitriy Zaporozhets --- Procfile | 2 +- config/unicorn_development.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 config/unicorn_development.rb diff --git a/Procfile b/Procfile index 9003369c938..18df7e78f9b 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec unicorn_rails -p $PORT -E development +web: bundle exec unicorn_rails -p $PORT -E development -c config/unicorn_development.rb worker: bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default,gitlab_shell diff --git a/config/unicorn_development.rb b/config/unicorn_development.rb new file mode 100644 index 00000000000..94a7061451d --- /dev/null +++ b/config/unicorn_development.rb @@ -0,0 +1,2 @@ +worker_processes 2 +timeout 30 -- cgit v1.2.1 From 83e83b6617694c03457ca3a36230b54560ce6833 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Mar 2014 10:53:03 +0200 Subject: Improve grack auth Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 21 +++++++++++++++++---- lib/gitlab/backend/grack_helpers.rb | 28 ---------------------------- 2 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 lib/gitlab/backend/grack_helpers.rb diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index ee99bd5f7de..b3e111354f5 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -1,9 +1,7 @@ require_relative 'shell_env' -require_relative 'grack_helpers' module Grack class Auth < Rack::Auth::Basic - include Helpers attr_accessor :user, :project, :env @@ -79,12 +77,14 @@ module Grack def authorize_request(service) case service - when 'git-upload-pack' + when *Gitlab::GitAccess::DOWNLOAD_COMMANDS # Serve only upload request. # Authorization on push will be serverd by update hook in repository Gitlab::GitAccess.new.download_allowed?(user, project) - else + when *Gitlab::GitAccess::PUSH_COMMANDS true + else + false end end @@ -101,5 +101,18 @@ module Grack def project @project ||= project_by_path(@request.path_info) end + + def project_by_path(path) + if m = /^([\w\.\/-]+)\.git/.match(path).to_a + path_with_namespace = m.last + path_with_namespace.gsub!(/\.wiki$/, '') + + Project.find_with_namespace(path_with_namespace) + end + end + + def render_not_found + [404, {"Content-Type" => "text/plain"}, ["Not Found"]] + end end end diff --git a/lib/gitlab/backend/grack_helpers.rb b/lib/gitlab/backend/grack_helpers.rb deleted file mode 100644 index cb747fe0137..00000000000 --- a/lib/gitlab/backend/grack_helpers.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Grack - module Helpers - def project_by_path(path) - if m = /^([\w\.\/-]+)\.git/.match(path).to_a - path_with_namespace = m.last - path_with_namespace.gsub!(/\.wiki$/, '') - - Project.find_with_namespace(path_with_namespace) - end - end - - def render_not_found - [404, {"Content-Type" => "text/plain"}, ["Not Found"]] - end - - def can?(object, action, subject) - abilities.allowed?(object, action, subject) - end - - def abilities - @abilities ||= begin - abilities = Six.new - abilities << Ability - abilities - end - end - end -end -- cgit v1.2.1 From 3a294daf535a733054ed4d79a64ee64904bf5218 Mon Sep 17 00:00:00 2001 From: Marc Radulescu Date: Thu, 20 Mar 2014 10:04:41 +0100 Subject: added OReilly sponsorship to CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index f82da87a806..93a31e7377f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ v 6.7.0 - Create and Update MR calls now support the description parameter (Greg Messner) - Markdown relative links in the wiki link to wiki pages, markdown relative links in repositories link to files in the repository - Added Slack service integration (Federico Ravasio) + - Better API responses for access_levels (sponsored by O'Reilly Media) v 6.6.5 - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) -- cgit v1.2.1 From e013be10d7185dcdc814c11a65537ecd903e404d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Mar 2014 13:37:35 +0200 Subject: GitLab requires gitlab-shell v1.9.0 Signed-off-by: Dmitriy Zaporozhets --- CHANGELOG | 2 ++ lib/tasks/gitlab/check.rake | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 93a31e7377f..a9a8c00666d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,8 @@ v 6.7.0 - Markdown relative links in the wiki link to wiki pages, markdown relative links in repositories link to files in the repository - Added Slack service integration (Federico Ravasio) - Better API responses for access_levels (sponsored by O'Reilly Media) + - Requires at least 2 unicorn workers + - Requires gitlab-shell v1.9+ v 6.6.5 - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index d4d5e48ce3f..067735d66b1 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -742,7 +742,7 @@ namespace :gitlab do end def check_gitlab_shell - required_version = Gitlab::VersionInfo.new(1, 8, 5) + required_version = Gitlab::VersionInfo.new(1, 9, 0) current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) print "GitLab Shell version >= #{required_version} ? ... " -- cgit v1.2.1 From 2767abd90d94b3fd0fedfad85015abbffd7e4cd9 Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Thu, 20 Mar 2014 13:23:07 +0100 Subject: Clearfix on well-lists. Pages affected: Pages affected: - admin/groups#show - admin/projets#index - admin/users#index - dashboard/issues#index (on small screens) --- app/assets/stylesheets/generic/lists.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/generic/lists.scss b/app/assets/stylesheets/generic/lists.scss index de70e47333f..8a6d7f68175 100644 --- a/app/assets/stylesheets/generic/lists.scss +++ b/app/assets/stylesheets/generic/lists.scss @@ -13,6 +13,12 @@ border-bottom: 1px solid #eee; border-bottom: 1px solid rgba(0, 0, 0, 0.05); + &:after { + content: " "; + display: table; + clear: both; + } + &.disabled { color: #888; } -- cgit v1.2.1 From 817f5ff6a3da3bcb494109bffbd9eca2fedc20b0 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Mar 2014 11:56:52 +0100 Subject: Use gitlab_emoji gem instead of gemoji. --- Gemfile | 2 +- Gemfile.lock | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 63f5e6d057c..786b0ad4db3 100644 --- a/Gemfile +++ b/Gemfile @@ -165,7 +165,7 @@ gem "modernizr", "2.6.2" gem "raphael-rails", "~> 2.1.2" gem 'bootstrap-sass', '~> 3.0' gem "font-awesome-rails", '~> 3.2' -gem "gemoji", "~> 1.3.0" +gem "gitlab_emoji", "~> 0.0.1" gem "gon", '~> 5.0.0' gem 'nprogress-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 46540fc7b03..dc2f920619d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -128,6 +128,8 @@ GEM mail (~> 2.2) email_validator (1.4.0) activemodel + emoji (1.0.1) + json enumerize (0.7.0) activesupport (>= 3.2) equalizer (0.0.8) @@ -165,7 +167,6 @@ GEM formatador (0.2.4) gemnasium-gitlab-service (0.2.1) rugged (~> 0.19) - gemoji (1.3.1) gherkin-ruby (0.3.1) racc github-markdown (0.5.5) @@ -190,6 +191,8 @@ GEM charlock_holmes (~> 0.6.6) escape_utils (~> 0.2.4) mime-types (~> 1.19) + gitlab_emoji (0.0.1) + emoji (~> 1.0.1) gitlab_git (5.7.1) activesupport (~> 4.0.0) charlock_holmes (~> 0.6.9) @@ -593,12 +596,12 @@ DEPENDENCIES font-awesome-rails (~> 3.2) foreman gemnasium-gitlab-service (~> 0.2) - gemoji (~> 1.3.0) github-markup (~> 0.7.4)! gitlab-flowdock-git-hook (~> 0.4.2) gitlab-gollum-lib (~> 1.1.0) gitlab-grack (~> 2.0.0.pre) gitlab-linguist (~> 3.0.0) + gitlab_emoji (~> 0.0.1) gitlab_git (~> 5.7.1) gitlab_meta (= 6.0) gitlab_omniauth-ldap (= 1.0.4) -- cgit v1.2.1 From 5f595be4b80ae57c92d01dc1c0026566f80e67d4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Mar 2014 13:30:27 +0100 Subject: Use new gems methods. --- app/views/layouts/_init_auto_complete.html.haml | 2 +- app/views/projects/notes/_note.html.haml | 2 +- config/initializers/gemoji.rb | 3 --- lib/gitlab/markdown.rb | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 config/initializers/gemoji.rb diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index 6a20dedf62f..fd6097dcc7b 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -1,4 +1,4 @@ :javascript GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" - GitLab.GfmAutoComplete.Emoji.assetBase = "#{Gitlab.config.gitlab.relative_url_root + '/assets/emoji'}" + GitLab.GfmAutoComplete.Emoji.assetBase = "#{Gitlab.config.gitlab.relative_url_root + Emoji.asset_path}" GitLab.GfmAutoComplete.setup(); diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index 217e36e38d0..81bf0611ec6 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -23,7 +23,7 @@ %i.icon-thumbs-up \+1 - if note.downvote? - %span.vote.downvote.label.label-error + %span.vote.downvote.label.label-danger %i.icon-thumbs-down \-1 diff --git a/config/initializers/gemoji.rb b/config/initializers/gemoji.rb deleted file mode 100644 index 6cc33aced77..00000000000 --- a/config/initializers/gemoji.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Workaround for https://github.com/github/gemoji/pull/18 -require 'gemoji' -Gitlab::Application.config.assets.paths << Emoji.images_path diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index e72f4f5d0ce..80bb00821f7 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -152,7 +152,7 @@ module Gitlab # # Returns boolean def valid_emoji?(emoji) - Emoji.names.include? emoji + Emoji.find_by_name emoji end # Private: Dispatches to a dedicated processing method based on reference -- cgit v1.2.1 From 4dc09e5c1dbed7aa40209499e4d0889936bc72a1 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Mar 2014 13:31:43 +0100 Subject: New bindings to vote on notes. --- app/models/note.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/note.rb b/app/models/note.rb index 48c03c9d587..906de4855ab 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -199,7 +199,8 @@ class Note < ActiveRecord::Base def downvote? votable? && (note.start_with?('-1') || note.start_with?(':-1:') || - note.start_with?(':thumbsdown:') + note.start_with?(':thumbsdown:') || + note.start_with?(':thumbs_down_sign:') ) end @@ -249,7 +250,8 @@ class Note < ActiveRecord::Base def upvote? votable? && (note.start_with?('+1') || note.start_with?(':+1:') || - note.start_with?(':thumbsup:') + note.start_with?(':thumbsup:') || + note.start_with?(':thumbs_up_sign:') ) end -- cgit v1.2.1 From 9afd04842f6658dcd1dc02cda17247c321ff6a67 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Mar 2014 13:46:31 +0100 Subject: Update Changelog --- CHANGELOG | 1 + Gemfile | 2 +- Gemfile.lock | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a9a8c00666d..f2124408b42 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ v 6.7.0 - Better API responses for access_levels (sponsored by O'Reilly Media) - Requires at least 2 unicorn workers - Requires gitlab-shell v1.9+ + - Replaced gemoji(due to closed licencing problem) with Phantom Open Emoji library(combined SIL Open Font License, MIT License and the CC 3.0 License) v 6.6.5 - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) diff --git a/Gemfile b/Gemfile index 786b0ad4db3..5b58ce443ae 100644 --- a/Gemfile +++ b/Gemfile @@ -165,7 +165,7 @@ gem "modernizr", "2.6.2" gem "raphael-rails", "~> 2.1.2" gem 'bootstrap-sass', '~> 3.0' gem "font-awesome-rails", '~> 3.2' -gem "gitlab_emoji", "~> 0.0.1" +gem "gitlab_emoji", "~> 0.0.1.1" gem "gon", '~> 5.0.0' gem 'nprogress-rails' diff --git a/Gemfile.lock b/Gemfile.lock index dc2f920619d..167fd960ff5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -191,7 +191,7 @@ GEM charlock_holmes (~> 0.6.6) escape_utils (~> 0.2.4) mime-types (~> 1.19) - gitlab_emoji (0.0.1) + gitlab_emoji (0.0.1.1) emoji (~> 1.0.1) gitlab_git (5.7.1) activesupport (~> 4.0.0) @@ -601,7 +601,7 @@ DEPENDENCIES gitlab-gollum-lib (~> 1.1.0) gitlab-grack (~> 2.0.0.pre) gitlab-linguist (~> 3.0.0) - gitlab_emoji (~> 0.0.1) + gitlab_emoji (~> 0.0.1.1) gitlab_git (~> 5.7.1) gitlab_meta (= 6.0) gitlab_omniauth-ldap (= 1.0.4) -- cgit v1.2.1 From dd7efd1768f7f61dfa8c47200fc95bac831c9ff5 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 13 Mar 2014 15:20:31 +0100 Subject: Add load_ok check to script/background_jobs --- script/background_jobs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/script/background_jobs b/script/background_jobs index 06125c11ffe..a41ae3956c2 100755 --- a/script/background_jobs +++ b/script/background_jobs @@ -6,6 +6,11 @@ sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" sidekiq_logfile="$app_root/log/sidekiq.log" gitlab_user=$(ls -l config.ru | awk '{print $3}') +function warn +{ + echo "$@" 1>&2 +} + function stop { bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 @@ -35,6 +40,22 @@ function start_sidekiq bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1 } +function load_ok +{ + sidekiq_pid=$(cat $sidekiq_pidfile) + if [[ -z $sidekiq_pid ]] ; then + warn "Could not find a PID in $sidekiq_pidfile" + exit 0 + fi + + if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then + warn "Too many busy Sidekiq workers" + exit 1 + fi + + exit 0 +} + case "$1" in stop) stop @@ -51,6 +72,9 @@ case "$1" in killall) killall ;; + load_ok) + load_ok + ;; *) echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall}" esac -- cgit v1.2.1 From cc83c696c0f453c48811263b08505dba77b34315 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 20 Mar 2014 14:47:06 +0100 Subject: Add load_ok to background_jobs usage message --- script/background_jobs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/background_jobs b/script/background_jobs index a41ae3956c2..52732f5532b 100755 --- a/script/background_jobs +++ b/script/background_jobs @@ -76,5 +76,5 @@ case "$1" in load_ok ;; *) - echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall}" + echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall|load_ok}" esac -- cgit v1.2.1 From 0bc88794684fe89af61360c6b88056dec18f1ecc Mon Sep 17 00:00:00 2001 From: dosire Date: Thu, 20 Mar 2014 15:32:30 +0100 Subject: Tell how to do it, solves https://twitter.com/unwiredbrain/status/446588631424462848 --- doc/integration/external-issue-tracker.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/integration/external-issue-tracker.md b/doc/integration/external-issue-tracker.md index 02eadfd410a..3212ebd64b5 100644 --- a/doc/integration/external-issue-tracker.md +++ b/doc/integration/external-issue-tracker.md @@ -5,3 +5,5 @@ GitLab has a great issue tracker but you can also use an external issue tracker - textual references to PROJECT-1234 in comments, commit messages get turned into HTML links to the corresponding JIRA issue. ![jira screenshot](jira-intergration-points.png) + +You can configure the integration in the gitlab.yml configuration file. -- cgit v1.2.1 From fefab474569f231676a4fd1579a70723d729f206 Mon Sep 17 00:00:00 2001 From: Dmitry Medvinsky Date: Wed, 19 Mar 2014 17:32:38 +0400 Subject: Fix `/:username.keys` response content type Currently this method responds with `text/html`. It is kind of unusable if you open it in a browser. The browser thinks it is HTML and renders it as HTML, meaning new lines are dropped. So it's very hard to distinguish where the key starts and where it ends. This commit changes the content type header to `text/plain`. --- CHANGELOG | 1 + app/controllers/profiles/keys_controller.rb | 2 +- spec/controllers/profile_keys_controller_spec.rb | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a9a8c00666d..1d41a3505da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ v 6.7.0 - Better API responses for access_levels (sponsored by O'Reilly Media) - Requires at least 2 unicorn workers - Requires gitlab-shell v1.9+ + - Fix `/:username.keys` response content type (Dmitry Medvinsky) v 6.6.5 - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index b4f14e649e2..6713cd7c8c7 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -41,7 +41,7 @@ class Profiles::KeysController < ApplicationController begin user = User.find_by_username(params[:username]) if user.present? - render text: user.all_ssh_keys.join("\n") + render text: user.all_ssh_keys.join("\n"), content_type: "text/plain" else render_404 and return end diff --git a/spec/controllers/profile_keys_controller_spec.rb b/spec/controllers/profile_keys_controller_spec.rb index 121012d5d49..593d3e9eb56 100644 --- a/spec/controllers/profile_keys_controller_spec.rb +++ b/spec/controllers/profile_keys_controller_spec.rb @@ -24,6 +24,11 @@ describe Profiles::KeysController do expect(response.body).to eq("") end + + it "should respond with text/plain content type" do + get :get_keys, username: user.username + expect(response.content_type).to eq("text/plain") + end end describe "user with keys" do @@ -44,6 +49,11 @@ describe Profiles::KeysController do expect(response.body).not_to eq("") expect(response.body).to eq(user.all_ssh_keys.join("\n")) end + + it "should respond with text/plain content type" do + get :get_keys, username: user.username + expect(response.content_type).to eq("text/plain") + end end end end -- cgit v1.2.1 From 44aa6b90ddde3a7babc6ed9f50d73040d6184789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bner=20Silva=20de=20Oliveira?= Date: Fri, 21 Mar 2014 06:18:19 -0300 Subject: added api method to return labels of a given project --- lib/api/entities.rb | 4 ++++ lib/api/projects.rb | 9 +++++++++ spec/requests/api/labels_spec.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 spec/requests/api/labels_spec.rb diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8b4519af2d1..9fa8506926c 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -187,5 +187,9 @@ module API end end end + + class Label < Grape::Entity + expose :name + end end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 4d48d2194f8..40b5ce86c93 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -215,6 +215,15 @@ module API @users = paginate @users present @users, with: Entities::User end + + # Get a labels list + # + # Example Request: + # GET /users + get ':id/labels' do + @labels = user_project.issues_labels + present @labels, with: Entities::Label + end end end end diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb new file mode 100644 index 00000000000..ba5efb6c603 --- /dev/null +++ b/spec/requests/api/labels_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe API::API do + include ApiHelpers + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + let(:user) { create(:user) } + let!(:project) { create(:project, namespace: user.namespace ) } + let!(:issue) { create(:issue, author: user, assignee: user, project: project, :label_list => "label1, label2") } + before { project.team << [user, :reporter] } + + + describe "GET /projects/:id/labels" do + it "should return project labels" do + get api("/projects/#{project.id}/labels", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == 'label1' + json_response.last['name'].should == 'label2' + end + end + + +end + -- cgit v1.2.1 From 6d9dccbec802d8d5956f31eda4af4f03fafd66b8 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Fri, 21 Mar 2014 12:26:34 +0100 Subject: Checkout gitlab-shell v 1.9.0 --- doc/update/6.6-to-6.7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/update/6.6-to-6.7.md b/doc/update/6.6-to-6.7.md index e4a0cafa911..f5b90c8ac5e 100644 --- a/doc/update/6.6-to-6.7.md +++ b/doc/update/6.6-to-6.7.md @@ -37,7 +37,7 @@ sudo -u git -H git checkout 6-7-stable-ee ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.8.0 +sudo -u git -H git checkout v1.9.0 ``` ### 4. Install libs, migrations, etc. -- cgit v1.2.1 From 895c913247e0444374316ea46dec9304ce1efdf4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Fri, 21 Mar 2014 12:42:59 +0100 Subject: Use the latest tag, 1.9.1 for gitlab-shell. --- doc/install/installation.md | 2 +- doc/update/6.6-to-6.7.md | 2 +- lib/tasks/gitlab/check.rake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index a0eac76ab5b..a37eb733147 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -128,7 +128,7 @@ GitLab Shell is an ssh access and repository management software developed speci cd /home/git # Clone gitlab shell - sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0 + sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.1 cd gitlab-shell diff --git a/doc/update/6.6-to-6.7.md b/doc/update/6.6-to-6.7.md index f5b90c8ac5e..8a16e5d67be 100644 --- a/doc/update/6.6-to-6.7.md +++ b/doc/update/6.6-to-6.7.md @@ -37,7 +37,7 @@ sudo -u git -H git checkout 6-7-stable-ee ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.9.0 +sudo -u git -H git checkout v1.9.1 ``` ### 4. Install libs, migrations, etc. diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 067735d66b1..071760c0c36 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -742,7 +742,7 @@ namespace :gitlab do end def check_gitlab_shell - required_version = Gitlab::VersionInfo.new(1, 9, 0) + required_version = Gitlab::VersionInfo.new(1, 9, 1) current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) print "GitLab Shell version >= #{required_version} ? ... " -- cgit v1.2.1 From 7dd18a3ec832cb5e49932dff33f3a4ced30fe1e8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 14:52:30 +0200 Subject: Fix http clone for public project Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 60 ++++++++++++++++++++++++---------------- lib/gitlab/git_access.rb | 4 +-- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index b3e111354f5..de18d904916 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -22,14 +22,16 @@ module Grack @env['SCRIPT_NAME'] = "" - auth! + if project + auth! + else + render_not_found + end end private def auth! - return render_not_found unless project - if @auth.provided? return bad_request unless @auth.basic? @@ -38,12 +40,8 @@ module Grack # Allow authentication for GitLab CI service # if valid token passed - if login == "gitlab-ci-token" && project.gitlab_ci? - token = project.gitlab_ci_service.token - - if token.present? && token == password && service_name == 'git-upload-pack' - return @app.call(env) - end + if gitlab_ci_request?(login, password) + return @app.call(env) end @user = authenticate_user(login, password) @@ -51,23 +49,26 @@ module Grack if @user Gitlab::ShellEnv.set_env(@user) @env['REMOTE_USER'] = @auth.username - else - return unauthorized end - - else - return unauthorized unless project.public? end - if authorized_git_request? + if authorized_request? @app.call(env) else unauthorized end end - def authorized_git_request? - authorize_request(service_name) + def gitlab_ci_request?(login, password) + if login == "gitlab-ci-token" && project.gitlab_ci? + token = project.gitlab_ci_service.token + + if token.present? && token == password && git_cmd == 'git-upload-pack' + true + end + end + + false end def authenticate_user(login, password) @@ -75,20 +76,31 @@ module Grack auth.find(login, password) end - def authorize_request(service) - case service + def authorized_request? + case git_cmd when *Gitlab::GitAccess::DOWNLOAD_COMMANDS - # Serve only upload request. - # Authorization on push will be serverd by update hook in repository - Gitlab::GitAccess.new.download_allowed?(user, project) + if user + Gitlab::GitAccess.new.download_allowed?(user, project) + elsif project.public? + # Allow clone/fetch for public projects + true + else + false + end when *Gitlab::GitAccess::PUSH_COMMANDS - true + if user + # Skip user authorization on upload request. + # It will be serverd by update hook in repository + true + else + false + end else false end end - def service_name + def git_cmd if @request.get? @request.params['service'] elsif @request.post? diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 5fb5505743f..1ab8f9213a3 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -34,7 +34,7 @@ module Gitlab end def download_allowed?(user, project) - if user_allowed?(user) + if user && user_allowed?(user) user.can?(:download_code, project) else false @@ -42,7 +42,7 @@ module Gitlab end def push_allowed?(user, project, ref, oldrev, newrev) - if user_allowed?(user) + if user && user_allowed?(user) action = if project.protected_branch?(ref) :push_code_to_protected_branches else -- cgit v1.2.1 From 20c3cbb18cfc414e144e5cb214d6b663ba17f828 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 21 Mar 2014 15:04:45 +0100 Subject: Update monster update guide to 6.0-to-6.7 --- doc/update/6.0-to-6.5.md | 127 ------------------------------------------ doc/update/6.0-to-6.7.md | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 127 deletions(-) delete mode 100644 doc/update/6.0-to-6.5.md create mode 100644 doc/update/6.0-to-6.7.md diff --git a/doc/update/6.0-to-6.5.md b/doc/update/6.0-to-6.5.md deleted file mode 100644 index e01cc589a83..00000000000 --- a/doc/update/6.0-to-6.5.md +++ /dev/null @@ -1,127 +0,0 @@ -# From 6.0 to 6.5 - -# In 6.1 we remove a lot of deprecated code. -# You should update to 6.0 before installing 6.1 or higher so all the necessary conversions are run. - -### Deprecations - -#### Global issue numbers - -As of 6.1 issue numbers are project specific. This means all issues are renumbered and get a new number in their url. If you use an old issue number url and the issue number does not exist yet you are redirected to the new one. This conversion does not trigger if the old number already exists for this project, this is unlikely but will happen with old issues and large projects. - -### 0. Backup - -It's useful to make a backup just in case things go south: -(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) - -```bash -cd /home/git/gitlab -sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production -``` - -### 1. Stop server - - sudo service gitlab stop - -### 2. Get latest code - -```bash -cd /home/git/gitlab -sudo -u git -H git fetch --all -sudo -u git -H git checkout 6-5-stable -# For GitLab Enterprise Edition: sudo -u git -H git checkout 6-5-stable-ee -``` - - -### 3. Install additional packages - -```bash -# Add support for lograte for better log file handling -sudo apt-get install logrotate -``` - -### 4. Update gitlab-shell - -```bash -cd /home/git/gitlab-shell -sudo -u git -H git fetch -sudo -u git -H git checkout v1.8.0 # Addresses multiple critical security vulnerabilities -``` - -### 5. Install libs, migrations, etc. - -```bash -cd /home/git/gitlab - -# MySQL installations (note: the line below states '--without ... postgres') -sudo -u git -H bundle install --without development test postgres --deployment - -# PostgreSQL installations (note: the line below states '--without ... mysql') -sudo -u git -H bundle install --without development test mysql --deployment - - -sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production -sudo -u git -H bundle exec rake migrate_iids RAILS_ENV=production -sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production -sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production -sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production -``` - -### 6. Update config files - -TIP: to see what changed in gitlab.yml.example in this release use next command: - -``` -git diff 6-0-stable:config/gitlab.yml.example 6-5-stable:config/gitlab.yml.example -``` - -* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-5-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-5-stable/config/unicorn.rb.example but with your settings. -* Copy rack attack middleware config - -```bash -sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb -``` - -* Set up logrotate - -```bash -sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab -``` - -### 7. Update Init script - -```bash -sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -``` - -### 8. Start application - - sudo service gitlab start - sudo service nginx restart - -### 9. Check application status - -Check if GitLab and its environment are configured correctly: - - cd /home/git/gitlab - sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production - -To make sure you didn't miss anything run a more thorough check with: - - sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production - -If all items are green, then congratulations upgrade complete! - -## Things went south? Revert to previous version (6.0) - -### 1. Revert the code to the previous version -Follow the [`upgrade guide from 5.4 to 6.0`](5.4-to-6.0.md), except for the database migration -(The backup is already migrated to the previous version) - -### 2. Restore from the backup: - -```bash -cd /home/git/gitlab -sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production -``` diff --git a/doc/update/6.0-to-6.7.md b/doc/update/6.0-to-6.7.md new file mode 100644 index 00000000000..68878bb9cd9 --- /dev/null +++ b/doc/update/6.0-to-6.7.md @@ -0,0 +1,142 @@ +# From 6.0 to 6.7 + +# In 6.1 we remove a lot of deprecated code. +# You should update to 6.0 before installing 6.1 or higher so all the necessary conversions are run. + +### Deprecations + +#### Global issue numbers + +As of 6.1 issue numbers are project specific. This means all issues are renumbered and get a new number in their url. If you use an old issue number url and the issue number does not exist yet you are redirected to the new one. This conversion does not trigger if the old number already exists for this project, this is unlikely but will happen with old issues and large projects. + +### 0. Backup + +It's useful to make a backup just in case things go south: +(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +``` + +For Gitlab Community Edition: + +```bash +sudo -u git -H git checkout 6-7-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 6-7-stable-ee +``` + + +### 3. Install additional packages + +```bash +# Add support for lograte for better log file handling +sudo apt-get install logrotate +``` + +### 4. Update gitlab-shell + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.9.1 # Addresses multiple critical security vulnerabilities +``` + +### 5. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL installations (note: the line below states '--without ... postgres') +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL installations (note: the line below states '--without ... mysql') +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Enable internal issue IDs (introduced in GitLab 6.1) +sudo -u git -H bundle exec rake migrate_iids RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production +``` + +### 6. Update config files + +TIP: to see what changed in gitlab.yml.example in this release use next command: + +``` +git diff 6-0-stable:config/gitlab.yml.example 6-7-stable:config/gitlab.yml.example +``` + +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-7-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-7-stable/config/unicorn.rb.example but with your settings. +* Copy rack attack middleware config + +```bash +sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb +``` + +* Set up logrotate + +```bash +sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab +``` + +### 7. Update Init script + +```bash +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +``` + +### 8. Start application + + sudo service gitlab start + sudo service nginx restart + +### 9. Check application status + +Check if GitLab and its environment are configured correctly: + + cd /home/git/gitlab + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade complete! + +## Things went south? Revert to previous version (6.0) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 5.4 to 6.0`](5.4-to-6.0.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` -- cgit v1.2.1 From af3aaaddbd6d29e5e78f28ade1f18e65404227ab Mon Sep 17 00:00:00 2001 From: dosire Date: Fri, 21 Mar 2014 15:50:33 +0100 Subject: Features people are missing are not bugs. --- CONTRIBUTING.md | 8 ++++---- PROCESS.md | 4 +--- README.md | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1788657b95..c3c615b004c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,9 +24,9 @@ Issues and merge requests should be in English and contain appropriate language To get support for your particular problem please use the channels as detailed in the getting help section of [the readme](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/README.md). Professional [support subscriptions](http://www.gitlab.com/subscription/) and [consulting services](http://www.gitlab.com/consultancy/) are available from [GitLab.com](http://www.gitlab.com/). -The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious bugs or misbehavior in the latest [stable or development release of GitLab](MAINTENANCE.md). When submitting an issue please conform to the issue submission guidelines listed below. Not all issues will be addressed and your issue is more likely to be addressed if you submit a merge request which partially or fully addresses the issue. +The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious bugs in the latest [stable or development release of GitLab](MAINTENANCE.md). If something is missing but it is not a regression compared to older versions of GitLab please do not open an issue but a feature request. When submitting an issue please conform to the issue submission guidelines listed below. Not all issues will be addressed and your issue is more likely to be addressed if you submit a merge request which partially or fully addresses the issue. -Do not use the issue tracker for feature requests. We have a specific [feedback and suggestions forum](http://feedback.gitlab.com) for this purpose. +Do not use the issue tracker for feature requests. We have a specific [feature request forum](http://feedback.gitlab.com) for this purpose. Please send a merge request with a tested solution or a merge request with a failing test instead of opening an issue if you can. If you're unsure where to post, post to the [mailing list](https://groups.google.com/forum/#!forum/gitlabhq) or [Stack Overflow](http://stackoverflow.com/questions/tagged/gitlab) first. There are a lot of helpful GitLab users there who may be able to help you quickly. If your particular issue turns out to be a bug, it will find its way from there. @@ -48,7 +48,7 @@ Please send a merge request with a tested solution or a merge request with a fai ## Merge requests -We welcome merge requests with fixes and improvements to GitLab code, tests, and/or documentation. The features we would really like a merge request for are listed with the [status 'accepting merge requests' on our feedback forum](http://feedback.gitlab.com/forums/176466-general/status/796455) but other improvements are also welcome. If you want to add a new feature that is not marked it is best to first create a feedback issue (if there isn't one already) and leave a comment asking for it to be marked accepting merge requests. Please include screenshots or wireframes if the feature will also change the UI. +We welcome merge requests with fixes and improvements to GitLab code, tests, and/or documentation. The features we would really like a merge request for are listed with the [status 'accepting merge requests' on our feature request forum](http://feedback.gitlab.com/forums/176466-general/status/796455) but other improvements are also welcome. If you want to add a new feature that is not marked it is best to first create a feedback issue (if there isn't one already) and leave a comment asking for it to be marked accepting merge requests. Please include screenshots or wireframes if the feature will also change the UI. ### Merge request guidelines @@ -64,7 +64,7 @@ If you can, please submit a merge request with the fix or improvements including 1. The MR title should describes the change you want to make 1. The MR description should give a motive for your change and the method you used to achieve it 1. If the MR changes the UI it should include before and after screenshots -1. Link relevant [issues](https://gitlab.com/gitlab-org/gitlab-ce/issues) and/or [feedback items](http://feedback.gitlab.com/) from the merge request description and leave a comment on them with a link back to the MR +1. Link relevant [issues](https://gitlab.com/gitlab-org/gitlab-ce/issues) and/or [feature requests](http://feedback.gitlab.com/) from the merge request description and leave a comment on them with a link back to the MR 1. Be prepared to answer questions and incorporate feedback even if requests for this arrive weeks or months after your MR submittion 1. If your MR touches code that executes shell commands, make sure it adheres to the [shell command guidelines]( doc/development/shell_commands.md). diff --git a/PROCESS.md b/PROCESS.md index bf757025c40..feabc6c09a4 100644 --- a/PROCESS.md +++ b/PROCESS.md @@ -24,8 +24,6 @@ Below we describe the contributing process to GitLab for two reasons. So that co - Monitors for new merge requests (at least once a week) - Manages their work queue by looking at issues and merge requests assigned to them - Close fixed issues (via commit messages or manually) -- Codes [new features](http://feedback.gitlab.com/forums/176466-general/filters/top)! -- Response guidelines - Be kind to people trying to contribute. Be aware that people can be a non-native or a native English speaker, they might not understand thing or they might be very sensitive to how your word things. Use emoji to express your feelings (heart, star, smile, etc.). Some good tips about giving feedback to merge requests is in the [Thoughtbot code review guide](https://github.com/thoughtbot/guides/tree/master/code-review). ## Priorities of the issue team @@ -73,7 +71,7 @@ Thanks for the issue report. Please reformat your issue to conform to the issue ### Feature requests -Thanks for your interest in GitLab. We don't use the issue tracker for feature requests. Please use http://feedback.gitlab.com/ for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. +Thanks for your interest in GitLab. We don't use the issue tracker for feature requests. Please use the [feature request forum](http://feedback.gitlab.com/) for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. ### Issue report for old version diff --git a/README.md b/README.md index 3bffdbe1f3a..c6a78e2807b 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Since 2011 GitLab is released on the 22nd of every month. Every new release incl It is recommended to follow a monthly upgrade schedule. Security releases come out when needed. For more information about the release process see the documentation for [monthly](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/release/monthly.md) and [security](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/release/security.md) releases. -* Features that will be in the next releases are listed on [the feedback and suggestions forum](http://feedback.gitlab.com/forums/176466-general) with the status [started](http://feedback.gitlab.com/forums/176466-general/status/796456) and [completed](http://feedback.gitlab.com/forums/176466-general/status/796457). +* Features that will be in the next releases are listed on the [feature request forum](http://feedback.gitlab.com/forums/176466-general) with the status [started](http://feedback.gitlab.com/forums/176466-general/status/796456) and [completed](http://feedback.gitlab.com/forums/176466-general/status/796457). ### Run in production mode @@ -142,7 +142,7 @@ or start each component separately * [Mailing list](https://groups.google.com/forum/#!forum/gitlabhq) and [Stack Overflow](http://stackoverflow.com/questions/tagged/gitlab) are the best places to ask questions. For example you can use it if you have questions about: permission denied errors, invisible repos, can't clone/pull/push or with web hooks that don't fire. Please search for similar issues before posting your own, there's a good chance somebody else had the same issue you have now and has resolved it. There are a lot of helpful GitLab users there who may be able to help you quickly. If your particular issue turns out to be a bug, it will find its way from there to a fix. -* [Feedback and suggestions forum](http://feedback.gitlab.com) is the place to propose and discuss new features for GitLab. +* [Feature request forum](http://feedback.gitlab.com) is the place to propose and discuss new features for GitLab. * [Contributing guide](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) describes how to submit merge requests and issues. Pull requests and issues not in line with the guidelines in this document will be closed. -- cgit v1.2.1 From d03612412a575bb7bb05a2f51570b36493283b8a Mon Sep 17 00:00:00 2001 From: dosire Date: Fri, 21 Mar 2014 15:51:30 +0100 Subject: Ensure I can link to this line. --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3c615b004c..70ab1407500 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,10 @@ Issues and merge requests should be in English and contain appropriate language To get support for your particular problem please use the channels as detailed in the getting help section of [the readme](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/README.md). Professional [support subscriptions](http://www.gitlab.com/subscription/) and [consulting services](http://www.gitlab.com/consultancy/) are available from [GitLab.com](http://www.gitlab.com/). -The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious bugs in the latest [stable or development release of GitLab](MAINTENANCE.md). If something is missing but it is not a regression compared to older versions of GitLab please do not open an issue but a feature request. When submitting an issue please conform to the issue submission guidelines listed below. Not all issues will be addressed and your issue is more likely to be addressed if you submit a merge request which partially or fully addresses the issue. +The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious bugs in the latest [stable or development release of GitLab](MAINTENANCE.md). +If something is missing but it is not a regression compared to older versions of GitLab please do not open an issue but a feature request. +When submitting an issue please conform to the issue submission guidelines listed below. +Not all issues will be addressed and your issue is more likely to be addressed if you submit a merge request which partially or fully addresses the issue. Do not use the issue tracker for feature requests. We have a specific [feature request forum](http://feedback.gitlab.com) for this purpose. -- cgit v1.2.1 From 6bb474a0dc7a01108e9d2345da1c5a6e70d8aed0 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Fri, 21 Mar 2014 17:22:12 +0100 Subject: Version 6.7.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 13f32397641..f0e13c50902 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.7.0.rc1 +6.7.0 -- cgit v1.2.1 From 78261b4aad4ceed5b3b11e761436313b1cac3bfe Mon Sep 17 00:00:00 2001 From: Ali Tavakoli Date: Fri, 21 Mar 2014 14:14:11 -0400 Subject: Set monospace font-family for textarea.js-gfm-input --- app/assets/stylesheets/generic/typography.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/stylesheets/generic/typography.scss b/app/assets/stylesheets/generic/typography.scss index 3a31e28e0ac..bca0b12ab62 100644 --- a/app/assets/stylesheets/generic/typography.scss +++ b/app/assets/stylesheets/generic/typography.scss @@ -120,3 +120,11 @@ a:focus { .md { @include md-typography; } + +/** + * Textareas intended for GFM + * + */ +textarea.js-gfm-input { + font-family: $monospace_font; +} -- cgit v1.2.1 From d8a015cc9723557665ada26609b3f13820b03665 Mon Sep 17 00:00:00 2001 From: dosire Date: Fri, 21 Mar 2014 18:34:59 +0100 Subject: Should be 6-7. --- doc/install/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index a37eb733147..addb21b50e0 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -173,7 +173,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da ## Clone the Source # Clone GitLab repository - sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-6-stable gitlab + sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-7-stable gitlab # Go to gitlab dir cd /home/git/gitlab -- cgit v1.2.1 From 5c038d949f1e40939548c530214d65d33ab94904 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 23:04:57 +0200 Subject: Fix gitlab-ci integration Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index de18d904916..c2f3b851c07 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -64,7 +64,7 @@ module Grack token = project.gitlab_ci_service.token if token.present? && token == password && git_cmd == 'git-upload-pack' - true + return true end end -- cgit v1.2.1 From ae1a3148242907b21e9952f1964919622b4f3129 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 23:08:36 +0200 Subject: Fix upgrader Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/upgrader.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gitlab/upgrader.rb b/lib/gitlab/upgrader.rb index 0fe4888665d..0846359f9b1 100644 --- a/lib/gitlab/upgrader.rb +++ b/lib/gitlab/upgrader.rb @@ -1,3 +1,4 @@ +require_relative "popen" require_relative "version_info" module Gitlab -- cgit v1.2.1 From 4b2c50d53f32fcd09674dc8ba0aa9719ece73d56 Mon Sep 17 00:00:00 2001 From: Jeroen van Baarsen Date: Sat, 22 Mar 2014 20:09:23 +0100 Subject: Added some extra information how a good MR looks like --- CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6d6ec28ed9..47b04c11d24 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,14 @@ Please keep the change in a single MR **as small as possible**. If you want to c For examples of feedback on merge requests please look at already [closed merge requests](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests?assignee_id=&label_name=&milestone_id=&scope=&sort=&state=closed). Please ensure that your merge request meets the following contribution acceptance criteria. +**Please format your merge request as follow:** + +1. What does this MR do? +2. Are there points in the code the reviewer needs to double check? +3. Why was this MR needed? +4. What are the relevant issue numbers / [Feedback items](http://feedback.gitlab.com/)? +5. Screenshots (If appropiate) + ## Contribution acceptance criteria 1. The change is as small as possible (see the above paragraph for details) -- cgit v1.2.1 From fa340595746ba18fae3c6422ff4c9ea4af8e3023 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 22 Mar 2014 15:36:54 -0400 Subject: Default message for SatelliteNotExistError --- lib/gitlab/satellite/satellite.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index bcf3012bd92..9e3c3997e55 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -1,5 +1,9 @@ module Gitlab - class SatelliteNotExistError < StandardError; end + class SatelliteNotExistError < StandardError + def initialize(msg = "Satellite doesn't exist") + super + end + end module Satellite class Satellite @@ -17,12 +21,8 @@ module Gitlab Gitlab::Satellite::Logger.error(message) end - def raise_no_satellite - raise SatelliteNotExistError.new("Satellite doesn't exist") - end - def clear_and_update! - raise_no_satellite unless exists? + raise SatelliteNotExistError unless exists? File.exists? path @repo = nil @@ -55,7 +55,7 @@ module Gitlab # * Changes the current directory to the satellite's working dir # * Yields def lock - raise_no_satellite unless exists? + raise SatelliteNotExistError unless exists? File.open(lock_file, "w+") do |f| begin @@ -77,7 +77,7 @@ module Gitlab end def repo - raise_no_satellite unless exists? + raise SatelliteNotExistError unless exists? @repo ||= Grit::Repo.new(path) end -- cgit v1.2.1 From 760f827ba0257d6664f429a832d1962fcac6e58e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 22 Mar 2014 15:40:42 -0400 Subject: Remove code that does nothing ping @karlhungus --- lib/gitlab/satellite/satellite.rb | 1 - spec/support/test_env.rb | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 9e3c3997e55..bdfcf254e9e 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -24,7 +24,6 @@ module Gitlab def clear_and_update! raise SatelliteNotExistError unless exists? - File.exists? path @repo = nil clear_working_dir! delete_heads! diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index e2c3f648ccf..d00decf6121 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -29,7 +29,6 @@ module TestEnv disable_mailer if opts[:mailer] == false setup_stubs - clear_test_repo_dir if opts[:init_repos] == true setup_test_repos(opts) if opts[:repos] == true end @@ -165,8 +164,7 @@ module TestEnv def clear_test_repo_dir setup_stubs - # Use tmp dir for FS manipulations - repos_path = testing_path() + # Remove tmp/test-git-base-path FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path -- cgit v1.2.1 From 85b5812bc21623c6a11ed92f482ac8282ec12fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bner=20Silva=20de=20Oliveira?= Date: Sat, 22 Mar 2014 17:29:13 -0300 Subject: moving labels specs to projects_spec file --- spec/requests/api/labels_spec.rb | 26 -------------------------- spec/requests/api/projects_spec.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 spec/requests/api/labels_spec.rb diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb deleted file mode 100644 index ba5efb6c603..00000000000 --- a/spec/requests/api/labels_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe API::API do - include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - - let(:user) { create(:user) } - let!(:project) { create(:project, namespace: user.namespace ) } - let!(:issue) { create(:issue, author: user, assignee: user, project: project, :label_list => "label1, label2") } - before { project.team << [user, :reporter] } - - - describe "GET /projects/:id/labels" do - it "should return project labels" do - get api("/projects/#{project.id}/labels", user) - response.status.should == 200 - json_response.should be_an Array - json_response.first['name'].should == 'label1' - json_response.last['name'].should == 'label2' - end - end - - -end - diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 149c5bffcda..7fe65639657 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -13,6 +13,7 @@ describe API::API do let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } + let(:issue_with_labels) { create(:issue, author: user, assignee: user, project: project, :label_list => "label1, label2") } describe "GET /projects" do before { project } @@ -632,4 +633,16 @@ describe API::API do end end end + + describe "GET /projects/:id/labels" do + before { issue_with_labels } + + it "should return project labels" do + get api("/projects/#{project.id}/labels", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == issue_with_labels.labels.first.name + json_response.last['name'].should == issue_with_labels.labels.last.name + end + end end -- cgit v1.2.1 From 07833d16760bf30e4c9c84653909d4efe2dbcaff Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 22 Mar 2014 16:37:54 -0400 Subject: Move Project's service specs to the correct location [ci skip] --- spec/services/project_transfer_service_spec.rb | 33 ----- spec/services/projects/create_service_spec.rb | 163 ++++++++++++++++++++++++ spec/services/projects/transfer_service_spec.rb | 33 +++++ spec/services/projects/update_service_spec.rb | 111 ++++++++++++++++ spec/services/projects_create_service_spec.rb | 163 ------------------------ spec/services/projects_update_service_spec.rb | 111 ---------------- 6 files changed, 307 insertions(+), 307 deletions(-) delete mode 100644 spec/services/project_transfer_service_spec.rb create mode 100644 spec/services/projects/create_service_spec.rb create mode 100644 spec/services/projects/transfer_service_spec.rb create mode 100644 spec/services/projects/update_service_spec.rb delete mode 100644 spec/services/projects_create_service_spec.rb delete mode 100644 spec/services/projects_update_service_spec.rb diff --git a/spec/services/project_transfer_service_spec.rb b/spec/services/project_transfer_service_spec.rb deleted file mode 100644 index 109b429967e..00000000000 --- a/spec/services/project_transfer_service_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe ProjectTransferService do - before(:each) { enable_observers } - after(:each) {disable_observers} - - context 'namespace -> namespace' do - let(:user) { create(:user) } - let(:group) { create(:group) } - let(:project) { create(:project, namespace: user.namespace) } - - before do - @result = service.transfer(project, group) - end - - it { @result.should be_true } - it { project.namespace.should == group } - end - - context 'namespace -> no namespace' do - let(:user) { create(:user) } - let(:project) { create(:project, namespace: user.namespace) } - - it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) } - end - - def service - service = ProjectTransferService.new - service.gitlab_shell.stub(mv_repository: true) - service - end -end - diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb new file mode 100644 index 00000000000..f2a784df103 --- /dev/null +++ b/spec/services/projects/create_service_spec.rb @@ -0,0 +1,163 @@ +require 'spec_helper' + +describe Projects::CreateService do + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + describe :create_by_user do + before do + @user = create :user + @admin = create :user, admin: true + @opts = { + name: "GitLab", + namespace: @user.namespace + } + end + + context 'user namespace' do + before do + @project = create_project(@user, @opts) + end + + it { @project.should be_valid } + it { @project.owner.should == @user } + it { @project.namespace.should == @user.namespace } + end + + context 'group namespace' do + before do + @group = create :group + @group.add_owner(@user) + + @opts.merge!(namespace_id: @group.id) + @project = create_project(@user, @opts) + end + + it { @project.should be_valid } + it { @project.owner.should == @group } + it { @project.namespace.should == @group } + end + + context 'wiki_enabled creates repository directory' do + context 'wiki_enabled true creates wiki repository directory' do + before do + @project = create_project(@user, @opts) + @path = GollumWiki.new(@project, @user).send(:path_to_repo) + end + + it { File.exists?(@path).should be_true } + end + + context 'wiki_enabled false does not create wiki repository directory' do + before do + @opts.merge!(wiki_enabled: false) + @project = create_project(@user, @opts) + @path = GollumWiki.new(@project, @user).send(:path_to_repo) + end + + it { File.exists?(@path).should be_false } + end + end + + context 'respect configured visibility setting' do + before(:each) do + @settings = double("settings") + @settings.stub(:issues) { true } + @settings.stub(:merge_requests) { true } + @settings.stub(:wiki) { true } + @settings.stub(:wall) { true } + @settings.stub(:snippets) { true } + stub_const("Settings", Class.new) + @restrictions = double("restrictions") + @restrictions.stub(:restricted_visibility_levels) { [] } + Settings.stub_chain(:gitlab).and_return(@restrictions) + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) + end + + context 'should be public when setting is public' do + before do + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } + @project = create_project(@user, @opts) + end + + it { @project.public?.should be_true } + end + + context 'should be private when setting is private' do + before do + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } + @project = create_project(@user, @opts) + end + + it { @project.private?.should be_true } + end + + context 'should be internal when setting is internal' do + before do + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::INTERNAL } + @project = create_project(@user, @opts) + end + + it { @project.internal?.should be_true } + end + end + + context 'respect configured visibility restrictions setting' do + before(:each) do + @settings = double("settings") + @settings.stub(:issues) { true } + @settings.stub(:merge_requests) { true } + @settings.stub(:wiki) { true } + @settings.stub(:wall) { true } + @settings.stub(:snippets) { true } + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } + stub_const("Settings", Class.new) + @restrictions = double("restrictions") + @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } + Settings.stub_chain(:gitlab).and_return(@restrictions) + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) + end + + context 'should be private when option is public' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + @project = create_project(@user, @opts) + end + + it { @project.private?.should be_true } + end + + context 'should be public when option is public for admin' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + @project = create_project(@admin, @opts) + end + + it { @project.public?.should be_true } + end + + context 'should be private when option is private' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) + @project = create_project(@user, @opts) + end + + it { @project.private?.should be_true } + end + + context 'should be internal when option is internal' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + @project = create_project(@user, @opts) + end + + it { @project.internal?.should be_true } + end + end + end + + def create_project(user, opts) + Projects::CreateService.new(user, opts).execute + end +end + diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb new file mode 100644 index 00000000000..109b429967e --- /dev/null +++ b/spec/services/projects/transfer_service_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe ProjectTransferService do + before(:each) { enable_observers } + after(:each) {disable_observers} + + context 'namespace -> namespace' do + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:project) { create(:project, namespace: user.namespace) } + + before do + @result = service.transfer(project, group) + end + + it { @result.should be_true } + it { project.namespace.should == group } + end + + context 'namespace -> no namespace' do + let(:user) { create(:user) } + let(:project) { create(:project, namespace: user.namespace) } + + it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) } + end + + def service + service = ProjectTransferService.new + service.gitlab_shell.stub(mv_repository: true) + service + end +end + diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb new file mode 100644 index 00000000000..1854c0d8233 --- /dev/null +++ b/spec/services/projects/update_service_spec.rb @@ -0,0 +1,111 @@ +require 'spec_helper' + +describe Projects::UpdateService do + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + describe :update_by_user do + before do + @user = create :user + @admin = create :user, admin: true + @project = create :project, creator_id: @user.id, namespace: @user.namespace + @opts = { project: {} } + end + + context 'should be private when updated to private' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.private?.should be_true } + end + + context 'should be internal when updated to internal' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.internal?.should be_true } + end + + context 'should be public when updated to public' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.public?.should be_true } + end + + context 'respect configured visibility restrictions setting' do + before(:each) do + @restrictions = double("restrictions") + @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } + Settings.stub_chain(:gitlab).and_return(@restrictions) + end + + context 'should be private when updated to private' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.private?.should be_true } + end + + context 'should be internal when updated to internal' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.internal?.should be_true } + end + + context 'should be private when updated to public' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.private?.should be_true } + end + + context 'should be public when updated to public by admin' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + update_project(@project, @admin, @opts) + end + + it { @created_private.should be_true } + it { @project.public?.should be_true } + end + end + end + + def update_project(project, user, opts) + Projects::UpdateService.new(project, user, opts).execute + end +end diff --git a/spec/services/projects_create_service_spec.rb b/spec/services/projects_create_service_spec.rb deleted file mode 100644 index f2a784df103..00000000000 --- a/spec/services/projects_create_service_spec.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'spec_helper' - -describe Projects::CreateService do - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - - describe :create_by_user do - before do - @user = create :user - @admin = create :user, admin: true - @opts = { - name: "GitLab", - namespace: @user.namespace - } - end - - context 'user namespace' do - before do - @project = create_project(@user, @opts) - end - - it { @project.should be_valid } - it { @project.owner.should == @user } - it { @project.namespace.should == @user.namespace } - end - - context 'group namespace' do - before do - @group = create :group - @group.add_owner(@user) - - @opts.merge!(namespace_id: @group.id) - @project = create_project(@user, @opts) - end - - it { @project.should be_valid } - it { @project.owner.should == @group } - it { @project.namespace.should == @group } - end - - context 'wiki_enabled creates repository directory' do - context 'wiki_enabled true creates wiki repository directory' do - before do - @project = create_project(@user, @opts) - @path = GollumWiki.new(@project, @user).send(:path_to_repo) - end - - it { File.exists?(@path).should be_true } - end - - context 'wiki_enabled false does not create wiki repository directory' do - before do - @opts.merge!(wiki_enabled: false) - @project = create_project(@user, @opts) - @path = GollumWiki.new(@project, @user).send(:path_to_repo) - end - - it { File.exists?(@path).should be_false } - end - end - - context 'respect configured visibility setting' do - before(:each) do - @settings = double("settings") - @settings.stub(:issues) { true } - @settings.stub(:merge_requests) { true } - @settings.stub(:wiki) { true } - @settings.stub(:wall) { true } - @settings.stub(:snippets) { true } - stub_const("Settings", Class.new) - @restrictions = double("restrictions") - @restrictions.stub(:restricted_visibility_levels) { [] } - Settings.stub_chain(:gitlab).and_return(@restrictions) - Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) - end - - context 'should be public when setting is public' do - before do - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } - @project = create_project(@user, @opts) - end - - it { @project.public?.should be_true } - end - - context 'should be private when setting is private' do - before do - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } - @project = create_project(@user, @opts) - end - - it { @project.private?.should be_true } - end - - context 'should be internal when setting is internal' do - before do - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::INTERNAL } - @project = create_project(@user, @opts) - end - - it { @project.internal?.should be_true } - end - end - - context 'respect configured visibility restrictions setting' do - before(:each) do - @settings = double("settings") - @settings.stub(:issues) { true } - @settings.stub(:merge_requests) { true } - @settings.stub(:wiki) { true } - @settings.stub(:wall) { true } - @settings.stub(:snippets) { true } - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } - stub_const("Settings", Class.new) - @restrictions = double("restrictions") - @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } - Settings.stub_chain(:gitlab).and_return(@restrictions) - Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) - end - - context 'should be private when option is public' do - before do - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) - @project = create_project(@user, @opts) - end - - it { @project.private?.should be_true } - end - - context 'should be public when option is public for admin' do - before do - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) - @project = create_project(@admin, @opts) - end - - it { @project.public?.should be_true } - end - - context 'should be private when option is private' do - before do - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) - @project = create_project(@user, @opts) - end - - it { @project.private?.should be_true } - end - - context 'should be internal when option is internal' do - before do - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) - @project = create_project(@user, @opts) - end - - it { @project.internal?.should be_true } - end - end - end - - def create_project(user, opts) - Projects::CreateService.new(user, opts).execute - end -end - diff --git a/spec/services/projects_update_service_spec.rb b/spec/services/projects_update_service_spec.rb deleted file mode 100644 index 1854c0d8233..00000000000 --- a/spec/services/projects_update_service_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -require 'spec_helper' - -describe Projects::UpdateService do - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - - describe :update_by_user do - before do - @user = create :user - @admin = create :user, admin: true - @project = create :project, creator_id: @user.id, namespace: @user.namespace - @opts = { project: {} } - end - - context 'should be private when updated to private' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) - update_project(@project, @user, @opts) - end - - it { @created_private.should be_true } - it { @project.private?.should be_true } - end - - context 'should be internal when updated to internal' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) - update_project(@project, @user, @opts) - end - - it { @created_private.should be_true } - it { @project.internal?.should be_true } - end - - context 'should be public when updated to public' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) - update_project(@project, @user, @opts) - end - - it { @created_private.should be_true } - it { @project.public?.should be_true } - end - - context 'respect configured visibility restrictions setting' do - before(:each) do - @restrictions = double("restrictions") - @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } - Settings.stub_chain(:gitlab).and_return(@restrictions) - end - - context 'should be private when updated to private' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) - update_project(@project, @user, @opts) - end - - it { @created_private.should be_true } - it { @project.private?.should be_true } - end - - context 'should be internal when updated to internal' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) - update_project(@project, @user, @opts) - end - - it { @created_private.should be_true } - it { @project.internal?.should be_true } - end - - context 'should be private when updated to public' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) - update_project(@project, @user, @opts) - end - - it { @created_private.should be_true } - it { @project.private?.should be_true } - end - - context 'should be public when updated to public by admin' do - before do - @created_private = @project.private? - - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) - update_project(@project, @admin, @opts) - end - - it { @created_private.should be_true } - it { @project.public?.should be_true } - end - end - end - - def update_project(project, user, opts) - Projects::UpdateService.new(project, user, opts).execute - end -end -- cgit v1.2.1 From 3704d85bc49e76891f37f3b14d6fddb499921ed8 Mon Sep 17 00:00:00 2001 From: awiddersheim Date: Sat, 22 Mar 2014 16:44:13 -0400 Subject: Remove periods from merge request The "Merged by" and "Closed by" statements end with an extra space followed by a period. This doesn't seem necessary to me and not having the extra space followed by a period looks better to me. Also, the top of the merge request doesn't have the sentence ending with a period. --- app/views/projects/merge_requests/show/_mr_box.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml index 38db4363ade..abdcd127a0c 100644 --- a/app/views/projects/merge_requests/show/_mr_box.html.haml +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -29,13 +29,13 @@ %span %i.icon-remove Closed by #{link_to_member(@project, @merge_request.closed_event.author)} - #{time_ago_with_tooltip(@merge_request.closed_event.created_at)}. + #{time_ago_with_tooltip(@merge_request.closed_event.created_at)} - if @merge_request.merged? .alert.alert-info %span %i.icon-ok Merged by #{link_to_member(@project, @merge_request.merge_event.author)} - #{time_ago_with_tooltip(@merge_request.merge_event.created_at)}. + #{time_ago_with_tooltip(@merge_request.merge_event.created_at)} - if !@closes_issues.empty? && @merge_request.open? .alert.alert-info.alert-info %span -- cgit v1.2.1 From 6adbfda2f832b7e0e5a16718d625a3be3f137819 Mon Sep 17 00:00:00 2001 From: Jeroen van Baarsen Date: Sun, 23 Mar 2014 19:07:09 +0100 Subject: Better naming things --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47b04c11d24..d816f8e72a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,12 +77,12 @@ Please keep the change in a single MR **as small as possible**. If you want to c For examples of feedback on merge requests please look at already [closed merge requests](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests?assignee_id=&label_name=&milestone_id=&scope=&sort=&state=closed). Please ensure that your merge request meets the following contribution acceptance criteria. -**Please format your merge request as follow:** +**Please format your merge request description as follows:** 1. What does this MR do? 2. Are there points in the code the reviewer needs to double check? 3. Why was this MR needed? -4. What are the relevant issue numbers / [Feedback items](http://feedback.gitlab.com/)? +4. What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)? 5. Screenshots (If appropiate) ## Contribution acceptance criteria -- cgit v1.2.1 From e153469f31db106d0720e357a5e22431635f2b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bner=20Silva=20de=20Oliveira?= Date: Sun, 23 Mar 2014 19:07:18 -0300 Subject: changed doc comment for get labels of a project --- lib/api/projects.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 40b5ce86c93..9d290c75ba9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -216,10 +216,12 @@ module API present @users, with: Entities::User end - # Get a labels list + # Get a project labels # + # Parameters: + # id (required) - The ID of a project # Example Request: - # GET /users + # GET /projects/:id/labels get ':id/labels' do @labels = user_project.issues_labels present @labels, with: Entities::Label -- cgit v1.2.1 From 19938156d89ea980596fd5b1d72856f3defb228a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bner=20Silva=20de=20Oliveira?= Date: Sun, 23 Mar 2014 19:20:17 -0300 Subject: documentation for api method which get labels of a project --- doc/api/projects.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/api/projects.md b/doc/api/projects.md index 6e82ddd9903..54618d7c045 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -621,3 +621,29 @@ Parameters: + query (required) - A string contained in the project name + per_page (optional) - number of projects to return per page + page (optional) - the page to retrieve + + +## Labels + +### List project labels + +Get a list of project labels. + +``` +GET /projects/:id/labels +``` + +Parameters: + ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + +```json +[ + { + "name":"featute" + }, + { + "name": "bug" + } +] +``` -- cgit v1.2.1 From 6672d6492f8a118d6ef26efaec38d3b1bab9223a Mon Sep 17 00:00:00 2001 From: Ciro Santillli Date: Sun, 23 Mar 2014 23:49:22 +0100 Subject: Start development Key seed id from 1. --- db/fixtures/development/11_keys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb index 42171393d1b..61329f197c3 100644 --- a/db/fixtures/development/11_keys.rb +++ b/db/fixtures/development/11_keys.rb @@ -2,7 +2,7 @@ Gitlab::Seeder.quiet do User.first(30).each_with_index do |user, i| Key.seed(:id, [ { - id: i, + id: i + 1, title: "Sample key #{i}", key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{i + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", user_id: user.id, -- cgit v1.2.1 From dab09af518a1ab573b30f12895b448790bc66222 Mon Sep 17 00:00:00 2001 From: Drew Blessing Date: Sun, 23 Mar 2014 21:17:01 -0500 Subject: Mobile UI Improvements Move spinner for mobile --- app/assets/stylesheets/sections/header.scss | 6 ++++++ app/views/layouts/_public_head_panel.html.haml | 16 ++++++++++------ app/views/layouts/public_projects.html.haml | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/sections/header.scss b/app/assets/stylesheets/sections/header.scss index f8da4f0f87b..06709bd7ef6 100644 --- a/app/assets/stylesheets/sections/header.scss +++ b/app/assets/stylesheets/sections/header.scss @@ -273,3 +273,9 @@ header { } } } + +@media (max-width: $screen-xs-max) { + #nprogress .spinner { + right: 35px !important; + } +} diff --git a/app/views/layouts/_public_head_panel.html.haml b/app/views/layouts/_public_head_panel.html.haml index 99e11cd2b5c..63992a22f32 100644 --- a/app/views/layouts/_public_head_panel.html.haml +++ b/app/views/layouts/_public_head_panel.html.haml @@ -8,11 +8,15 @@ %span.separator %h1.title= title - .pull-right + %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle navigation + %i.icon-reorder + + .pull-right.hidden-xs = link_to "Sign in", new_session_path(:user), class: 'btn btn-sign-in btn-new' - %ul.nav.navbar-nav - %li - %a - %div.hide.turbolink-spinner - %i.icon-refresh.icon-spin + .navbar-collapse.collapse + %ul.nav.navbar-nav + %li.visible-xs + = link_to "Sign in", new_session_path(:user) + diff --git a/app/views/layouts/public_projects.html.haml b/app/views/layouts/public_projects.html.haml index cf4ca9c7a84..2a9230244f8 100644 --- a/app/views/layouts/public_projects.html.haml +++ b/app/views/layouts/public_projects.html.haml @@ -4,7 +4,7 @@ %body{class: "#{app_theme} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/public_head_panel", title: project_title(@project) - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/project' .container .content= yield -- cgit v1.2.1 From b816389182084bd0234d8409bdd4cfef41f8e502 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 24 Mar 2014 09:52:50 +0100 Subject: Suppress 'Rendered' messages in production.log --- config/environments/production.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index 9ac4622abc2..87c5efd2142 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -33,6 +33,11 @@ Gitlab::Application.configure do # See everything in the log (default is :info) # config.log_level = :debug + # Suppress 'Rendered template ...' messages in the log + %w{render_template render_partial render_collection}.each do |event| + ActiveSupport::Notifications.unsubscribe "#{event}.action_view" + end + # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] -- cgit v1.2.1 From 7862201de9e3e8229e33a28d17fb2edb691eead0 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 24 Mar 2014 09:57:28 +0100 Subject: Add source for 'Rendered' message suppression --- config/environments/production.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index 87c5efd2142..ad3c03d8fc9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -34,6 +34,7 @@ Gitlab::Application.configure do # config.log_level = :debug # Suppress 'Rendered template ...' messages in the log + # source: http://stackoverflow.com/a/16369363 %w{render_template render_partial render_collection}.each do |event| ActiveSupport::Notifications.unsubscribe "#{event}.action_view" end -- cgit v1.2.1 From 00487d455a10e074a4539a231a9b3028853a7334 Mon Sep 17 00:00:00 2001 From: dosire Date: Mon, 24 Mar 2014 12:04:43 +0100 Subject: References for the issues the guide addresses. --- doc/development/shell_commands.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/development/shell_commands.md b/doc/development/shell_commands.md index 57b1172d5e6..63e58a63080 100644 --- a/doc/development/shell_commands.md +++ b/doc/development/shell_commands.md @@ -1,5 +1,11 @@ # Guidelines for shell commands in the GitLab codebase +## References + +- [Google Ruby Security Reviewer's Guide](https://code.google.com/p/ruby-security/wiki/Guide) +- [OWASP Command Injection](https://www.owasp.org/index.php/Command_Injection) +- [Ruby on Rails Security Guide](http://guides.rubyonrails.org/security.html) section 7.7 + ## Use File and FileUtils instead of shell commands Sometimes we invoke basic Unix commands via the shell when there is also a Ruby API for doing it. -- cgit v1.2.1 From de5e41c67d1e0c2d4aa53fbe863a8b3f7e24f731 Mon Sep 17 00:00:00 2001 From: dosire Date: Mon, 24 Mar 2014 13:35:24 +0100 Subject: Move up in the month. --- doc/release/monthly.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/release/monthly.md b/doc/release/monthly.md index 28fc260b334..77502a97833 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -58,16 +58,14 @@ Check if changed since last release (~22nd of last month depending on when last After making the release branch new commits are cherry-picked from master. When the release gets closer we get more selective what is cherry-picked. The days of the month are approximately as follows: -* 17th: feature freeze (stop merging new features in master) -* 18th: UI freeze (stop merging changes to the user interface) -* 19th: code freeze (stop merging non-essential code improvements) -* 20th: release candidate 1 (VERSION x.x.0.rc1, tag and tweet about x.x.0.rc1) -* 21st: optional release candidate 2 (x.x.0.rc2, only if rc1 had problems) +* 1-7th: official merge window (see contributing guide) +* 8-14th: work on bugfixes, sponsored features and GitLab EE +* 15th: code freeze (stop merging into master except essential bugfixes) +* 18th: release candidate 1 (VERSION x.x.0.rc1, tag and tweet about x.x.0.rc1, release on GitLab Cloud) +* 20st: optional release candidate 2 (x.x.0.rc2, only if rc1 had problems) * 22nd: release (VERSION x.x.0, create x-x-stable branch, tag, blog and tweet) * 23nd: optional patch releases (x.x.1, x.x.2, etc., only if there are serious problems) -* 24-end of month: release Enterprise Edition and upgrade GitLab Cloud -* 1-7th: official merge window (see contributing guide) -* 8-16th: bugfixes and sponsored features +* 24-end of month: release GitLab EE and GitLab CI # Write a blog post -- cgit v1.2.1 From 1e3b5c3787bcd7f1fce775e2c3de5ce0aabc813d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 13 Mar 2014 18:34:12 -0400 Subject: Remove Spork --- Gemfile | 1 - Gemfile.lock | 2 -- spec/spec_helper.rb | 101 +++++++++++++++++++++++----------------------------- 3 files changed, 44 insertions(+), 60 deletions(-) diff --git a/Gemfile b/Gemfile index 5b58ce443ae..397165f668f 100644 --- a/Gemfile +++ b/Gemfile @@ -218,7 +218,6 @@ group :development, :test do # PhantomJS driver for Capybara gem 'poltergeist', '~> 1.4.1' - gem 'spork', '~> 1.0rc' gem 'jasmine', '2.0.0.rc5' gem "spring", '1.1.1' diff --git a/Gemfile.lock b/Gemfile.lock index 167fd960ff5..1a0bce98ac5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -484,7 +484,6 @@ GEM capybara (>= 2.0.0) railties (>= 3) spinach (>= 0.4) - spork (1.0.0rc4) spring (1.1.1) spring-commands-rspec (1.0.1) spring (>= 0.9.1) @@ -661,7 +660,6 @@ DEPENDENCIES slack-notifier (~> 0.2.0) slim spinach-rails - spork (~> 1.0rc) spring (= 1.1.1) spring-commands-rspec (= 1.0.1) spring-commands-spinach (= 1.0.0) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dd008ed02ad..e6b1f816df0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,63 +1,50 @@ -require 'rubygems' -require 'spork' +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) -Spork.prefork do - require 'simplecov' unless ENV['CI'] +require 'simplecov' unless ENV['CI'] - if ENV['TRAVIS'] - require 'coveralls' - Coveralls.wear! - end - - # This file is copied to spec/ when you run 'rails generate rspec:install' - ENV["RAILS_ENV"] ||= 'test' - require File.expand_path("../../config/environment", __FILE__) - require 'rspec/rails' - require 'capybara/rails' - require 'capybara/rspec' - require 'webmock/rspec' - require 'email_spec' - require 'sidekiq/testing/inline' - require 'capybara/poltergeist' - - # Loading more in this block will cause your tests to run faster. However, - - # if you change any configuration or code from libraries loaded here, you'll - # need to restart spork for it take effect. - Capybara.javascript_driver = :poltergeist - Capybara.default_wait_time = 10 - - # Requires supporting ruby files with custom matchers and macros, etc, - # in spec/support/ and its subdirectories. - Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} - - WebMock.disable_net_connect!(allow_localhost: true) - - RSpec.configure do |config| - config.mock_with :rspec - - config.include LoginHelpers, type: :feature - config.include LoginHelpers, type: :request - config.include FactoryGirl::Syntax::Methods - config.include Devise::TestHelpers, type: :controller - - config.include TestEnv - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = false - - config.before(:suite) do - TestEnv.init(observers: false, init_repos: true, repos: false) - end - config.before(:each) do - TestEnv.setup_stubs - end - end +if ENV['TRAVIS'] + require 'coveralls' + Coveralls.wear! end -Spork.each_run do - # This code will be run each time you run your specs. +require 'rspec/rails' +require 'capybara/rails' +require 'capybara/rspec' +require 'webmock/rspec' +require 'email_spec' +require 'sidekiq/testing/inline' +require 'capybara/poltergeist' + +Capybara.javascript_driver = :poltergeist +Capybara.default_wait_time = 10 + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +WebMock.disable_net_connect!(allow_localhost: true) +RSpec.configure do |config| + config.mock_with :rspec + + config.include LoginHelpers, type: :feature + config.include LoginHelpers, type: :request + config.include FactoryGirl::Syntax::Methods + config.include Devise::TestHelpers, type: :controller + + config.include TestEnv + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = false + + config.before(:suite) do + TestEnv.init(observers: false, init_repos: true, repos: false) + end + config.before(:each) do + TestEnv.setup_stubs + end end -- cgit v1.2.1 From 2855a799fde6ec60c5bfff348f6dfa9b1e480bcc Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 18 Mar 2014 20:01:17 -0400 Subject: Remove --drb from .rspec --- .rspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rspec b/.rspec index 7488cbe7792..4e1e0d2f722 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---color --drb +--color -- cgit v1.2.1 From a87f03768f87c3ebe62b7aaf94380eb56239bd4e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 18 Mar 2014 20:05:10 -0400 Subject: Fix deprecation warning output Removes the following from test output: DEPRECATION WARNING: It looks like you are eager loading table(s) (one of: merge_requests, projects) that are referenced in a string SQL snippet. For example: Post.includes(:comments).where("comments.title = 'foo'") Currently, Active Record recognizes the table in the string, and knows to JOIN the comments table to the query, rather than loading comments in a separate query. However, doing this without writing a full-blown SQL parser is inherently flawed. Since we don't want to write an SQL parser, we are removing this functionality. From now on, you must explicitly tell Active Record when you are referencing a table from a string: Post.includes(:comments).where("comments.title = 'foo'").references(:comments) If you don't rely on implicit join references you can disable the feature entirely by setting `config.active_record.disable_implicit_join_references = true`. --- app/finders/base_finder.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/finders/base_finder.rb b/app/finders/base_finder.rb index d20716fb170..7fc5840561c 100644 --- a/app/finders/base_finder.rb +++ b/app/finders/base_finder.rb @@ -47,9 +47,9 @@ class BaseFinder [] end elsif current_user && params[:authorized_only].presence - klass.of_projects(current_user.authorized_projects) + klass.of_projects(current_user.authorized_projects).references(:project) else - klass.of_projects(Project.accessible_to(current_user)) + klass.of_projects(Project.accessible_to(current_user)).references(:project) end end -- cgit v1.2.1 From 5fbf15cb88411ebca2156dfefe993503e074ce3e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Mar 2014 15:10:21 +0200 Subject: Add proper explanation to MR in archived projects Signed-off-by: Dmitriy Zaporozhets --- app/views/projects/merge_requests/show/_mr_accept.html.haml | 8 ++++++-- app/views/projects/show.html.haml | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/projects/merge_requests/show/_mr_accept.html.haml b/app/views/projects/merge_requests/show/_mr_accept.html.haml index 97706a5a4b0..4b1857ccb68 100644 --- a/app/views/projects/merge_requests/show/_mr_accept.html.haml +++ b/app/views/projects/merge_requests/show/_mr_accept.html.haml @@ -1,6 +1,10 @@ - unless @allowed_to_merge - .bs-callout - %strong You don't have permission to merge this MR + - if @project.archived? + .bs-callout.bs-callout-warning + %strong Archived projects cannot be committed to! + - else + .bs-callout + %strong You don't have permission to merge this MR - if @show_merge_controls diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 8a1e1d3354b..20879d69091 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -9,8 +9,8 @@ .col-md-3.project-side.hidden-sm .clearfix - if @project.archived? - .alert - %h5 + .alert.alert-warning + %h4 %i.icon-warning-sign Archived project! %p Repository is read-only -- cgit v1.2.1 From eb4320cb07db2b704d6e976fe9e2ac7d959b6c25 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Mar 2014 15:20:29 +0200 Subject: Remove assignee/milestone selects from MR form Signed-off-by: Dmitriy Zaporozhets --- app/views/projects/merge_requests/_form.html.haml | 45 +++++++---------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/app/views/projects/merge_requests/_form.html.haml b/app/views/projects/merge_requests/_form.html.haml index 51fa29ddcbe..22502760e50 100644 --- a/app/views/projects/merge_requests/_form.html.haml +++ b/app/views/projects/merge_requests/_form.html.haml @@ -1,13 +1,18 @@ -- if @repository.contribution_guide && !@merge_request.persisted? - - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name)) - .alert.alert-info.col-sm-10.col-sm-offset-2 - ="Please review the #{link_to "guidelines for contribution", contribution_guide_url} to this repository.".html_safe = form_for [@project, @merge_request], html: { class: "merge-request-form form-horizontal" } do |f| - -if @merge_request.errors.any? - .alert.alert-danger - %ul - - @merge_request.errors.full_messages.each do |msg| - %li= msg + .row + .col-sm-2 + .col-sm-10 + - if @repository.contribution_guide && !@merge_request.persisted? + - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name)) + .alert.alert-info + Please review the + %strong #{link_to "guidelines for contribution", contribution_guide_url} + to this repository. + + -if @merge_request.errors.any? + .alert.alert-danger + - @merge_request.errors.full_messages.each do |msg| + %div= msg .merge-request-branches .form-group @@ -47,24 +52,6 @@ = f.text_area :description, class: "form-control js-gfm-input", rows: 14 %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - %hr - .form-group - .merge-request-assignee - = f.label :assignee_id, class: 'control-label' do - %i.icon-user - Assign to - .col-sm-10 - = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @merge_request.assignee_id) -   - = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' - .form-group - .merge-request-milestone - = f.label :milestone_id, class: 'control-label' do - %i.icon-time - Milestone - .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'}) - - .form-actions - if @merge_request.new_record? = f.submit 'Submit merge request', class: "btn btn-create" @@ -96,7 +83,3 @@ target_branch.on("change", function() { $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() }); }); - $('.assign-to-me-link').on('click', function(e){ - $('#merge_request_assignee_id').val("#{current_user.id}").trigger("change"); - e.preventDefault(); - }); -- cgit v1.2.1 From 5e985a7eed7317d4f0ed323c4f6f7d0f386fbde4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 24 Mar 2014 14:22:11 +0100 Subject: Use emoji assets on autocomplete. --- app/assets/javascripts/gfm_auto_complete.js.coffee | 3 +-- app/controllers/projects_controller.rb | 2 +- app/views/layouts/_init_auto_complete.html.haml | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee index dd12000a1cf..00d56ae5b4b 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.coffee +++ b/app/assets/javascripts/gfm_auto_complete.js.coffee @@ -6,7 +6,6 @@ GitLab.GfmAutoComplete = dataSource: '' # Emoji Emoji: - assetBase: '' template: '
  • ${name} ${name}
  • ' # Team Members @@ -27,7 +26,7 @@ GitLab.GfmAutoComplete = tpl: @Emoji.template callbacks: before_save: (emojis) => - $.map emojis, (em) => name: em, insert: em+ ':', image: "#{@Emoji.assetBase}/#{em}.png" + $.map emojis, (em) => name: em.name, insert: em.name+ ':', image: em.path # Team Members input.atwho diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8d24052f724..e181a0ec7fa 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -124,7 +124,7 @@ class ProjectsController < ApplicationController def autocomplete_sources @suggestions = { - emojis: Emoji.names, + emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, issues: @project.issues.select([:iid, :title, :description]), mergerequests: @project.merge_requests.select([:iid, :title, :description]), members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index fd6097dcc7b..9e728b462bb 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -1,4 +1,3 @@ :javascript GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" - GitLab.GfmAutoComplete.Emoji.assetBase = "#{Gitlab.config.gitlab.relative_url_root + Emoji.asset_path}" GitLab.GfmAutoComplete.setup(); -- cgit v1.2.1 From f9a69ab1da1f311e11f56b29ffe295598a754fe5 Mon Sep 17 00:00:00 2001 From: dosire Date: Mon, 24 Mar 2014 14:22:26 +0100 Subject: Inform people about the verify-none for webhooks. --- doc/web_hooks/web_hooks.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md index 64cce45945e..f80891e264d 100644 --- a/doc/web_hooks/web_hooks.md +++ b/doc/web_hooks/web_hooks.md @@ -5,6 +5,7 @@ Project web hooks allow you to trigger an URL if new code is pushed or a new iss You can configure web hook to listen for specific events like pushes, issues, merge requests. GitLab will send POST request with data to web hook URL. Web Hooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. +If you send a web hook to an SSL endpoint [the certificate will not be verified](https://gitlab.com/gitlab-org/gitlab-ce/blob/ccd617e58ea71c42b6b073e692447d0fe3c00be6/app/models/web_hook.rb#L35) since many people use self-signed certificates. --- -- cgit v1.2.1 From 842c0d6b5f7a60a4e4523fe1faefaab5038c96eb Mon Sep 17 00:00:00 2001 From: dosire Date: Mon, 24 Mar 2014 14:31:35 +0100 Subject: Can deeplink after all. --- doc/development/shell_commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/development/shell_commands.md b/doc/development/shell_commands.md index 63e58a63080..af0d5ca4426 100644 --- a/doc/development/shell_commands.md +++ b/doc/development/shell_commands.md @@ -4,7 +4,7 @@ - [Google Ruby Security Reviewer's Guide](https://code.google.com/p/ruby-security/wiki/Guide) - [OWASP Command Injection](https://www.owasp.org/index.php/Command_Injection) -- [Ruby on Rails Security Guide](http://guides.rubyonrails.org/security.html) section 7.7 +- [Ruby on Rails Security Guide Command Line Injection](http://guides.rubyonrails.org/security.html#command-line-injection) ## Use File and FileUtils instead of shell commands -- cgit v1.2.1 From 8af94ed75505f0253823b9b2d44320fecea5b5fb Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 24 Mar 2014 14:59:09 +0100 Subject: Add gzip compression for assets to nginx example. --- lib/support/nginx/gitlab | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab index 7a0f3efbb53..5bff362da0e 100644 --- a/lib/support/nginx/gitlab +++ b/lib/support/nginx/gitlab @@ -54,6 +54,14 @@ server { proxy_pass http://gitlab; } + # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression + location ~ ^/(assets)/ { + root /home/git/gitlab/public; + gzip_static on; # to serve pre-gzipped version + expires max; + add_header Cache-Control public; + } + error_page 502 /502.html; } -- cgit v1.2.1 From 65f5496e0210be96b4803f655d1a4c94ef1e07fe Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 24 Mar 2014 15:11:35 +0100 Subject: Fix the merge notification email not being sent The 'author_id_of_changes' attribute is not persisted in the database. As we retrieve the merge request from the DB just before sending the email, this attribute was always nil. Also there was no tests for the merge notification code - tests have been added. Fix #6605 --- app/mailers/emails/merge_requests.rb | 4 ++-- app/services/notification_service.rb | 2 +- spec/mailers/notify_spec.rb | 24 ++++++++++++++++++++++++ spec/services/notification_service_spec.rb | 6 +++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 5e1b8faf13e..a97d55f1b50 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -29,11 +29,11 @@ module Emails subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) end - def merged_merge_request_email(recipient_id, merge_request_id) + def merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id) @merge_request = MergeRequest.find(merge_request_id) @project = @merge_request.project @target_url = project_merge_request_url(@project, @merge_request) - mail(from: sender(@merge_request.author_id_of_changes), + mail(from: sender(updated_by_user_id), to: recipient(recipient_id), subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 5daf573630d..44fe9893e74 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -91,7 +91,7 @@ class NotificationService recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq recipients.each do |recipient| - mailer.merged_merge_request_email(recipient.id, merge_request.id) + mailer.merged_merge_request_email(recipient.id, merge_request.id, merge_request.author_id_of_changes) end end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index f990ed659b8..22d60429ccd 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -229,6 +229,7 @@ describe Notify do end context 'for merge requests' do + let(:merge_author) { create(:user) } let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) } let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: Faker::Lorem.sentence) } @@ -288,7 +289,30 @@ describe Notify do it 'contains a link to the merge request' do should have_body_text /#{project_merge_request_path project, merge_request}/ end + end + + describe 'that are merged' do + subject { Notify.merged_merge_request_email(recipient.id, merge_request.id, merge_author.id) } + + it_behaves_like 'a multiple recipients email' + + it 'is sent as the merge author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(merge_author.name) + sender.address.should eq(gitlab_sender) + end + + it 'has the correct subject' do + should have_subject /#{merge_request.title} \(!#{merge_request.iid}\)/ + end + it 'contains the new status' do + should have_body_text /merged/i + end + + it 'contains a link to the merge request' do + should have_body_text /#{project_merge_request_path project, merge_request}/ + end end end end diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 077ad8b6e12..59c17d6e4d7 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -233,15 +233,15 @@ describe NotificationService do should_email(@u_watcher.id) should_not_email(@u_participating.id) should_not_email(@u_disabled.id) - notification.merge_mr(merge_request) + notification.merge_mr(merge_request, @u_disabled) end def should_email(user_id) - Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id) + Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id) end def should_not_email(user_id) - Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id) + Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id) end end end -- cgit v1.2.1 From 3ef0a625ac656e64861df912492dc3b8febb66c3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Mar 2014 16:12:23 +0200 Subject: Applications js to coffee Signed-off-by: Dmitriy Zaporozhets --- app/assets/javascripts/application.js | 33 ------ app/assets/javascripts/application.js.coffee | 154 +++++++++++++++++++++++++++ app/assets/javascripts/main.js.coffee | 120 --------------------- 3 files changed, 154 insertions(+), 153 deletions(-) delete mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/application.js.coffee delete mode 100644 app/assets/javascripts/main.js.coffee diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index f69b750bb69..00000000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,33 +0,0 @@ -// This is a manifest file that'll be compiled into including all the files listed below. -// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically -// be included in the compiled file accessible from http://example.com/assets/application.js -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// the compiled file. -// -//= require jquery -//= require jquery.ui.all -//= require jquery_ujs -//= require jquery.cookie -//= require jquery.endless-scroll -//= require jquery.highlight -//= require jquery.history -//= require jquery.waitforimages -//= require jquery.atwho -//= require jquery.scrollto -//= require jquery.blockUI -//= require turbolinks -//= require jquery.turbolinks -//= require bootstrap -//= require modernizr -//= require select2 -//= require raphael -//= require g.raphael-min -//= require g.bar-min -//= require branch-graph -//= require highlightjs.min -//= require ace/ace -//= require_tree . -//= require d3 -//= require underscore -//= require nprogress -//= require nprogress-turbolinks diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee new file mode 100644 index 00000000000..5042221abe4 --- /dev/null +++ b/app/assets/javascripts/application.js.coffee @@ -0,0 +1,154 @@ +# This is a manifest file that'll be compiled into including all the files listed below. +# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +# be included in the compiled file accessible from http://example.com/assets/application.js +# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +# the compiled file. +# +#= require jquery +#= require jquery.ui.all +#= require jquery_ujs +#= require jquery.cookie +#= require jquery.endless-scroll +#= require jquery.highlight +#= require jquery.history +#= require jquery.waitforimages +#= require jquery.atwho +#= require jquery.scrollto +#= require jquery.blockUI +#= require turbolinks +#= require jquery.turbolinks +#= require bootstrap +#= require modernizr +#= require select2 +#= require raphael +#= require g.raphael-min +#= require g.bar-min +#= require branch-graph +#= require highlightjs.min +#= require ace/ace +#= require d3 +#= require underscore +#= require nprogress +#= require nprogress-turbolinks +#= require_tree . + +window.slugify = (text) -> + text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase() + +window.ajaxGet = (url) -> + $.ajax({type: "GET", url: url, dataType: "script"}) + +window.showAndHide = (selector) -> + +window.errorMessage = (message) -> + ehtml = $("

    ") + ehtml.addClass("error_message") + ehtml.html(message) + ehtml + +window.split = (val) -> + return val.split( /,\s*/ ) + +window.extractLast = (term) -> + return split( term ).pop() + +# Disable button if text field is empty +window.disableButtonIfEmptyField = (field_selector, button_selector) -> + field = $(field_selector) + closest_submit = field.closest("form").find(button_selector) + + closest_submit.disable() if field.val() is "" + + field.on "input", -> + if $(@).val() is "" + closest_submit.disable() + else + closest_submit.enable() + +window.sanitize = (str) -> + return str.replace(/<(?:.|\n)*?>/gm, '') + +window.linkify = (str) -> + exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig + return str.replace(exp,"$1") + +window.simpleFormat = (str) -> + linkify(sanitize(str).replace(/\n/g, '
    ')) + +window.unbindEvents = -> + $(document).unbind('scroll') + $(document).off('scroll') + +document.addEventListener("page:fetch", unbindEvents) + +$ -> + # Click a .one_click_select field, select the contents + $(".one_click_select").on 'click', -> $(@).select() + + $('.remove-row').bind 'ajax:success', -> + $(this).closest('li').fadeOut() + + # Initialize select2 selects + $('select.select2').select2(width: 'resolve', dropdownAutoWidth: true) + + # Initialize tooltips + $('.has_tooltip').tooltip() + + # Bottom tooltip + $('.has_bottom_tooltip').tooltip(placement: 'bottom') + + # Form submitter + $('.trigger-submit').on 'change', -> + $(@).parents('form').submit() + + $("abbr.timeago").timeago() + $('.js-timeago').timeago() + + # Flash + if (flash = $(".flash-container")).length > 0 + flash.click -> $(@).fadeOut() + flash.show() + setTimeout (-> flash.fadeOut()), 5000 + + # Disable form buttons while a form is submitting + $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> + buttons = $('[type="submit"]', @) + + switch e.type + when 'ajax:beforeSend', 'submit' + buttons.disable() + else + buttons.enable() + + # Show/Hide the profile menu when hovering the account box + $('.account-box').hover -> $(@).toggleClass('hover') + + # Focus search field by pressing 's' key + $(document).keypress (e) -> + # Don't do anything if typing in an input + return if $(e.target).is(":input") + + switch e.which + when 115 + $("#search").focus() + e.preventDefault() + when 63 + new Shortcuts() + e.preventDefault() + + + # Commit show suppressed diff + $(".diff-content").on "click", ".supp_diff_link", -> + $(@).next('table').show() + $(@).remove() + +(($) -> + # Disable an element and add the 'disabled' Bootstrap class + $.fn.extend disable: -> + $(@).attr('disabled', 'disabled').addClass('disabled') + + # Enable an element and remove the 'disabled' Bootstrap class + $.fn.extend enable: -> + $(@).removeAttr('disabled').removeClass('disabled') + +)(jQuery) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee deleted file mode 100644 index 89f6a547ff8..00000000000 --- a/app/assets/javascripts/main.js.coffee +++ /dev/null @@ -1,120 +0,0 @@ -window.slugify = (text) -> - text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase() - -window.ajaxGet = (url) -> - $.ajax({type: "GET", url: url, dataType: "script"}) - -window.showAndHide = (selector) -> - -window.errorMessage = (message) -> - ehtml = $("

    ") - ehtml.addClass("error_message") - ehtml.html(message) - ehtml - -window.split = (val) -> - return val.split( /,\s*/ ) - -window.extractLast = (term) -> - return split( term ).pop() - -# Disable button if text field is empty -window.disableButtonIfEmptyField = (field_selector, button_selector) -> - field = $(field_selector) - closest_submit = field.closest("form").find(button_selector) - - closest_submit.disable() if field.val() is "" - - field.on "input", -> - if $(@).val() is "" - closest_submit.disable() - else - closest_submit.enable() - -window.sanitize = (str) -> - return str.replace(/<(?:.|\n)*?>/gm, '') - -window.linkify = (str) -> - exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig - return str.replace(exp,"$1") - -window.simpleFormat = (str) -> - linkify(sanitize(str).replace(/\n/g, '
    ')) - -window.unbindEvents = -> - $(document).unbind('scroll') - $(document).off('scroll') - -document.addEventListener("page:fetch", unbindEvents) - -$ -> - # Click a .one_click_select field, select the contents - $(".one_click_select").on 'click', -> $(@).select() - - $('.remove-row').bind 'ajax:success', -> - $(this).closest('li').fadeOut() - - # Initialize select2 selects - $('select.select2').select2(width: 'resolve', dropdownAutoWidth: true) - - # Initialize tooltips - $('.has_tooltip').tooltip() - - # Bottom tooltip - $('.has_bottom_tooltip').tooltip(placement: 'bottom') - - # Form submitter - $('.trigger-submit').on 'change', -> - $(@).parents('form').submit() - - $("abbr.timeago").timeago() - $('.js-timeago').timeago() - - # Flash - if (flash = $(".flash-container")).length > 0 - flash.click -> $(@).fadeOut() - flash.show() - setTimeout (-> flash.fadeOut()), 5000 - - # Disable form buttons while a form is submitting - $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> - buttons = $('[type="submit"]', @) - - switch e.type - when 'ajax:beforeSend', 'submit' - buttons.disable() - else - buttons.enable() - - # Show/Hide the profile menu when hovering the account box - $('.account-box').hover -> $(@).toggleClass('hover') - - # Focus search field by pressing 's' key - $(document).keypress (e) -> - # Don't do anything if typing in an input - return if $(e.target).is(":input") - - switch e.which - when 115 - $("#search").focus() - e.preventDefault() - when 63 - new Shortcuts() - e.preventDefault() - - - # Commit show suppressed diff - $(".diff-content").on "click", ".supp_diff_link", -> - $(@).next('table').show() - $(@).remove() - -(($) -> - # Disable an element and add the 'disabled' Bootstrap class - $.fn.extend disable: -> - $(@).attr('disabled', 'disabled').addClass('disabled') - - # Enable an element and remove the 'disabled' Bootstrap class - $.fn.extend enable: -> - $(@).removeAttr('disabled').removeClass('disabled') - -)(jQuery) -- cgit v1.2.1 From 394737b2cb2ab82caa3b192ee4ae8fd17cb22cb9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Mar 2014 16:15:57 +0200 Subject: Use humanize instead of titleize for MR title suggestion Signed-off-by: Dmitriy Zaporozhets --- app/helpers/merge_requests_helper.rb | 2 +- app/views/projects/merge_requests/branch_from.js.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 1381b0220d6..ba25a87f392 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -20,7 +20,7 @@ module MergeRequestsHelper target_project_id: target_project.id, source_branch: event.branch_name, target_branch: target_project.repository.root_ref, - title: event.branch_name.titleize + title: event.branch_name.humanize } end diff --git a/app/views/projects/merge_requests/branch_from.js.haml b/app/views/projects/merge_requests/branch_from.js.haml index d3147188d1c..1b1082baafe 100644 --- a/app/views/projects/merge_requests/branch_from.js.haml +++ b/app/views/projects/merge_requests/branch_from.js.haml @@ -3,5 +3,5 @@ var mrTitle = $('#merge_request_title'); if(mrTitle.val().length == 0) { - mrTitle.val("#{params[:ref].titleize}"); + mrTitle.val("#{params[:ref].humanize}"); } -- cgit v1.2.1 From 369bd858d880dfdcadc75a87970c25c9c4d82a4a Mon Sep 17 00:00:00 2001 From: dosire Date: Mon, 24 Mar 2014 15:17:43 +0100 Subject: We should only specify unsafe version, never give advise since it it perishable. --- doc/update/4.2-to-5.0.md | 2 +- doc/update/5.0-to-5.1.md | 2 +- doc/update/5.1-to-5.2.md | 2 +- doc/update/5.1-to-5.4.md | 3 --- doc/update/5.1-to-6.0.md | 2 +- doc/update/5.2-to-5.3.md | 2 +- doc/update/5.3-to-5.4.md | 3 --- doc/update/5.4-to-6.0.md | 2 +- doc/update/6.0-to-6.1.md | 2 +- doc/update/6.1-to-6.2.md | 3 --- 10 files changed, 7 insertions(+), 16 deletions(-) diff --git a/doc/update/4.2-to-5.0.md b/doc/update/4.2-to-5.0.md index 5bf8c367734..f8fb607e016 100644 --- a/doc/update/4.2-to-5.0.md +++ b/doc/update/4.2-to-5.0.md @@ -1,7 +1,7 @@ # From 4.2 to 5.0 ## Warning -GitLab 5.0 is affected by critical security vulnerability CVE-2013-4490. Please update to GitLab 5.4 immediately. +GitLab 5.0 is affected by critical security vulnerability CVE-2013-4490. ## Important changes diff --git a/doc/update/5.0-to-5.1.md b/doc/update/5.0-to-5.1.md index 24d96e43bad..ba56507dd81 100644 --- a/doc/update/5.0-to-5.1.md +++ b/doc/update/5.0-to-5.1.md @@ -1,7 +1,7 @@ # From 5.0 to 5.1 ## Warning -GitLab 5.1 is affected by critical security vulnerability CVE-2013-4490. Please [update to GitLab 5.4 immediately](5.1-to-5.4.md). +GitLab 5.1 is affected by critical security vulnerability CVE-2013-4490. ## Release notes: diff --git a/doc/update/5.1-to-5.2.md b/doc/update/5.1-to-5.2.md index e4eaee91b8e..466c815195f 100644 --- a/doc/update/5.1-to-5.2.md +++ b/doc/update/5.1-to-5.2.md @@ -1,7 +1,7 @@ # From 5.1 to 5.2 ## Warning -GitLab 5.2 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. Please [update to GitLab 5.4 directly](5.1-to-5.4.md). +GitLab 5.2 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. ### 0. Backup diff --git a/doc/update/5.1-to-5.4.md b/doc/update/5.1-to-5.4.md index 39cacd381a3..56f4854daf0 100644 --- a/doc/update/5.1-to-5.4.md +++ b/doc/update/5.1-to-5.4.md @@ -1,9 +1,6 @@ # From 5.1 to 5.4 Also works starting from 5.2. -## Notice -Security vulnerabilities CVE-2013-4490 and CVE-2013-4489 have been patched in the latest version of GitLab 5.4. - ### 0. Backup It's useful to make a backup just in case things go south: diff --git a/doc/update/5.1-to-6.0.md b/doc/update/5.1-to-6.0.md index fa0f9ce54b6..5b74b1f893d 100644 --- a/doc/update/5.1-to-6.0.md +++ b/doc/update/5.1-to-6.0.md @@ -1,7 +1,7 @@ # From 5.1 to 6.0 ## Warning -GitLab 6.0 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. Please [update to GitLab 6.2 immediately](6.0-to-6.2.md). +GitLab 6.0 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. ### Deprecations diff --git a/doc/update/5.2-to-5.3.md b/doc/update/5.2-to-5.3.md index 7f89f6bf887..e3c3016db64 100644 --- a/doc/update/5.2-to-5.3.md +++ b/doc/update/5.2-to-5.3.md @@ -1,7 +1,7 @@ # From 5.2 to 5.3 ## Warning -GitLab 5.3 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. Please [update to GitLab 5.4 directly](5.1-to-5.4.md). +GitLab 5.3 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. ### 0. Backup diff --git a/doc/update/5.3-to-5.4.md b/doc/update/5.3-to-5.4.md index 7a24c11c223..213ce77ec38 100644 --- a/doc/update/5.3-to-5.4.md +++ b/doc/update/5.3-to-5.4.md @@ -1,8 +1,5 @@ # From 5.3 to 5.4 -## Notice -Security vulnerabilities CVE-2013-4490 and CVE-2013-4489 have been patched in the latest version of GitLab 5.4. - ### 0. Backup It's useful to make a backup just in case things go south: diff --git a/doc/update/5.4-to-6.0.md b/doc/update/5.4-to-6.0.md index 312e9a46080..c289fcb57fd 100644 --- a/doc/update/5.4-to-6.0.md +++ b/doc/update/5.4-to-6.0.md @@ -1,7 +1,7 @@ # From 5.4 to 6.0 ## Warning -GitLab 6.0 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. Please [update to GitLab 6.2 immediately](6.0-to-6.2.md). +GitLab 6.0 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. ### Deprecations diff --git a/doc/update/6.0-to-6.1.md b/doc/update/6.0-to-6.1.md index b7fd7634859..b4cc9203587 100644 --- a/doc/update/6.0-to-6.1.md +++ b/doc/update/6.0-to-6.1.md @@ -1,7 +1,7 @@ # From 6.0 to 6.1 ## Warning -GitLab 6.1 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. Please [update to GitLab 6.2 directly](6.0-to-6.2.md). +GitLab 6.1 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. # In 6.1 we remove a lot of deprecated code. # You should update to 6.0 before installing 6.1 so all the necessary conversions are run. diff --git a/doc/update/6.1-to-6.2.md b/doc/update/6.1-to-6.2.md index 3c453a5ab42..c618e599dcb 100644 --- a/doc/update/6.1-to-6.2.md +++ b/doc/update/6.1-to-6.2.md @@ -1,8 +1,5 @@ # From 6.1 to 6.2 -## Notice -Security vulnerabilities CVE-2013-4490 and CVE-2013-4489 have been patched in the latest version of GitLab 6.2. - # You should update to 6.1 before installing 6.2 so all the necessary conversions are run. ### 0. Backup -- cgit v1.2.1 From 775f686e0e6e126555910a32c5c400d24e90789e Mon Sep 17 00:00:00 2001 From: dosire Date: Mon, 24 Mar 2014 16:51:55 +0100 Subject: Prevent discussion about is it a bug or a feature request. --- PROCESS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PROCESS.md b/PROCESS.md index bf757025c40..7055b2af2ca 100644 --- a/PROCESS.md +++ b/PROCESS.md @@ -73,7 +73,7 @@ Thanks for the issue report. Please reformat your issue to conform to the issue ### Feature requests -Thanks for your interest in GitLab. We don't use the issue tracker for feature requests. Please use http://feedback.gitlab.com/ for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. +Thanks for your interest in GitLab. We don't use the issue tracker for feature requests. Things that are wrong but are not a regression compared to older versions of GitLab are considered feature requests and not issues. Please use http://feedback.gitlab.com/ for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. ### Issue report for old version -- cgit v1.2.1 From 842ad4a42590484ee12a9e76ffde90a300e9f3b8 Mon Sep 17 00:00:00 2001 From: George Dewar Date: Mon, 24 Mar 2014 16:13:01 +1300 Subject: Initial implementation --- app/assets/stylesheets/print.scss | 13 +++++++++++++ app/views/layouts/_head.html.haml | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/print.scss diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss new file mode 100644 index 00000000000..42dbf4d6ef3 --- /dev/null +++ b/app/assets/stylesheets/print.scss @@ -0,0 +1,13 @@ +/* Generic print styles */ +header, nav, nav.main-nav, nav.navbar-collapse, nav.navbar-collapse.collapse {display: none!important;} +.profiler-results {display: none;} + +/* Styles targeted specifically at printing files */ +.tree-ref-holder, .tree-holder .breadcrumb, .blob-commit-info {display: none;} +.file-title {display: none;} +.file-holder {border: none;} + +.wiki h1, .wiki h2, .wiki h3, .wiki h4, .wiki h5, .wiki h6 {margin-top: 17px; } +.wiki h1 {font-size: 30px;} +.wiki h2 {font-size: 22px;} +.wiki h3 {font-size: 18px; font-weight: bold; } diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 9ba20f1347d..d9a7a2d31cf 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -4,7 +4,8 @@ = "#{title} | " if defined?(title) GitLab = favicon_link_tag 'favicon.ico' - = stylesheet_link_tag "application" + = stylesheet_link_tag "application", :media => "all" + = stylesheet_link_tag "print", :media => "print" = javascript_include_tag "application" = csrf_meta_tags = include_gon -- cgit v1.2.1 From 7847e108631f739ed4278ee40118073bdda8250b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 12:05:37 +0200 Subject: Fix tests Signed-off-by: Dmitriy Zaporozhets --- features/steps/dashboard/dashboard.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 3526006c94a..394acd3fe8f 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -25,7 +25,7 @@ class Dashboard < Spinach::FeatureSteps find("#merge_request_target_project_id").value.should == @project.id.to_s find("#merge_request_source_branch").value.should == "new_design" find("#merge_request_target_branch").value.should == "master" - find("#merge_request_title").value.should == "New Design" + find("#merge_request_title").value.should == "New design" end Given 'user with name "John Doe" joined project "Shop"' do -- cgit v1.2.1 From 8bbac4576b7c75f47a3a940dc5fb6b1217a3c397 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 12:10:50 +0200 Subject: Simplify run tests command Signed-off-by: Dmitriy Zaporozhets --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 7d1dc09b4d6..7818d40ac55 100644 --- a/README.md +++ b/README.md @@ -96,14 +96,9 @@ or start each component separately ### Run the tests -* Seed the database - - bundle exec rake db:setup RAILS_ENV=test - bundle exec rake db:seed_fu RAILS_ENV=test - * Run all tests - bundle exec rake gitlab:test RAILS_ENV=test + bundle exec rake test * [RSpec](http://rspec.info/) unit and functional tests -- cgit v1.2.1 From 80daf9a7774fd757a8838f0b49b6384ec7ceb724 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 13:47:48 +0200 Subject: Use current_user for Notification#merge_mr Signed-off-by: Dmitriy Zaporozhets --- app/services/merge_requests/auto_merge_service.rb | 2 +- app/services/merge_requests/merge_service.rb | 2 +- app/services/notification_service.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/merge_requests/auto_merge_service.rb b/app/services/merge_requests/auto_merge_service.rb index d60d61ed54a..9c9117f4687 100644 --- a/app/services/merge_requests/auto_merge_service.rb +++ b/app/services/merge_requests/auto_merge_service.rb @@ -12,7 +12,7 @@ module MergeRequests merge_request.author_id_of_changes = current_user.id merge_request.merge - notification.merge_mr(merge_request) + notification.merge_mr(merge_request, current_user) create_merge_event(merge_request) execute_project_hooks(merge_request) diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 1d5af04cdbb..80487f661e0 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -10,7 +10,7 @@ module MergeRequests merge_request.author_id_of_changes = current_user.id merge_request.merge - notification.merge_mr(merge_request) + notification.merge_mr(merge_request, current_user) create_merge_event(merge_request) execute_project_hooks(merge_request) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 9edb7fd3e31..6fda9868aa5 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -86,12 +86,12 @@ class NotificationService # * merge_request assignee if their notification level is not Disabled # * project team members with notification level higher then Participating # - def merge_mr(merge_request) + def merge_mr(merge_request, current_user) recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project) recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq recipients.each do |recipient| - mailer.merged_merge_request_email(recipient.id, merge_request.id, merge_request.author_id_of_changes) + mailer.merged_merge_request_email(recipient.id, merge_request.id, current_user.id) end end -- cgit v1.2.1 From f08464c055420f9091512a3f9ec1dc2de960fbde Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 14:01:52 +0200 Subject: Remove author_id_of_changes from app Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects/issues_controller.rb | 2 +- app/controllers/projects/merge_requests_controller.rb | 2 +- app/controllers/projects/milestones_controller.rb | 3 +-- app/models/concerns/issuable.rb | 2 -- app/models/issue.rb | 3 +-- app/models/merge_request.rb | 2 +- app/models/milestone.rb | 5 ++--- app/observers/activity_observer.rb | 6 +----- app/services/merge_requests/auto_merge_service.rb | 3 +-- app/services/merge_requests/base_merge_service.rb | 4 ++-- app/services/merge_requests/merge_service.rb | 3 +-- 11 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 9d97c820f38..eef849d8209 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -76,7 +76,7 @@ class Projects::IssuesController < Projects::ApplicationController end def update - @issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id)) + @issue.update_attributes(params[:issue]) @issue.reset_events_cache respond_to do |format| diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 38e567f3b13..e6edceb1fbc 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -109,7 +109,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController params[:merge_request].delete(:source_project_id) params[:merge_request].delete(:target_project_id) - if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id)) + if @merge_request.update_attributes(params[:merge_request]) @merge_request.reset_events_cache respond_to do |format| diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index aea92a19f34..05237bbd2d2 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -38,7 +38,6 @@ class Projects::MilestonesController < Projects::ApplicationController def create @milestone = @project.milestones.new(params[:milestone]) - @milestone.author_id_of_changes = current_user.id if @milestone.save redirect_to project_milestone_path(@project, @milestone) @@ -48,7 +47,7 @@ class Projects::MilestonesController < Projects::ApplicationController end def update - @milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id)) + @milestone.update_attributes(params[:milestone]) respond_to do |format| format.js diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 75989888bfa..de167f8803a 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -37,8 +37,6 @@ module Issuable allow_nil: true, prefix: true - attr_accessor :author_id_of_changes - attr_mentionable :title, :description end diff --git a/app/models/issue.rb b/app/models/issue.rb index a8dc6e5fd85..21040327741 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -30,8 +30,7 @@ class Issue < ActiveRecord::Base scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } attr_accessible :title, :assignee_id, :position, :description, - :milestone_id, :label_list, :author_id_of_changes, - :state_event + :milestone_id, :label_list, :state_event acts_as_taggable_on :labels diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 7c2648d8c7a..5c2b0656d40 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -38,7 +38,7 @@ class MergeRequest < ActiveRecord::Base delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil - attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event, :description + attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :state_event, :description attr_accessor :should_remove_source_branch diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 1a73fa71e48..e16529a634c 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -16,8 +16,7 @@ class Milestone < ActiveRecord::Base include InternalId - attr_accessible :title, :description, :due_date, :state_event, :author_id_of_changes - attr_accessor :author_id_of_changes + attr_accessible :title, :description, :due_date, :state_event belongs_to :project has_many :issues @@ -89,6 +88,6 @@ class Milestone < ActiveRecord::Base end def author_id - author_id_of_changes + nil end end diff --git a/app/observers/activity_observer.rb b/app/observers/activity_observer.rb index d754ac8185a..c5420c275ae 100644 --- a/app/observers/activity_observer.rb +++ b/app/observers/activity_observer.rb @@ -2,8 +2,6 @@ class ActivityObserver < BaseObserver observe :issue, :note, :milestone def after_create(record) - event_author_id = record.author_id - if record.kind_of?(Note) # Skip system notes, like status changes and cross-references. return true if record.system? @@ -12,9 +10,7 @@ class ActivityObserver < BaseObserver return true if record.noteable_type.blank? end - if event_author_id - create_event(record, Event.determine_action(record)) - end + create_event(record, Event.determine_action(record)) if current_user end def after_close(record, transition) diff --git a/app/services/merge_requests/auto_merge_service.rb b/app/services/merge_requests/auto_merge_service.rb index 9c9117f4687..e35c03275f2 100644 --- a/app/services/merge_requests/auto_merge_service.rb +++ b/app/services/merge_requests/auto_merge_service.rb @@ -9,11 +9,10 @@ module MergeRequests merge_request.lock if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message) - merge_request.author_id_of_changes = current_user.id merge_request.merge notification.merge_mr(merge_request, current_user) - create_merge_event(merge_request) + create_merge_event(merge_request, current_user) execute_project_hooks(merge_request) true diff --git a/app/services/merge_requests/base_merge_service.rb b/app/services/merge_requests/base_merge_service.rb index dbdb0063074..d0f777d50ec 100644 --- a/app/services/merge_requests/base_merge_service.rb +++ b/app/services/merge_requests/base_merge_service.rb @@ -7,13 +7,13 @@ module MergeRequests NotificationService.new end - def create_merge_event(merge_request) + def create_merge_event(merge_request, current_user) Event.create( project: merge_request.target_project, target_id: merge_request.id, target_type: merge_request.class.name, action: Event::MERGED, - author_id: merge_request.author_id_of_changes + author_id: current_user.id ) end diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 80487f661e0..680766140bd 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -7,11 +7,10 @@ module MergeRequests # to target branch class MergeService < BaseMergeService def execute(merge_request, current_user, commit_message) - merge_request.author_id_of_changes = current_user.id merge_request.merge notification.merge_mr(merge_request, current_user) - create_merge_event(merge_request) + create_merge_event(merge_request, current_user) execute_project_hooks(merge_request) true -- cgit v1.2.1 From cce80d04fe0271709170222d3b5774c39203ea07 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 14:02:55 +0200 Subject: Remove author_id_of_changes from spec Signed-off-by: Dmitriy Zaporozhets --- spec/models/concerns/issuable_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 0827e4f162b..9cbc8990676 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -25,11 +25,6 @@ describe Issue, "Issuable" do it { described_class.should respond_to(:assigned) } end - it "has an :author_id_of_changes accessor" do - issue.should respond_to(:author_id_of_changes) - issue.should respond_to(:author_id_of_changes=) - end - describe ".search" do let!(:searchable_issue) { create(:issue, title: "Searchable issue") } -- cgit v1.2.1 From d89130b0974782824fb11d4e0cc0fd9b12fe7cab Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 14:48:02 +0200 Subject: Collect all event creation logic in one place called EventCreateService Signed-off-by: Dmitriy Zaporozhets --- app/services/event_create_service.rb | 56 ++++++++++++++++ spec/services/event_create_service_spec.rb | 103 +++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 app/services/event_create_service.rb create mode 100644 spec/services/event_create_service_spec.rb diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb new file mode 100644 index 00000000000..8ff4dad674c --- /dev/null +++ b/app/services/event_create_service.rb @@ -0,0 +1,56 @@ +# EventCreateService class +# +# Used for creating events feed on dashboard after certain user action +# +# Ex. +# EventCreateService.new.new_issue(issue, current_user) +# +class EventCreateService + def open_issue(issue, current_user) + create_event(issue, current_user, Event::CREATED) + end + + def close_issue(issue, current_user) + create_event(issue, current_user, Event::CLOSED) + end + + def reopen_issue(issue, current_user) + create_event(issue, current_user, Event::REOPENED) + end + + def open_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::CREATED) + end + + def close_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::CLOSED) + end + + def reopen_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::REOPENED) + end + + def merge_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::MERGED) + end + + def open_milestone(milestone, current_user) + create_event(milestone, current_user, Event::CREATED) + end + + def close_milestone(milestone, current_user) + create_event(milestone, current_user, Event::CLOSED) + end + + private + + def create_event(record, current_user, status) + Event.create( + project: record.project, + target_id: record.id, + target_type: record.class.name, + action: status, + author_id: current_user.id + ) + end +end diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb new file mode 100644 index 00000000000..713aa3e7e74 --- /dev/null +++ b/spec/services/event_create_service_spec.rb @@ -0,0 +1,103 @@ +require 'spec_helper' + +describe EventCreateService do + let(:service) { EventCreateService.new } + + describe 'Issues' do + describe :open_issue do + let(:issue) { create(:issue) } + + it { service.open_issue(issue, issue.author).should be_true } + + it "should create new event" do + expect { service.open_issue(issue, issue.author) }.to change { Event.count } + end + end + + describe :close_issue do + let(:issue) { create(:issue) } + + it { service.close_issue(issue, issue.author).should be_true } + + it "should create new event" do + expect { service.close_issue(issue, issue.author) }.to change { Event.count } + end + end + + describe :reopen_issue do + let(:issue) { create(:issue) } + + it { service.reopen_issue(issue, issue.author).should be_true } + + it "should create new event" do + expect { service.reopen_issue(issue, issue.author) }.to change { Event.count } + end + end + end + + describe 'Merge Requests' do + describe :open_mr do + let(:merge_request) { create(:merge_request) } + + it { service.open_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.open_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + + describe :close_mr do + let(:merge_request) { create(:merge_request) } + + it { service.close_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.close_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + + describe :merge_mr do + let(:merge_request) { create(:merge_request) } + + it { service.merge_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.merge_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + + describe :reopen_mr do + let(:merge_request) { create(:merge_request) } + + it { service.reopen_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.reopen_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + end + + describe 'Milestone' do + let(:user) { create :user } + + describe :open_milestone do + let(:milestone) { create(:milestone) } + + it { service.open_milestone(milestone, user).should be_true } + + it "should create new event" do + expect { service.open_milestone(milestone, user) }.to change { Event.count } + end + end + + describe :close_mr do + let(:milestone) { create(:milestone) } + + it { service.close_milestone(milestone, user).should be_true } + + it "should create new event" do + expect { service.close_milestone(milestone, user) }.to change { Event.count } + end + end + end +end -- cgit v1.2.1 From 12d081008da393a4e2d2c931b7898875e565d8d5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 15:07:16 +0200 Subject: Add milestone observer Signed-off-by: Dmitriy Zaporozhets --- app/observers/milestone_observer.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/observers/milestone_observer.rb diff --git a/app/observers/milestone_observer.rb b/app/observers/milestone_observer.rb new file mode 100644 index 00000000000..a1a62a99a8f --- /dev/null +++ b/app/observers/milestone_observer.rb @@ -0,0 +1,13 @@ +class MilestoneObserver < BaseObserver + def after_create(milestone) + event_service.open_milestone(milestone, current_user) + end + + def after_close(milestone, transition) + event_service.close_milestone(milestone, current_user) + end + + def after_reopen(milestone, transition) + event_service.reopen_milestone(milestone, current_user) + end +end -- cgit v1.2.1 From 6cc4ac7b98b0fb2ba028644fd8dc4e2d89b65e2a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 15:07:54 +0200 Subject: Drop activity observer. User EventCreateService instead Signed-off-by: Dmitriy Zaporozhets --- app/models/event.rb | 8 -------- app/observers/activity_observer.rb | 35 ----------------------------------- app/observers/base_observer.rb | 4 ++++ app/observers/issue_observer.rb | 3 +++ 4 files changed, 7 insertions(+), 43 deletions(-) delete mode 100644 app/observers/activity_observer.rb diff --git a/app/models/event.rb b/app/models/event.rb index d43d6eb682f..5c156856d79 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -47,14 +47,6 @@ class Event < ActiveRecord::Base scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } class << self - def determine_action(record) - if [Issue, MergeRequest].include? record.class - Event::CREATED - elsif record.kind_of? Note - Event::COMMENTED - end - end - def create_ref_event(project, user, ref, action = 'add', prefix = 'refs/heads') commit = project.repository.commit(ref.target) diff --git a/app/observers/activity_observer.rb b/app/observers/activity_observer.rb deleted file mode 100644 index c5420c275ae..00000000000 --- a/app/observers/activity_observer.rb +++ /dev/null @@ -1,35 +0,0 @@ -class ActivityObserver < BaseObserver - observe :issue, :note, :milestone - - def after_create(record) - if record.kind_of?(Note) - # Skip system notes, like status changes and cross-references. - return true if record.system? - - # Skip wall notes to prevent spamming of dashboard - return true if record.noteable_type.blank? - end - - create_event(record, Event.determine_action(record)) if current_user - end - - def after_close(record, transition) - create_event(record, Event::CLOSED) - end - - def after_reopen(record, transition) - create_event(record, Event::REOPENED) - end - - protected - - def create_event(record, status) - Event.create( - project: record.project, - target_id: record.id, - target_type: record.class.name, - action: status, - author_id: current_user.id - ) - end -end diff --git a/app/observers/base_observer.rb b/app/observers/base_observer.rb index f9a0242ce77..d685bd5d819 100644 --- a/app/observers/base_observer.rb +++ b/app/observers/base_observer.rb @@ -3,6 +3,10 @@ class BaseObserver < ActiveRecord::Observer NotificationService.new end + def event_service + EventCreateService.new + end + def log_info message Gitlab::AppLogger.info message end diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb index 6ef13eb5d5e..30da1f83da7 100644 --- a/app/observers/issue_observer.rb +++ b/app/observers/issue_observer.rb @@ -1,17 +1,20 @@ class IssueObserver < BaseObserver def after_create(issue) notification.new_issue(issue, current_user) + event_service.open_issue(issue, current_user) issue.create_cross_references!(issue.project, current_user) execute_hooks(issue) end def after_close(issue, transition) notification.close_issue(issue, current_user) + event_service.close_issue(issue, current_user) create_note(issue) execute_hooks(issue) end def after_reopen(issue, transition) + event_service.reopen_issue(issue, current_user) create_note(issue) execute_hooks(issue) end -- cgit v1.2.1 From ba87b76de1177574e26ad09ca97c30fde76d7a45 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 15:08:25 +0200 Subject: Use EventCreateService for notes, merge requests Signed-off-by: Dmitriy Zaporozhets --- app/observers/merge_request_observer.rb | 19 +++---------------- app/observers/note_observer.rb | 6 ++++++ app/services/event_create_service.rb | 8 ++++++++ app/services/merge_requests/base_merge_service.rb | 8 +------- config/application.rb | 2 +- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/app/observers/merge_request_observer.rb b/app/observers/merge_request_observer.rb index f2e2d16c943..dd8dcd4b409 100644 --- a/app/observers/merge_request_observer.rb +++ b/app/observers/merge_request_observer.rb @@ -2,24 +2,21 @@ class MergeRequestObserver < ActivityObserver observe :merge_request def after_create(merge_request) - if merge_request.author_id - create_event(merge_request, Event.determine_action(merge_request)) - end - + event_service.open_mr(merge_request, current_user) notification.new_merge_request(merge_request, current_user) merge_request.create_cross_references!(merge_request.project, current_user) execute_hooks(merge_request) end def after_close(merge_request, transition) - create_event(merge_request, Event::CLOSED) + event_service.close_mr(merge_request, current_user) notification.close_mr(merge_request, current_user) create_note(merge_request) execute_hooks(merge_request) end def after_reopen(merge_request, transition) - create_event(merge_request, Event::REOPENED) + event_service.reopen_mr(merge_request, current_user) create_note(merge_request) execute_hooks(merge_request) merge_request.reload_code @@ -33,16 +30,6 @@ class MergeRequestObserver < ActivityObserver execute_hooks(merge_request) end - def create_event(record, status) - Event.create( - project: record.target_project, - target_id: record.id, - target_type: record.class.name, - action: status, - author_id: current_user.id - ) - end - private # Create merge request note with service comment like 'Status changed to closed' diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb index d31b6e8d7ce..337bb1dc5ae 100644 --- a/app/observers/note_observer.rb +++ b/app/observers/note_observer.rb @@ -2,6 +2,12 @@ class NoteObserver < BaseObserver def after_create(note) notification.new_note(note) + # Skip system notes, like status changes and cross-references. + # Skip wall notes to prevent spamming of dashboard + if note.noteable_type.present? && !note.system + event_service.leave_note(note, current_user) + end + unless note.system? # Create a cross-reference note if this Note contains GFM that names an # issue, merge request, or commit. diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb index 8ff4dad674c..8d8a5873e62 100644 --- a/app/services/event_create_service.rb +++ b/app/services/event_create_service.rb @@ -42,6 +42,14 @@ class EventCreateService create_event(milestone, current_user, Event::CLOSED) end + def reopen_milestone(milestone, current_user) + create_event(milestone, current_user, Event::REOPENED) + end + + def leave_note(note, current_user) + create_event(note, current_user, Event::COMMENTED) + end + private def create_event(record, current_user, status) diff --git a/app/services/merge_requests/base_merge_service.rb b/app/services/merge_requests/base_merge_service.rb index d0f777d50ec..9bc50d3d16c 100644 --- a/app/services/merge_requests/base_merge_service.rb +++ b/app/services/merge_requests/base_merge_service.rb @@ -8,13 +8,7 @@ module MergeRequests end def create_merge_event(merge_request, current_user) - Event.create( - project: merge_request.target_project, - target_id: merge_request.id, - target_type: merge_request.class.name, - action: Event::MERGED, - author_id: current_user.id - ) + EventCreateService.new.merge_mr(merge_request, current_user) end def execute_project_hooks(merge_request) diff --git a/config/application.rb b/config/application.rb index 4d7c1415c8e..a782dd1d01e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,7 +19,7 @@ module Gitlab # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. - config.active_record.observers = :activity_observer, + config.active_record.observers = :milestone_observer, :project_activity_cache_observer, :issue_observer, :key_observer, -- cgit v1.2.1 From 45e6abffb422045dd30c3f1c74dd14186a23741d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 15:09:17 +0200 Subject: Remove activity observer specs Signed-off-by: Dmitriy Zaporozhets --- spec/observers/activity_observer_spec.rb | 61 -------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 spec/observers/activity_observer_spec.rb diff --git a/spec/observers/activity_observer_spec.rb b/spec/observers/activity_observer_spec.rb deleted file mode 100644 index dc14ab86b6d..00000000000 --- a/spec/observers/activity_observer_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe ActivityObserver do - let(:project) { create(:project) } - - before { Thread.current[:current_user] = create(:user) } - - def self.it_should_be_valid_event - it { @event.should_not be_nil } - it { @event.project.should == project } - end - - describe "Issue created" do - before do - Issue.observers.enable :activity_observer do - @issue = create(:issue, project: project) - @event = Event.last - end - end - - it_should_be_valid_event - it { @event.action.should == Event::CREATED } - it { @event.target.should == @issue } - end - - describe "Issue commented" do - before do - Note.observers.enable :activity_observer do - @issue = create(:issue, project: project) - @note = create(:note, noteable: @issue, project: project, author: @issue.author) - @event = Event.last - end - end - - it_should_be_valid_event - it { @event.action.should == Event::COMMENTED } - it { @event.target.should == @note } - end - - describe "Ignore system notes" do - let(:author) { create(:user) } - let!(:issue) { create(:issue, project: project) } - let!(:other) { create(:issue) } - - it "should not create events for status change notes" do - expect do - Note.observers.enable :activity_observer do - Note.create_status_change_note(issue, project, author, 'reopened', nil) - end - end.to_not change { Event.count } - end - - it "should not create events for cross-reference notes" do - expect do - Note.observers.enable :activity_observer do - Note.create_cross_reference_note(issue, other, author, issue.project) - end - end.to_not change { Event.count } - end - end -end -- cgit v1.2.1 From d4bfacc36524c79516435e34352e8dc15919a118 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 15:16:12 +0200 Subject: Fix MR observer Signed-off-by: Dmitriy Zaporozhets --- app/observers/merge_request_observer.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/observers/merge_request_observer.rb b/app/observers/merge_request_observer.rb index dd8dcd4b409..04ee30b4976 100644 --- a/app/observers/merge_request_observer.rb +++ b/app/observers/merge_request_observer.rb @@ -1,6 +1,4 @@ -class MergeRequestObserver < ActivityObserver - observe :merge_request - +class MergeRequestObserver < BaseObserver def after_create(merge_request) event_service.open_mr(merge_request, current_user) notification.new_merge_request(merge_request, current_user) -- cgit v1.2.1 From 535339a6ab756b0bfb1164afb764acef6e1f46af Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 16:25:59 +0200 Subject: Fix tests Signed-off-by: Dmitriy Zaporozhets --- spec/requests/api/issues_spec.rb | 12 ------------ spec/support/test_env.rb | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index c55025d72b5..e9422cd2643 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -100,16 +100,4 @@ describe API::API do response.status.should == 405 end end - - describe "PUT /projects/:id/issues/:issue_id to test observer on close" do - before { enable_observers } - after { disable_observers } - - it "should create an activity event when an issue is closed" do - Event.should_receive(:create) - - put api("/projects/#{project.id}/issues/#{issue.id}", user), - state_event: "close" - end - end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index d00decf6121..d237f7ad094 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -90,7 +90,7 @@ module TestEnv size: 12.45 ) - ActivityObserver.any_instance.stub( + BaseObserver.any_instance.stub( current_user: double("current_user", id: 1) ) end -- cgit v1.2.1 From c21c3e5707c4f6e28a3733153f2e898279e0730d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 19:32:49 +0200 Subject: Add bottom margin to highlighed code block in comment/wiki Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/generic/common.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/generic/common.scss b/app/assets/stylesheets/generic/common.scss index b5ccaed0401..4e660d0b1e0 100644 --- a/app/assets/stylesheets/generic/common.scss +++ b/app/assets/stylesheets/generic/common.scss @@ -355,3 +355,7 @@ table { @media (max-width: $screen-xs-max) { .container .content { margin-top: 20px; } } + +.wiki .highlight, .note-body .highlight { + margin-bottom: 9px; +} -- cgit v1.2.1 From 73a987ea6bedd569e24f37d323883a7dbeb3ae56 Mon Sep 17 00:00:00 2001 From: Nick Downs Date: Fri, 31 Jan 2014 21:14:05 -0800 Subject: Removed the backgrounding of the unicorn_rails webapp start call. --- lib/support/init.d/gitlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index ff584e69058..701db3e7d52 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -167,7 +167,7 @@ start() { # Remove old socket if it exists rm -f "$socket_path"/gitlab.socket 2>/dev/null # Start the web server - RAILS_ENV=$RAILS_ENV script/web start & + RAILS_ENV=$RAILS_ENV script/web start fi # If sidekiq is already running, don't start it again. -- cgit v1.2.1 From 01ec6c793c533306365319e3bf01174a976352d0 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 09:25:31 +0100 Subject: At mention participating users. --- app/controllers/projects_controller.rb | 3 ++- app/models/user.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e181a0ec7fa..aac9fcd555c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -123,11 +123,12 @@ class ProjectsController < ApplicationController end def autocomplete_sources + participating_users = @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + User.participating(@project.notes).select([:username, :name]).sort_by(&:username).map { |user| { username: user.username, name: user.name } } @suggestions = { emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, issues: @project.issues.select([:iid, :title, :description]), mergerequests: @project.merge_requests.select([:iid, :title, :description]), - members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + members: participating_users.uniq } respond_to do |format| diff --git a/app/models/user.rb b/app/models/user.rb index d9f420759d2..99ebf1527bf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -169,6 +169,7 @@ class User < ActiveRecord::Base scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') } scope :ldap, -> { where(provider: 'ldap') } + scope :participating, ->(notes){ where(id: notes.inc_author.map(&:author_id))} scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active } -- cgit v1.2.1 From 02850210b6694983bed0c3eb7ad8dedfc7d95c54 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 09:52:27 +0100 Subject: Allow referencing an existing user. --- lib/gitlab/markdown.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 80bb00821f7..1d3c6ac6eea 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -166,8 +166,8 @@ module Gitlab end def reference_user(identifier) - if member = @project.team_members.find { |user| user.username == identifier } - link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member + if user = User.find_by_username(identifier) + link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if user end end -- cgit v1.2.1 From eda2c0c607e4f12803d9021f9f2eacf56a4d2fcd Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 12:40:49 +0100 Subject: Include commits. --- app/controllers/projects_controller.rb | 25 +++++++++++++++++++++++-- app/views/layouts/_init_auto_complete.html.haml | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index aac9fcd555c..353d4f0c4b6 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -123,12 +123,21 @@ class ProjectsController < ApplicationController end def autocomplete_sources - participating_users = @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + User.participating(@project.notes).select([:username, :name]).sort_by(&:username).map { |user| { username: user.username, name: user.name } } + note_type = params['type'] + note_id = params['type_id'] + participating = if note_type && note_id + participants_in(note_type, note_id) + else + [] + end + team_members = @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + participants = team_members + participating + #participating = @project.issues.map { |issue| issue.participants.sort_by(&:username).map { |user| { username: user.username, name: user.name } } }.flatten @suggestions = { emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, issues: @project.issues.select([:iid, :title, :description]), mergerequests: @project.merge_requests.select([:iid, :title, :description]), - members: participating_users.uniq + members: participants.uniq } respond_to do |format| @@ -163,4 +172,16 @@ class ProjectsController < ApplicationController def user_layout current_user ? "projects" : "public_projects" end + + def participants_in(type, id) + note = case type + when "Issue", "MergeRequest" + type.constantize.find_by_iid(id) + when "Commits" + type.constantize.find(id) + else + [] + end + note.participants.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + end end diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index 9e728b462bb..353f7ce34f1 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -1,3 +1,3 @@ :javascript - GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" + GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project, type: @noteable.class, type_id: params[:id])}" GitLab.GfmAutoComplete.setup(); -- cgit v1.2.1 From 0a4283b50adb10c13cf2f00c83e372549a004a05 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 13:10:32 +0100 Subject: Extract sorting into a method. --- app/controllers/projects_controller.rb | 20 ++++++++++++-------- app/models/user.rb | 1 - 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 353d4f0c4b6..30196f9da3a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -130,14 +130,13 @@ class ProjectsController < ApplicationController else [] end - team_members = @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + team_members = sorted(@project.team.members) participants = team_members + participating - #participating = @project.issues.map { |issue| issue.participants.sort_by(&:username).map { |user| { username: user.username, name: user.name } } }.flatten @suggestions = { emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, issues: @project.issues.select([:iid, :title, :description]), mergerequests: @project.merge_requests.select([:iid, :title, :description]), - members: participants.uniq + members: participants } respond_to do |format| @@ -174,14 +173,19 @@ class ProjectsController < ApplicationController end def participants_in(type, id) - note = case type + users = case type when "Issue", "MergeRequest" - type.constantize.find_by_iid(id) - when "Commits" - type.constantize.find(id) + type.constantize.find_by_iid(id).participants + when "Commit" + author_ids = Note.for_commit_id(id).pluck(:author_id).uniq + User.where(id: author_ids) else [] end - note.participants.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + sorted(users) + end + + def sorted(users) + users.uniq.sort_by(&:username).map { |user| { username: user.username, name: user.name } } end end diff --git a/app/models/user.rb b/app/models/user.rb index 99ebf1527bf..d9f420759d2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -169,7 +169,6 @@ class User < ActiveRecord::Base scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') } scope :ldap, -> { where(provider: 'ldap') } - scope :participating, ->(notes){ where(id: notes.inc_author.map(&:author_id))} scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active } -- cgit v1.2.1 From 12c3962fc0741f4976688a9a15c5865b23414181 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 14:00:43 +0100 Subject: Search within project. --- app/controllers/projects_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 30196f9da3a..4afcedf3361 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -136,7 +136,7 @@ class ProjectsController < ApplicationController emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, issues: @project.issues.select([:iid, :title, :description]), mergerequests: @project.merge_requests.select([:iid, :title, :description]), - members: participants + members: participants.uniq } respond_to do |format| @@ -174,8 +174,10 @@ class ProjectsController < ApplicationController def participants_in(type, id) users = case type - when "Issue", "MergeRequest" - type.constantize.find_by_iid(id).participants + when "Issue" + @project.issues.find_by_iid(id).participants + when "MergeRequest" + @project.merge_requests.find_by_iid(id).participants when "Commit" author_ids = Note.for_commit_id(id).pluck(:author_id).uniq User.where(id: author_ids) -- cgit v1.2.1 From d26302215a81b3428ba121fe58be904ea1ac7b6e Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 17:25:16 +0100 Subject: Correct identation, default value if note doesn't exist. --- app/controllers/projects_controller.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 4afcedf3361..ebb8a90c630 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -126,10 +126,10 @@ class ProjectsController < ApplicationController note_type = params['type'] note_id = params['type_id'] participating = if note_type && note_id - participants_in(note_type, note_id) - else - [] - end + participants_in(note_type, note_id) + else + [] + end team_members = sorted(@project.team.members) participants = team_members + participating @suggestions = { @@ -174,16 +174,18 @@ class ProjectsController < ApplicationController def participants_in(type, id) users = case type - when "Issue" - @project.issues.find_by_iid(id).participants - when "MergeRequest" - @project.merge_requests.find_by_iid(id).participants - when "Commit" - author_ids = Note.for_commit_id(id).pluck(:author_id).uniq - User.where(id: author_ids) - else - [] - end + when "Issue" + issue = @project.issues.find_by_iid(id) + issue ? issue.participants : [] + when "MergeRequest" + merge_request = @project.merge_requests.find_by_iid(id) + merge_request ? merge_request.participants : [] + when "Commit" + author_ids = Note.for_commit_id(id).pluck(:author_id).uniq + User.where(id: author_ids) + else + [] + end sorted(users) end -- cgit v1.2.1 From 5245fac63b7ec7b4ad17c91e821350cff8e3bf04 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 23:11:01 +0200 Subject: Version 6.7.2 Signed-off-by: Dmitriy Zaporozhets Conflicts: CHANGELOG VERSION --- CHANGELOG | 6 ++++++ VERSION | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 441f36a5bde..75d88e2ce3f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +v6.7.2 + - Fix upgrader script + +v6.7.1 + - Fix GitLab CI integration + v 6.7.0 - Increased the example Nginx client_max_body_size from 5MB to 20MB, consider updating it manually on existing installations - Add support for Gemnasium as a Project Service (Olivier Gonzalez) diff --git a/VERSION b/VERSION index f0e13c50902..2dd517aa61c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.7.0 +6.7.2 -- cgit v1.2.1 From 9dd58c320a38cbcaf8134157103b2b2a2fad76d2 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 17:54:32 +0100 Subject: Add to changelog. --- CHANGELOG | 7 +++++-- lib/gitlab/markdown.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 75d88e2ce3f..2a025d6481e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,10 @@ -v6.7.2 +v 6.8.0 + - Ability to at mention users that are participating in issue and merge req. discussion + +v 6.7.2 - Fix upgrader script -v6.7.1 +v 6.7.1 - Fix GitLab CI integration v 6.7.0 diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 1d3c6ac6eea..de14a3eca27 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -167,7 +167,7 @@ module Gitlab def reference_user(identifier) if user = User.find_by_username(identifier) - link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if user + link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) end end -- cgit v1.2.1 From e421772f8935b9bdce02b6f552593f8dabca9074 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 19:53:30 +0200 Subject: Revert "Clearfix on well-lists. Pages affected:" Because it adds extra spaces at each project row on dashboard This reverts commit 2767abd90d94b3fd0fedfad85015abbffd7e4cd9. --- app/assets/stylesheets/generic/lists.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/assets/stylesheets/generic/lists.scss b/app/assets/stylesheets/generic/lists.scss index 8a6d7f68175..de70e47333f 100644 --- a/app/assets/stylesheets/generic/lists.scss +++ b/app/assets/stylesheets/generic/lists.scss @@ -13,12 +13,6 @@ border-bottom: 1px solid #eee; border-bottom: 1px solid rgba(0, 0, 0, 0.05); - &:after { - content: " "; - display: table; - clear: both; - } - &.disabled { color: #888; } -- cgit v1.2.1 From 7f67e066dc9749d2532d220fafa3f397a5fe1f24 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Mar 2014 20:10:08 +0200 Subject: More compact event feed and projects list Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/sections/dashboard.scss | 2 +- app/assets/stylesheets/sections/events.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index 6fc394e2e2b..e088ef82203 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -61,7 +61,7 @@ } .project-row, .group-row { - padding: 10px 12px !important; + padding: 8px 12px !important; font-size: 14px; line-height: 24px; diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 6ef12b20a5a..fe7ab426e8d 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -42,7 +42,7 @@ } } - padding: 14px 0px; + padding: 12px 0px; border-bottom: 1px solid #eee; .event-title { color: #333; -- cgit v1.2.1 From 74f16902cfdf9e75f187afda3cb58127b590a3db Mon Sep 17 00:00:00 2001 From: dosire Date: Tue, 25 Mar 2014 20:57:58 +0100 Subject: More strict wording of the bug criteria. --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d816f8e72a0..d864df14868 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,8 +24,8 @@ Issues and merge requests should be in English and contain appropriate language To get support for your particular problem please use the channels as detailed in the [getting help section of the readme](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/README.md#getting-help). Professional [support subscriptions](http://www.gitlab.com/subscription/) and [consulting services](http://www.gitlab.com/consultancy/) are available from [GitLab.com](http://www.gitlab.com/). -The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious bugs in the latest [stable or development release of GitLab](MAINTENANCE.md). -If something is missing but it is not a regression compared to older versions of GitLab please do not open an issue but a feature request. +The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious errors in the latest [stable or development release of GitLab](MAINTENANCE.md). +If something is wrong but it is not a regression compared to older versions of GitLab please do not open an issue but a feature request. When submitting an issue please conform to the issue submission guidelines listed below. Not all issues will be addressed and your issue is more likely to be addressed if you submit a merge request which partially or fully addresses the issue. -- cgit v1.2.1 From 5bda665d74fe5fdb08980d3ab04822e578f6aa57 Mon Sep 17 00:00:00 2001 From: dosire Date: Tue, 25 Mar 2014 21:35:08 +0100 Subject: Nice trick for css class check mentioned by Dmitriy. --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d864df14868..b5fc2d59c9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,6 +67,7 @@ If you can, please submit a merge request with the fix or improvements including 1. The MR title should describes the change you want to make 1. The MR description should give a motive for your change and the method you used to achieve it 1. If the MR changes the UI it should include before and after screenshots +1. If the MR changes CSS classes please include the list of affected pages `grep css-class ./app -R` 1. Link relevant [issues](https://gitlab.com/gitlab-org/gitlab-ce/issues) and/or [feature requests](http://feedback.gitlab.com/) from the merge request description and leave a comment on them with a link back to the MR 1. Be prepared to answer questions and incorporate feedback even if requests for this arrive weeks or months after your MR submittion 1. If your MR touches code that executes shell commands, make sure it adheres to the [shell command guidelines]( doc/development/shell_commands.md). -- cgit v1.2.1 From af0b59d477f7a9c314e17d3ceaf994f9cf5c4655 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Mar 2014 09:50:18 +0200 Subject: Time for 6.8.0pre Signed-off-by: Dmitriy Zaporozhets --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2dd517aa61c..38f2fa89925 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.7.2 +6.8.0.pre -- cgit v1.2.1 From 0a05c8dd8d648f5cc58508b70e0aff3d6a67ff32 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Mar 2014 10:45:22 +0200 Subject: Improve md typography Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/generic/typography.scss | 3 --- app/assets/stylesheets/main/mixins.scss | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/generic/typography.scss b/app/assets/stylesheets/generic/typography.scss index bca0b12ab62..a4419551738 100644 --- a/app/assets/stylesheets/generic/typography.scss +++ b/app/assets/stylesheets/generic/typography.scss @@ -88,9 +88,6 @@ a:focus { .wiki { @include md-typography; - font-size: 14px; - line-height: 1.6; - /* Link to current header. */ h1, h2, h3, h4, h5, h6 { position: relative; diff --git a/app/assets/stylesheets/main/mixins.scss b/app/assets/stylesheets/main/mixins.scss index 4afe61d756c..fcc7374d0d9 100644 --- a/app/assets/stylesheets/main/mixins.scss +++ b/app/assets/stylesheets/main/mixins.scss @@ -84,6 +84,9 @@ } @mixin md-typography { + font-size: 14px; + line-height: 1.6; + img { max-width: 100%; } -- cgit v1.2.1 From acb03f1fc3e7080f3eeaaaef720d33e6951ffa1b Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 09:46:51 +0100 Subject: Add gzip asset compression to the changelog. --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 2a025d6481e..0b295e4d759 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ v 6.8.0 - Ability to at mention users that are participating in issue and merge req. discussion + - Enabled GZip Compression for assets in example Nginx, make sure that Nginx is compiled with --with-http_gzip_static_module flag (this is default in Ubuntu) v 6.7.2 - Fix upgrader script -- cgit v1.2.1 From 92ca779ebcfaebd01b2b107478b8f77896b14587 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Mar 2014 10:55:04 +0200 Subject: Improve comment header Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/sections/notes.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/sections/notes.scss b/app/assets/stylesheets/sections/notes.scss index a65771974c6..4d7a873a519 100644 --- a/app/assets/stylesheets/sections/notes.scss +++ b/app/assets/stylesheets/sections/notes.scss @@ -27,11 +27,15 @@ ul.notes { .discussion-last-update, .note-last-update { - font-style: italic; + &:before { + content: "\00b7"; + } + font-size: 13px; } .author { - color: $style_color; + color: #555; font-weight: bold; + font-size: 14px; &:hover { color: $primary_color; } -- cgit v1.2.1 From c818712dfa0be11efd13c7e9ccac7dd7045e67d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Mar 2014 11:13:06 +0200 Subject: Reduce comments font size for events feed Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/sections/events.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index fe7ab426e8d..b68f882220e 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -63,6 +63,10 @@ color: #666; margin-top: 5px; + .md { + font-size: 13px; + } + pre { border: none; background: #f9f9f9; -- cgit v1.2.1 From 9422b451eb622196036ec3429bb61ac9a7078c2a Mon Sep 17 00:00:00 2001 From: Pawel Krzaczkowski Date: Thu, 19 Dec 2013 10:52:29 +0100 Subject: Init script - change start() stop() restart() reload() to xxxx_gitlab() --- lib/support/init.d/gitlab | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index ff584e69058..0308181b86b 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -149,7 +149,7 @@ exit_if_not_running(){ } ## Starts Unicorn and Sidekiq if they're not running. -start() { +start_gitlab() { check_stale_pids if [ "$web_status" != "0" -a "$sidekiq_status" != "0" ]; then @@ -184,7 +184,7 @@ start() { } ## Asks the Unicorn and the Sidekiq if they would be so kind as to stop, if not kills them. -stop() { +stop_gitlab() { exit_if_not_running if [ "$web_status" = "0" -a "$sidekiq_status" = "0" ]; then @@ -246,7 +246,7 @@ print_status() { } ## Tells unicorn to reload it's config and Sidekiq to restart -reload(){ +reload_gitlab(){ exit_if_not_running if [ "$wpid" = "0" ];then echo "The GitLab Unicorn Web server is not running thus its configuration can't be reloaded." @@ -263,12 +263,12 @@ reload(){ } ## Restarts Sidekiq and Unicorn. -restart(){ +restart_gitlab(){ check_status if [ "$web_status" = "0" -o "$sidekiq_status" = "0" ]; then - stop + stop_gitlab fi - start + start_gitlab } @@ -276,16 +276,16 @@ restart(){ case "$1" in start) - start + start_gitlab ;; stop) - stop + stop_gitlab ;; restart) - restart + restart_gitlab ;; reload|force-reload) - reload + reload_gitlab ;; status) print_status -- cgit v1.2.1 From d21ad74146c6f490bd2a19ccf359c357fa3b7a81 Mon Sep 17 00:00:00 2001 From: Andrea Usuelli Date: Wed, 26 Mar 2014 10:58:51 +0100 Subject: Changed the notification sender username to GitLab in Slack Notifier --- app/models/project_services/slack_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 754fd87db02..410dda22d47 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -52,6 +52,7 @@ class SlackService < Service notifier = Slack::Notifier.new(subdomain, token) notifier.channel = room + notifier.username = 'GitLab' notifier.ping(message.compose) end -- cgit v1.2.1 From 961d87937b55535ff3ffd041dbc78af82d644daa Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 12:44:00 +0100 Subject: Add the tests for user search. --- spec/models/user_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index fd8d7133ae9..cb0bf9ba517 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -292,6 +292,18 @@ describe User do end end + describe 'search' do + let(:user1) { create(:user, username: 'James', email: 'james@testing.com') } + let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') } + + it "should be case insensitive" do + User.search(user1.username.upcase).to_a.should == [user1] + User.search(user1.username.downcase).to_a.should == [user1] + User.search(user2.username.upcase).to_a.should == [user2] + User.search(user2.username.downcase).to_a.should == [user2] + end + end + describe 'by_username_or_id' do let(:user1) { create(:user, username: 'foo') } -- cgit v1.2.1 From 1aabfcb92d41f690e6756a7f057e85f17e30a0db Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 12:45:39 +0100 Subject: Change the user search query to be case insensitive. --- CHANGELOG | 1 + app/models/user.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0b295e4d759..06d19df7a32 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ v 6.8.0 - Ability to at mention users that are participating in issue and merge req. discussion - Enabled GZip Compression for assets in example Nginx, make sure that Nginx is compiled with --with-http_gzip_static_module flag (this is default in Ubuntu) + - Make user search case-insensitive (Christopher Arnold) v 6.7.2 - Fix upgrader script diff --git a/app/models/user.rb b/app/models/user.rb index d9f420759d2..25c10a6faa0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -204,7 +204,7 @@ class User < ActiveRecord::Base end def search query - where("name LIKE :query OR email LIKE :query OR username LIKE :query", query: "%#{query}%") + where("lower(name) LIKE :query OR lower(email) LIKE :query OR lower(username) LIKE :query", query: "%#{query.downcase}%") end def by_username_or_id(name_or_id) -- cgit v1.2.1 From 466203eb0c386b4b64512dc44cf7efa6221718df Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 12:56:25 +0100 Subject: Additional check in the test. --- spec/models/user_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index cb0bf9ba517..fef6314f23a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -301,6 +301,8 @@ describe User do User.search(user1.username.downcase).to_a.should == [user1] User.search(user2.username.upcase).to_a.should == [user2] User.search(user2.username.downcase).to_a.should == [user2] + User.search(user1.username.downcase).to_a.count.should == 2 + User.search(user2.username.downcase).to_a.count.should == 1 end end -- cgit v1.2.1 From 043c9f8640b558f2d46b9d64a498ab47f0c0700a Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 13:51:28 +0100 Subject: Change Diff to Changes in views. --- app/views/notify/repository_push_email.html.haml | 6 +++--- app/views/notify/repository_push_email.text.haml | 4 ++-- app/views/projects/commits/_text_file.html.haml | 2 +- app/views/projects/compare/show.html.haml | 8 ++++---- app/views/projects/merge_requests/_show.html.haml | 2 +- app/views/projects/merge_requests/show/_diffs.html.haml | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/notify/repository_push_email.html.haml b/app/views/notify/repository_push_email.html.haml index ab0d6c653b9..85a01a567f3 100644 --- a/app/views/notify/repository_push_email.html.haml +++ b/app/views/notify/repository_push_email.html.haml @@ -7,7 +7,7 @@ %li #{commit.short_id} - #{commit.title} -%h4 Diff: +%h4 Changes: - @diffs.each do |diff| %li %strong @@ -23,6 +23,6 @@ %br - if @compare.timeout - %h5 Huge diff. To prevent performance issues it was hidden + %h5 To prevent performance issues changes are hidden - elsif @compare.commits_over_limit? - %h5 Diff for big amount of commits is disabled + %h5 Changes are not shown due to large amount of commits diff --git a/app/views/notify/repository_push_email.text.haml b/app/views/notify/repository_push_email.text.haml index 93b344d2c82..b8d7fbeb046 100644 --- a/app/views/notify/repository_push_email.text.haml +++ b/app/views/notify/repository_push_email.text.haml @@ -6,7 +6,7 @@ Commits: #{commit.short_id} - #{truncate(commit.title, length: 40)} \ \ -Diff: +Changes: - @diffs.each do |diff| \ \===================================== @@ -22,4 +22,4 @@ Diff: - if @compare.timeout Huge diff. To prevent performance issues it was hidden - elsif @compare.commits_over_limit? - Diff for big amount of commits is disabled + Changes are not shown due to large amount of commits diff --git a/app/views/projects/commits/_text_file.html.haml b/app/views/projects/commits/_text_file.html.haml index c827d96d855..ba83d2e5a0f 100644 --- a/app/views/projects/commits/_text_file.html.haml +++ b/app/views/projects/commits/_text_file.html.haml @@ -1,6 +1,6 @@ - too_big = diff.diff.lines.count > 1000 - if too_big - %a.supp_diff_link Diff suppressed. Click to show + %a.supp_diff_link Changes suppressed. Click to show %table.text-file{class: "#{'hide' if too_big}"} - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line| diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index 9bd49855369..57331bff31b 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -18,17 +18,17 @@ - else %ul.well-list= render Commit.decorate(@commits), project: @project - %h4 Diff + %h4 Changes - if @diffs.present? = render "projects/commits/diffs", diffs: @diffs, project: @project - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE .bs-callout.bs-callout-danger %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. - %p To preserve performance the line diff is not shown. + %p To preserve performance the line changes are not shown. - elsif @timeout .bs-callout.bs-callout-danger - %h4 Diff for this comparison is extremely large. - %p Use command line to browse diff for this comparison. + %h4 Number of changed files for this comparison is extremely large. + %p Use command line to browse through changes for this comparison. - else diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml index 809b01918cf..7a21c0dd069 100644 --- a/app/views/projects/merge_requests/_show.html.haml +++ b/app/views/projects/merge_requests/_show.html.haml @@ -20,7 +20,7 @@ %li.diffs-tab{data: {action: 'diffs'}} = link_to diffs_project_merge_request_path(@project, @merge_request) do %i.icon-list-alt - Diff + Changes - content_for :note_actions do - if can?(current_user, :modify_merge_request, @merge_request) diff --git a/app/views/projects/merge_requests/show/_diffs.html.haml b/app/views/projects/merge_requests/show/_diffs.html.haml index 7c4f43d2d80..3d48514f98b 100644 --- a/app/views/projects/merge_requests/show/_diffs.html.haml +++ b/app/views/projects/merge_requests/show/_diffs.html.haml @@ -5,7 +5,7 @@ - else .bs-callout.bs-callout-warning %h4 - Diff for this comparison is extremely large. + Changes view for this comparison is extremely large. %p You can = link_to "download it", project_merge_request_path(@merge_request.source_project, @merge_request, format: :diff), class: "vlink" -- cgit v1.2.1 From 7bf92b368fae70c835c729515f9dac1fb766c185 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 15:38:14 +0100 Subject: Ldap check recognize ldap user filter. --- lib/tasks/gitlab/check.rake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 071760c0c36..3b9b2531bf7 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -677,7 +677,20 @@ namespace :gitlab do end def filter - Net::LDAP::Filter.present?(ldap_config.uid) + uid_filter = Net::LDAP::Filter.present?(ldap_config.uid) + if user_filter + Net::LDAP::Filter.join(uid_filter, user_filter) + else + uid_filter + end + end + + def user_filter + if ldap_config['user_filter'] && ldap_config.user_filter.present? + Net::LDAP::Filter.construct(ldap_config.user_filter) + else + nil + end end def ldap -- cgit v1.2.1 From 83f811fff5f6b2188c82f187f747122d2f7cd936 Mon Sep 17 00:00:00 2001 From: George Dewar Date: Fri, 21 Mar 2014 17:05:46 +1300 Subject: Refactor Parallel Diff feature and add scrollbars Also now removed lines relating to unused comments feature --- app/assets/stylesheets/sections/diff.scss | 25 ++++- app/helpers/commits_helper.rb | 76 +++++++++++++- app/models/diff_line.rb | 3 + .../projects/commits/_parallel_view.html.haml | 114 +++++++++------------ 4 files changed, 147 insertions(+), 71 deletions(-) create mode 100644 app/models/diff_line.rb diff --git a/app/assets/stylesheets/sections/diff.scss b/app/assets/stylesheets/sections/diff.scss index 813566c4def..eb272f20f40 100644 --- a/app/assets/stylesheets/sections/diff.scss +++ b/app/assets/stylesheets/sections/diff.scss @@ -62,6 +62,29 @@ font-size: 12px; } } + + .text-file-parallel div { + display: inline-block; + padding-bottom: 16px; + } + .diff-side { + overflow-x: scroll; + width: 508px; + height: 700px; + } + .diff-side.diff-side-left{ + overflow-y:hidden; + } + .diff-side table, td.diff-middle table { + height: 700px; + } + .diff-middle { + width: 114px; + vertical-align: top; + height: 700px; + overflow: hidden + } + .old_line, .new_line, .diff_line { margin: 0px; padding: 0px; @@ -125,8 +148,6 @@ } &.parallel { display: table-cell; - overflow: hidden; - width: 50%; } } } diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 5e5f3f77a21..c6e4f574b67 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -105,8 +105,80 @@ module CommitsHelper branches.sort.map { |branch| link_to(branch, project_tree_path(project, branch)) }.join(", ").html_safe end - def get_old_file(project, commit, diff) - project.repository.blob_at(commit.parent_id, diff.old_path) if commit.parent_id + def parallel_diff_lines(project, commit, diff, file) + old_file = project.repository.blob_at(commit.parent_id, diff.old_path) if commit.parent_id + deleted_lines = {} + added_lines = {} + each_diff_line(diff, 0) do |line, type, line_code, line_new, line_old| + if type == "old" + deleted_lines[line_old] = { line_code: line_code, type: type, line: line } + elsif type == "new" + added_lines[line_new] = { line_code: line_code, type: type, line: line } + end + end + max_length = old_file ? old_file.sloc + added_lines.length : file.sloc + + offset1 = 0 + offset2 = 0 + old_lines = [] + new_lines = [] + + max_length.times do |line_index| + line_index1 = line_index - offset1 + line_index2 = line_index - offset2 + deleted_line = deleted_lines[line_index1 + 1] + added_line = added_lines[line_index2 + 1] + old_line = old_file.lines[line_index1] if old_file + new_line = file.lines[line_index2] + + if deleted_line && added_line + elsif deleted_line + new_line = nil + offset2 += 1 + elsif added_line + old_line = nil + offset1 += 1 + end + + old_lines[line_index] = DiffLine.new + new_lines[line_index] = DiffLine.new + + # old + if line_index == 0 && diff.new_file + old_lines[line_index].type = :file_created + old_lines[line_index].content = 'File was created' + elsif deleted_line + old_lines[line_index].type = :deleted + old_lines[line_index].content = old_line + old_lines[line_index].num = line_index1 + 1 + old_lines[line_index].code = deleted_line[:line_code] + elsif old_line + old_lines[line_index].type = :no_change + old_lines[line_index].content = old_line + old_lines[line_index].num = line_index1 + 1 + else + old_lines[line_index].type = :added + end + + # new + if line_index == 0 && diff.deleted_file + new_lines[line_index].type = :file_deleted + new_lines[line_index].content = "File was deleted" + elsif added_line + new_lines[line_index].type = :added + new_lines[line_index].num = line_index2 + 1 + new_lines[line_index].content = new_line + new_lines[line_index].code = added_line[:line_code] + elsif new_line + new_lines[line_index].type = :no_change + new_lines[line_index].num = line_index2 + 1 + new_lines[line_index].content = new_line + else + new_lines[line_index].type = :deleted + end + end + + return old_lines, new_lines end protected diff --git a/app/models/diff_line.rb b/app/models/diff_line.rb new file mode 100644 index 00000000000..ad37945874a --- /dev/null +++ b/app/models/diff_line.rb @@ -0,0 +1,3 @@ +class DiffLine + attr_accessor :type, :content, :num, :code +end diff --git a/app/views/projects/commits/_parallel_view.html.haml b/app/views/projects/commits/_parallel_view.html.haml index 3234e9da0ac..5b60ab80ba4 100644 --- a/app/views/projects/commits/_parallel_view.html.haml +++ b/app/views/projects/commits/_parallel_view.html.haml @@ -1,75 +1,55 @@ / Side-by-side diff view -- old_file = get_old_file(project, @commit, diff) -- deleted_lines = {} -- added_lines = {} -- each_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line| - - if type == "old" - - deleted_lines[line_old] = { line_code: line_code, type: type, line: line } - - elsif type == "new" - - added_lines[line_new] = { line_code: line_code, type: type, line: line } - -- max_length = old_file.sloc + added_lines.length if old_file -- max_length ||= file.sloc -- offset1 = 0 -- offset2 = 0 +- old_lines, new_lines = parallel_diff_lines(project, @commit, diff, file) +- num_lines = old_lines.length %div.text-file-parallel - %table{ style: "table-layout: fixed;" } - - max_length.times do |line_index| - - line_index1 = line_index - offset1 - - line_index2 = line_index - offset2 - - deleted_line = deleted_lines[line_index1 + 1] - - added_line = added_lines[line_index2 + 1] - - old_line = old_file.lines[line_index1] if old_file - - new_line = file.lines[line_index2] + %div.diff-side.diff-side-left + %table + - old_lines.each do |line| + + %tr.line_holder.parallel + - if line.type == :file_created + %td.line_content.parallel= "File was created" + - elsif line.type == :deleted + %td.line_content{class: "parallel noteable_line old #{line.code}", "line_code" => line.code }= line.content + - else line.type == :no_change + %td.line_content.parallel= line.content + + %div.diff-middle + %table + - num_lines.times do |index| + %tr + - if old_lines[index].type == :deleted + %td.old_line.old= old_lines[index].num + - else + %td.old_line= old_lines[index].num + + %td.diff_line="" - - if deleted_line && added_line - - elsif deleted_line - - new_line = nil - - offset2 += 1 - - elsif added_line - - old_line = nil - - offset1 += 1 + - if new_lines[index].type == :added + %td.new_line.new= new_lines[index].num + - else + %td.new_line= new_lines[index].num - %tr.line_holder.parallel - - if line_index == 0 && diff.new_file - %td.line_content.parallel= "File was created" - %td.old_line= "" - - elsif deleted_line - %td.line_content{class: "parallel noteable_line old #{deleted_line[:line_code]}", "line_code" => deleted_line[:line_code] }= old_line - %td.old_line.old - = line_index1 + 1 - - if @comments_allowed - =# render "projects/notes/diff_note_link", line_code: deleted_line[:line_code] - - elsif old_line - %td.line_content.parallel= old_line - %td.old_line= line_index1 + 1 - - else - %td.line_content.parallel= "" - %td.old_line= "" + %div.diff-side.diff-side-right + %table + - new_lines.each do |line| - %td.diff_line= "" + %tr.line_holder.parallel + - if line.type == :file_deleted + %td.line_content.parallel= "File was deleted" + - elsif line.type == :added + %td.line_content{class: "parallel noteable_line new #{line.code}", "line_code" => line.code }= line.content + - else line.type == :no_change + %td.line_content.parallel= line.content - - if diff.deleted_file && line_index == 0 - %td.new_line= "" - %td.line_content.parallel= "File was deleted" - - elsif added_line - %td.new_line.new - = line_index2 + 1 - - if @comments_allowed - =# render "projects/notes/diff_note_link", line_code: added_line[:line_code] - %td.line_content{class: "parallel noteable_line new #{added_line[:line_code]}", "line_code" => added_line[:line_code] }= new_line - - elsif new_line - %td.new_line= line_index2 + 1 - %td.line_content.parallel= new_line - - else - %td.new_line= "" - %td.line_content.parallel= "" +:javascript + $('.diff-side-right').on('scroll', function(){ + $('.diff-side-left, .diff-middle').scrollTop($(this).scrollTop()); + $('.diff-side-left').scrollLeft($(this).scrollLeft()); + }); - - if @reply_allowed - - comments1 = [] - - comments2 = [] - - comments1 = @line_notes.select { |n| n.line_code == deleted_line[:line_code] }.sort_by(&:created_at) if deleted_line - - comments2 = @line_notes.select { |n| n.line_code == added_line[:line_code] }.sort_by(&:created_at) if added_line - - unless comments1.empty? && comments2.empty? - = render "projects/notes/diff_notes_with_reply_parallel", notes1: comments1, notes2: comments2, line1: deleted_line, line2: added_line \ No newline at end of file + $('.diff-side-left').on('scroll', function(){ + $('.diff-side-right, .diff-middle').scrollTop($(this).scrollTop()); // might never be relevant + $('.diff-side-right').scrollLeft($(this).scrollLeft()); + }); -- cgit v1.2.1 From 682cafdce627d5965a1f9e8d8053a2c6faf59219 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Thu, 27 Mar 2014 15:43:16 +1000 Subject: Update permissions.md --- doc/permissions/permissions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/permissions/permissions.md b/doc/permissions/permissions.md index 73e1728a559..ac4bdefddd5 100644 --- a/doc/permissions/permissions.md +++ b/doc/permissions/permissions.md @@ -38,7 +38,7 @@ If a user is a GitLab administrator they receive all permissions. |------|-----|--------|---------|------|-----| |Browse group|✓|✓|✓|✓|✓| |Edit group|||||✓| -|create project in group|||||✓| +|Create project in group|||||✓| |Manage group members|||||✓| |Remove group|||||✓| -- cgit v1.2.1 From b04c343311dfd5f12815936384762a9f1412fe34 Mon Sep 17 00:00:00 2001 From: dosire Date: Thu, 27 Mar 2014 10:53:26 +0100 Subject: Put important information at the top of the readme. --- doc/api/README.md | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/doc/api/README.md b/doc/api/README.md index 850666953a3..fa5b12af14c 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -1,5 +1,31 @@ # GitLab API +## End-points + ++ [Users](users.md) ++ [Session](session.md) ++ [Projects](projects.md) ++ [Project Snippets](project_snippets.md) ++ [Repositories](repositories.md) ++ [Repository Files](repository_files.md) ++ [Commits](commits.md) ++ [Merge Requests](merge_requests.md) ++ [Issues](issues.md) ++ [Milestones](milestones.md) ++ [Notes](notes.md) ++ [Deploy Keys](deploy_keys.md) ++ [System Hooks](system_hooks.md) ++ [Groups](groups.md) + +## Clients + ++ [php-gitlab-api](https://github.com/m4tthumphrey/php-gitlab-api) - PHP ++ [Ruby Wrapper](https://github.com/NARKOZ/gitlab) - Ruby ++ [python-gitlab](https://github.com/Itxaka/python-gitlab) - Python ++ [java-gitlab-api](https://github.com/timols/java-gitlab-api) - Java + +## Introduction + All API requests require authentication. You need to pass a `private_token` parameter by url or header. If passed as header, the header name must be "PRIVATE-TOKEN" (capital and with dash instead of underscore). You can find or reset your private token in your profile. If no, or an invalid, `private_token` is provided then an error message will be returned with status code 401: @@ -117,30 +143,3 @@ Issue So if you want to get issue with api you use `http://host/api/v3/.../issues/:id.json` But when you want to create a link to web page - use `http:://host/project/issues/:iid.json` - - - -## Contents - -+ [Users](users.md) -+ [Session](session.md) -+ [Projects](projects.md) -+ [Project Snippets](project_snippets.md) -+ [Repositories](repositories.md) -+ [Repository Files](repository_files.md) -+ [Commits](commits.md) -+ [Merge Requests](merge_requests.md) -+ [Issues](issues.md) -+ [Milestones](milestones.md) -+ [Notes](notes.md) -+ [Deploy Keys](deploy_keys.md) -+ [System Hooks](system_hooks.md) -+ [Groups](groups.md) - - -## Clients - -+ [php-gitlab-api](https://github.com/m4tthumphrey/php-gitlab-api) - PHP -+ [Ruby Wrapper](https://github.com/NARKOZ/gitlab) - Ruby -+ [python-gitlab](https://github.com/Itxaka/python-gitlab) - Python -+ [java-gitlab-api](https://github.com/timols/java-gitlab-api) - Java -- cgit v1.2.1 From 8a90db9e33b2dbb46655c0c3044da382b66c4d36 Mon Sep 17 00:00:00 2001 From: dosire Date: Thu, 27 Mar 2014 10:56:30 +0100 Subject: Test the new doc index. --- doc/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/README.md diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 00000000000..39880b55fa2 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,7 @@ +## The GitLab Documentation covers the following subjects + ++ [API](api/README.md) ++ [API](api/) ++ [API](api) ++ [API](/api/) ++ [API](/api) -- cgit v1.2.1 From 417c0cb2d33e76e271c89e99b323f2443e942107 Mon Sep 17 00:00:00 2001 From: dosire Date: Thu, 27 Mar 2014 12:17:27 +0100 Subject: New doc site needs indexes. --- doc/README.md | 18 ++++++++++++++---- doc/development/README.md | 2 ++ doc/install/README.md | 4 ++++ doc/legal/README.md | 2 ++ doc/raketasks/README.md | 6 ++++++ doc/release/README.md | 2 ++ doc/security/README.md | 2 ++ doc/update/README.md | 5 +++++ 8 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 doc/development/README.md create mode 100644 doc/install/README.md create mode 100644 doc/legal/README.md create mode 100644 doc/raketasks/README.md create mode 100644 doc/release/README.md create mode 100644 doc/security/README.md create mode 100644 doc/update/README.md diff --git a/doc/README.md b/doc/README.md index 39880b55fa2..865806f297a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,7 +1,17 @@ ## The GitLab Documentation covers the following subjects + [API](api/README.md) -+ [API](api/) -+ [API](api) -+ [API](/api/) -+ [API](/api) ++ [Development](development/README.md) ++ [Install](install/README.md) ++ [Integration](external-issue-tracker/README.md) ++ [Legal](legal/README.md) ++ [Markdown](markdown/markdown.md) ++ [Permissions](permissions/permissions.md) ++ [Public access](public_access/public_access.md) ++ [Raketasks](raketasks/README.md) ++ [Release](release/README.md) ++ [Security](security/README.md) ++ [System hooks](system_hooks/system_hooks.md) ++ [Update](update/README.md) ++ [Web hooks](web_hooks/web_hooks.md) ++ [Workflow](workflow/workflow.md) diff --git a/doc/development/README.md b/doc/development/README.md new file mode 100644 index 00000000000..aa59eb2c3e1 --- /dev/null +++ b/doc/development/README.md @@ -0,0 +1,2 @@ ++ [Architecture](architecture.md) ++ [Shell commands](shell_commands.md) diff --git a/doc/install/README.md b/doc/install/README.md new file mode 100644 index 00000000000..ec80e3cd62a --- /dev/null +++ b/doc/install/README.md @@ -0,0 +1,4 @@ ++ [Installation](installation.md) ++ [Requirements](requirements.md) ++ [Structure](structure.md) ++ [Database MySQL](database_mysql.md) diff --git a/doc/legal/README.md b/doc/legal/README.md new file mode 100644 index 00000000000..ebfdad13540 --- /dev/null +++ b/doc/legal/README.md @@ -0,0 +1,2 @@ ++ [Corporate contributor license agreement](corporate_contributor_license_agreement.md) ++ [Individual contributor license agreement](individual_contributor_license_agreement.md) diff --git a/doc/raketasks/README.md b/doc/raketasks/README.md new file mode 100644 index 00000000000..9aa80af12cc --- /dev/null +++ b/doc/raketasks/README.md @@ -0,0 +1,6 @@ ++ [Backup restore](backup_restore.md) ++ [Cleanup](cleanup.md) ++ [Features](features.md) ++ [Maintenance](maintenance.md) ++ [User management](user_management.md) ++ [Web hooks](web_hooks.md) diff --git a/doc/release/README.md b/doc/release/README.md new file mode 100644 index 00000000000..22510be3f18 --- /dev/null +++ b/doc/release/README.md @@ -0,0 +1,2 @@ ++ [Monthly](monthly.md) ++ [Security](security.md) diff --git a/doc/security/README.md b/doc/security/README.md new file mode 100644 index 00000000000..f8dd1291b9b --- /dev/null +++ b/doc/security/README.md @@ -0,0 +1,2 @@ ++ [Password length limits](password_length_limits.md) ++ [Rack attack](rack_attack.md) diff --git a/doc/update/README.md b/doc/update/README.md new file mode 100644 index 00000000000..97afd71bbe3 --- /dev/null +++ b/doc/update/README.md @@ -0,0 +1,5 @@ ++ [The indivual upgrade guides](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update) ++ [Uprader](upgrader.md) ++ [Ruby](ruby.md) ++ [Patch versions](patch_versions.md) ++ [MySQL to Postgress](mysql_to_postgress.md) -- cgit v1.2.1 From 762c7b4f2b272f56d185f09f061a8811c751a50e Mon Sep 17 00:00:00 2001 From: Kyle Fazzari Date: Thu, 27 Mar 2014 08:20:43 -0400 Subject: Fixed 500 error when creating issue for project with no commits. The form was updated to check that the repository wasn't empty before trying to load the contribution guide. This fixes #153. --- app/views/projects/issues/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml index dd091302c8e..05cae80e50c 100644 --- a/app/views/projects/issues/_form.html.haml +++ b/app/views/projects/issues/_form.html.haml @@ -1,7 +1,7 @@ %div.issue-form-holder %h3.page-title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.iid}" %hr - - if @repository.contribution_guide && !@issue.persisted? + - if !@repository.empty? && @repository.contribution_guide && !@issue.persisted? - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name)) .alert.alert-info.col-sm-10.col-sm-offset-2 ="Please review the #{link_to "guidelines for contribution", contribution_guide_url} to this repository.".html_safe -- cgit v1.2.1 From 592dce18b549cd29933603f53f1ab8fb9f33840e Mon Sep 17 00:00:00 2001 From: Jeroen van Baarsen Date: Thu, 27 Mar 2014 14:32:32 +0100 Subject: Always show merge status Always show the merge status of a merge request, even if the user has no permission to do the actual merging. Fixes http://feedback.gitlab.com/forums/176466-general/suggestions/5673321-everyone-should-be-able-to-see-a-mr-status --- app/views/projects/merge_requests/show/_mr_accept.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/projects/merge_requests/show/_mr_accept.html.haml b/app/views/projects/merge_requests/show/_mr_accept.html.haml index 4b1857ccb68..bd7c8435f4c 100644 --- a/app/views/projects/merge_requests/show/_mr_accept.html.haml +++ b/app/views/projects/merge_requests/show/_mr_accept.html.haml @@ -4,7 +4,10 @@ %strong Archived projects cannot be committed to! - else .bs-callout - %strong You don't have permission to merge this MR + .automerge_widget.cannot_be_merged.hide + %strong This can't be merged automatically, even if it could be merged you don't have the permission to do so. + .automerge_widget.can_be_merged.hide + %strong This can be merged automatically but you don't have the permission to do so. - if @show_merge_controls -- cgit v1.2.1 From 3b3186d58be54c0c720564939cebc0419a5751c1 Mon Sep 17 00:00:00 2001 From: Job van der Voort Date: Thu, 27 Mar 2014 14:34:55 +0000 Subject: fix image not displaying in GitLab due to faulty markdown --- doc/development/architecture.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/development/architecture.md b/doc/development/architecture.md index 805e115047a..6f832614d70 100644 --- a/doc/development/architecture.md +++ b/doc/development/architecture.md @@ -28,7 +28,7 @@ To serve repositories over SSH there's an add-on application called gitlab-shell ## Components -![GitLab Diagram Overview](resources/gitlab_diagram_overview.png "GitLab Diagram Overview") +![GitLab Diagram Overview](resources/gitlab_diagram_overview.png) A typical install of GitLab will be on Ubuntu Linux or RHEL/CentOS. It uses Nginx or Apache as a web front end to proxypass the Unicorn web server. @@ -180,4 +180,4 @@ bundle exec rake gitlab:check RAILS_ENV=production ``` Note: It is recommended to log into the `git` user using `sudo -i -u git` or `sudo su - git`. -While the sudo commands provided by gitlabhq work in Ubuntu they do not always work in RHEL. +While the sudo commands provided by gitlabhq work in Ubuntu they do not always work in RHEL. \ No newline at end of file -- cgit v1.2.1 From 9ec08daa90162ea4d63db518fca0312f5bd5328d Mon Sep 17 00:00:00 2001 From: dosire Date: Thu, 27 Mar 2014 16:08:02 +0100 Subject: Move help to the website. --- README.md | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/README.md b/README.md index 7818d40ac55..2668ed8bac0 100644 --- a/README.md +++ b/README.md @@ -129,22 +129,4 @@ or start each component separately ### Getting help -* [Maintenance policy](MAINTENANCE.md) specifies what versions are supported. - -* [Troubleshooting guide](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide) contains solutions to common problems. - -* [Mailing list](https://groups.google.com/forum/#!forum/gitlabhq) and [Stack Overflow](http://stackoverflow.com/questions/tagged/gitlab) are the best places to ask questions. For example you can use it if you have questions about: permission denied errors, invisible repos, can't clone/pull/push or with web hooks that don't fire. Please search for similar issues before posting your own, there's a good chance somebody else had the same issue you have now and has resolved it. There are a lot of helpful GitLab users there who may be able to help you quickly. If your particular issue turns out to be a bug, it will find its way from there to a fix. - -* [Feature request forum](http://feedback.gitlab.com) is the place to propose and discuss new features for GitLab. - -* [Contributing guide](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) describes how to submit merge requests and issues. Pull requests and issues not in line with the guidelines in this document will be closed. - -* [Support subscription](http://www.gitlab.com/subscription/) connects you to the knowledge of GitLab experts that will resolve your issues and answer your questions. - -* [Consultancy](http://www.gitlab.com/consultancy/) from the GitLab experts for installations, upgrades and customizations. - -* [#gitlab IRC channel](http://www.freenode.net/) on Freenode to get in touch with other GitLab users and get help, it's managed by James Newton (newton), Drew Blessing (dblessing), and Sam Gleske (sag47). - -* [Book](http://www.packtpub.com/gitlab-repository-management/book) written by GitLab enthusiast Jonathan M. Hethey is unofficial but it offers a good overview. - -* [Gitter chat room](https://gitter.im/gitlabhq/gitlabhq#) here you can ask questions when you need help. +Please see [Getting help for GitLab](https://www.gitlab.com/getting-help/) on our website for the many options to get help. -- cgit v1.2.1