From 75f72a2ff464c51e0e447600633be64ff365d360 Mon Sep 17 00:00:00 2001 From: rockneverdies55 Date: Fri, 24 Apr 2015 13:17:51 -0400 Subject: Removed "unreleased" from v7.10 changelog Version 7.10 is already released so "unreleased" text next to it in the changelog file can be removed. --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 58dde541429..634062550b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,7 +24,7 @@ v 7.11.0 (unreleased) - Prevent sending empty messages to HipChat (Chulki Lee) - Improve UI for mobile phones on dashboard and project pages -v 7.10.0 (unreleased) +v 7.10.0 - Ignore submodules that are defined in .gitmodules but are checked in as directories. - Allow projects to be imported from Google Code. - Remove access control for uploaded images to fix broken images in emails (Hannes Rosenögger) -- cgit v1.2.1 From 0cbafa4d65c31feef9e9651c40eca5dc820bc9ed Mon Sep 17 00:00:00 2001 From: Zhang Sen Date: Fri, 24 Apr 2015 18:27:52 +0800 Subject: Fix contributions calendar empty problem under mysql When using MySQL as database backend in GitLab, ``date`` in ``date(created_at), count(id) as total_amount`` won't return the ``date`` column (should be ``date(created_at)``), as a result, there's no contribution in the user profile page. Adding an ``as date`` can solve this problem. --- lib/gitlab/contributions_calendar.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index 3fd0823df06..45bb904ed7a 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -17,7 +17,7 @@ module Gitlab events = Event.reorder(nil).contributions.where(author_id: user.id). where("created_at > ?", date_from).where(project_id: projects). group('date(created_at)'). - select('date(created_at), count(id) as total_amount'). + select('date(created_at) as date, count(id) as total_amount'). map(&:attributes) dates = (1.year.ago.to_date..(Date.today + 1.day)).to_a -- cgit v1.2.1 From 2e34b7aab5ad91bdcfde80486e8b4bcc17cb2241 Mon Sep 17 00:00:00 2001 From: tonic Date: Sat, 25 Apr 2015 15:49:28 +0800 Subject: fix redis 3.0.0 --- lib/tasks/gitlab/check.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 04a2eb12db0..1a6303b6c82 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -282,7 +282,8 @@ namespace :gitlab do def check_redis_version print "Redis version >= 2.0.0? ... " - if run_and_match(%W(redis-cli --version), /redis-cli 2.\d.\d/) + redis_version = run(%W(redis-cli --version)) + if redis_version.try(:match, /redis-cli 2.\d.\d/) || redis_version.try(:match, /redis-cli 3.\d.\d/) puts "yes".green else puts "no".red -- cgit v1.2.1 From 548f182814acd0f7a110e6c165c186e345901b00 Mon Sep 17 00:00:00 2001 From: bugagazavr Date: Sat, 24 Jan 2015 03:10:43 +0300 Subject: Added X-GitLab-Event header for web hooks --- CHANGELOG | 1 + app/controllers/admin/hooks_controller.rb | 2 +- app/models/hooks/web_hook.rb | 16 +++++++++++----- app/models/project.rb | 2 +- app/services/system_hooks_service.rb | 6 +++--- app/services/test_hook_service.rb | 2 +- app/workers/project_web_hook_worker.rb | 4 ++-- app/workers/system_hook_worker.rb | 4 ++-- lib/api/system_hooks.rb | 2 +- spec/models/hooks/web_hook_spec.rb | 14 +++++++++----- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 82f789c2baf..aa99101feef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ v 7.11.0 (unreleased) - Add "Reply quoting selected text" shortcut key (`r`) - Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention. - Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention. + - Added GitLab Event header for project hooks - - Show Atom feed buttons everywhere where applicable. - Add project activity atom feed. diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb index 0a463239d74..690096bdbcf 100644 --- a/app/controllers/admin/hooks_controller.rb +++ b/app/controllers/admin/hooks_controller.rb @@ -33,7 +33,7 @@ class Admin::HooksController < Admin::ApplicationController owner_name: "Someone", owner_email: "example@gitlabhq.com" } - @hook.execute(data) + @hook.execute(data, 'system_hooks') redirect_to :back end diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb index 315d96af1b9..e9fd441352d 100644 --- a/app/models/hooks/web_hook.rb +++ b/app/models/hooks/web_hook.rb @@ -30,12 +30,15 @@ class WebHook < ActiveRecord::Base validates :url, presence: true, format: { with: /\A#{URI.regexp(%w(http https))}\z/, message: "should be a valid url" } - def execute(data) + def execute(data, hook_name) parsed_url = URI.parse(url) if parsed_url.userinfo.blank? WebHook.post(url, body: data.to_json, - headers: { "Content-Type" => "application/json" }, + headers: { + "Content-Type" => "application/json", + "X-Gitlab-Event" => hook_name.singularize.titleize + }, verify: false) else post_url = url.gsub("#{parsed_url.userinfo}@", "") @@ -45,7 +48,10 @@ class WebHook < ActiveRecord::Base } WebHook.post(post_url, body: data.to_json, - headers: { "Content-Type" => "application/json" }, + headers: { + "Content-Type" => "application/json", + "X-Gitlab-Event" => hook_name.singularize.titleize + }, verify: false, basic_auth: auth) end @@ -54,7 +60,7 @@ class WebHook < ActiveRecord::Base false end - def async_execute(data) - Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data) + def async_execute(data, hook_name) + Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data, hook_name) end end diff --git a/app/models/project.rb b/app/models/project.rb index 293ee04f228..59cca01e084 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -483,7 +483,7 @@ class Project < ActiveRecord::Base def execute_hooks(data, hooks_scope = :push_hooks) hooks.send(hooks_scope).each do |hook| - hook.async_execute(data) + hook.async_execute(data, hooks_scope.to_s) end end diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index c5d0b08845b..60235b6be2a 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -7,12 +7,12 @@ class SystemHooksService def execute_hooks(data) SystemHook.all.each do |sh| - async_execute_hook sh, data + async_execute_hook(sh, data, 'system_hooks') end end - def async_execute_hook(hook, data) - Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data) + def async_execute_hook(hook, data, hook_name) + Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data, hook_name) end def build_event_data(model, event) diff --git a/app/services/test_hook_service.rb b/app/services/test_hook_service.rb index 21ec2c01cb8..e85e58751e7 100644 --- a/app/services/test_hook_service.rb +++ b/app/services/test_hook_service.rb @@ -1,6 +1,6 @@ class TestHookService def execute(hook, current_user) data = Gitlab::PushDataBuilder.build_sample(hook.project, current_user) - hook.execute(data) + hook.execute(data, 'push_hooks') end end diff --git a/app/workers/project_web_hook_worker.rb b/app/workers/project_web_hook_worker.rb index 73085c046bd..fb878965288 100644 --- a/app/workers/project_web_hook_worker.rb +++ b/app/workers/project_web_hook_worker.rb @@ -3,8 +3,8 @@ class ProjectWebHookWorker sidekiq_options queue: :project_web_hook - def perform(hook_id, data) + def perform(hook_id, data, hook_name) data = data.with_indifferent_access - WebHook.find(hook_id).execute(data) + WebHook.find(hook_id).execute(data, hook_name) end end diff --git a/app/workers/system_hook_worker.rb b/app/workers/system_hook_worker.rb index 3ebc62b7e7a..a122c274763 100644 --- a/app/workers/system_hook_worker.rb +++ b/app/workers/system_hook_worker.rb @@ -3,7 +3,7 @@ class SystemHookWorker sidekiq_options queue: :system_hook - def perform(hook_id, data) - SystemHook.find(hook_id).execute data + def perform(hook_id, data, hook_name) + SystemHook.find(hook_id).execute(data, hook_name) end end diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 518964db50d..22b8f90dc5c 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -47,7 +47,7 @@ module API owner_name: "Someone", owner_email: "example@gitlabhq.com" } - @hook.execute(data) + @hook.execute(data, 'system_hooks') data end diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index 67ec9193ad7..14f873e6b5a 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -52,22 +52,26 @@ describe ProjectHook do end it "POSTs to the web hook URL" do - @project_hook.execute(@data) - expect(WebMock).to have_requested(:post, @project_hook.url).once + @project_hook.execute(@data, 'push_hooks') + expect(WebMock).to have_requested(:post, @project_hook.url). + with(headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook'}). + once end it "POSTs the data as JSON" do json = @data.to_json - @project_hook.execute(@data) - expect(WebMock).to have_requested(:post, @project_hook.url).with(body: json).once + @project_hook.execute(@data, 'push_hooks') + expect(WebMock).to have_requested(:post, @project_hook.url). + with(headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook'}). + once end it "catches exceptions" do expect(WebHook).to receive(:post).and_raise("Some HTTP Post error") expect { - @project_hook.execute(@data) + @project_hook.execute(@data, 'push_hooks') }.to raise_error end end -- cgit v1.2.1 From 57188d285f9fadf89726e808ca10c3fb96ac3880 Mon Sep 17 00:00:00 2001 From: Jeroen van Baarsen Date: Sat, 25 Apr 2015 12:02:55 +0200 Subject: Its 7.11.0-pre time Signed-off-by: Jeroen van Baarsen --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 67fc32adaba..e85691e6ff7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.10.0.pre +7.11.0.pre -- cgit v1.2.1 From 3c3b43b0a0568950b0eb4bdfb6fd27c30686c106 Mon Sep 17 00:00:00 2001 From: Dominik Sander Date: Sun, 26 Apr 2015 20:56:13 +0200 Subject: Add notify and color options to HipchatService When notify is set to true send messages will trigger a notification for all room members. Color changes the background color of the message. --- CHANGELOG | 1 + app/controllers/projects/services_controller.rb | 3 ++- app/models/project_services/hipchat_service.rb | 10 ++++++++-- spec/models/project_services/hipchat_service_spec.rb | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 82f789c2baf..2504a4e9c91 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ v 7.11.0 (unreleased) - Improve new project command options (Ben Bodenmiller) - Prevent sending empty messages to HipChat (Chulki Lee) - Improve UI for mobile phones on dashboard and project pages + - Add room notification and message color option for HipChat v 7.10.0 - Ignore submodules that are defined in .gitmodules but are checked in as directories. diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 73031851734..2080ee9a00f 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -6,7 +6,8 @@ class Projects::ServicesController < Projects::ApplicationController :description, :issues_url, :new_issue_url, :restrict_to_branch, :channel, :colorize_messages, :channels, :push_events, :issues_events, :merge_requests_events, :tag_push_events, - :note_events, :send_from_committer_email, :disable_diffs, :external_wiki_url] + :note_events, :send_from_committer_email, :disable_diffs, :external_wiki_url, + :notify, :color] # Authorize before_action :authorize_admin_project! before_action :service, only: [:edit, :update, :test] diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index 07520eab5d1..2fa5f0ce71c 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -20,7 +20,7 @@ class HipchatService < Service MAX_COMMITS = 3 - prop_accessor :token, :room, :server + prop_accessor :token, :room, :server, :notify, :color validates :token, presence: true, if: :activated? def title @@ -39,6 +39,8 @@ class HipchatService < Service [ { type: 'text', name: 'token', placeholder: 'Room token' }, { type: 'text', name: 'room', placeholder: 'Room name or ID' }, + { type: 'checkbox', name: 'notify' }, + { type: 'select', name: 'color', choices: ['yellow', 'red', 'green', 'purple', 'gray', 'random'] }, { type: 'text', name: 'server', placeholder: 'Leave blank for default. https://hipchat.example.com' } ] @@ -52,7 +54,7 @@ class HipchatService < Service return unless supported_events.include?(data[:object_kind]) message = create_message(data) return unless message.present? - gate[room].send('GitLab', message) + gate[room].send('GitLab', message, message_options) end private @@ -63,6 +65,10 @@ class HipchatService < Service @gate ||= HipChat::Client.new(token, options) end + def message_options + { notify: notify.present? && notify == '1', color: color || 'yellow' } + end + def create_message(data) object_kind = data[:object_kind] diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb index 8ab847e6432..348f83c56ad 100644 --- a/spec/models/project_services/hipchat_service_spec.rb +++ b/spec/models/project_services/hipchat_service_spec.rb @@ -213,5 +213,21 @@ describe HipchatService do "
snippet note
") end end + + context "#message_options" do + it "should be set to the defaults" do + expect(hipchat.send(:message_options)).to eq({notify: false, color: 'yellow'}) + end + + it "should set notfiy to true" do + hipchat.stub(notify: '1') + expect(hipchat.send(:message_options)).to eq({notify: true, color: 'yellow'}) + end + + it "should set the color" do + hipchat.stub(color: 'red') + expect(hipchat.send(:message_options)).to eq({notify: false, color: 'red'}) + end + end end end -- cgit v1.2.1 From 7098b7bbe0de8e514c4e487a37446154021bf894 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sun, 26 Apr 2015 17:24:09 -0700 Subject: google -> Google --- doc/integration/gitlab_buttons_in_gmail.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/integration/gitlab_buttons_in_gmail.md b/doc/integration/gitlab_buttons_in_gmail.md index a9885cef109..e35bb8ba693 100644 --- a/doc/integration/gitlab_buttons_in_gmail.md +++ b/doc/integration/gitlab_buttons_in_gmail.md @@ -7,11 +7,11 @@ If correctly setup, emails that require an action will be marked in Gmail. ![gitlab_actions](gitlab_actions.png) To get this functioning, you need to be registered with Google. -[See how to register with google in this document.](https://developers.google.com/gmail/markup/registering-with-google) +[See how to register with Google in this document.](https://developers.google.com/gmail/markup/registering-with-google) -To aid the registering with google, GitLab offers a rake task that will send an email to google whitelisting email address from your GitLab server. +To aid the registering with Google, GitLab offers a rake task that will send an email to Google whitelisting email address from your GitLab server. -To check what would be sent to the google email address, run the rake task: +To check what would be sent to the Google email address, run the rake task: ```bash bundle exec rake gitlab:mail_google_schema_whitelisting RAILS_ENV=production @@ -19,7 +19,7 @@ bundle exec rake gitlab:mail_google_schema_whitelisting RAILS_ENV=production **This will not send the email but give you the output of how the mail will look.** -Copy the output of the rake task to [google email markup tester](https://www.google.com/webmasters/markup-tester/u/0/) and press "Validate". +Copy the output of the rake task to [Google email markup tester](https://www.google.com/webmasters/markup-tester/u/0/) and press "Validate". If you receive "No errors detected" message from the tester you can send the email using: -- cgit v1.2.1