From b7a31a4b024e2c5f607003f1c42e2cd46adb2ff4 Mon Sep 17 00:00:00 2001 From: Nicole Cordes Date: Wed, 3 Sep 2014 22:28:04 +0200 Subject: [PATCH 1/2] Generate valid json for hooks It seems that ruby can handle 'nil' value but other json processors (like PHP) throw an error. This is always generated for empty arrays. --- CHANGELOG | 1 + app/services/system_hooks_service.rb | 2 +- lib/gitlab/push_data_builder.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 81468d4013e..1842a28f84e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -35,6 +35,7 @@ v 7.9.0 (unreleased) - Move groups page from profile to dashboard - Starred projects page at dashboard - Blocking user does not remove him/her from project/groups but show blocked label + - Improve json validation in hook data v 7.8.2 - Fix service migration issue when upgrading from versions prior to 7.3 diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 46f6e91e808..c5d0b08845b 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -41,7 +41,7 @@ class SystemHooksService path_with_namespace: model.path_with_namespace, project_id: model.id, owner_name: owner.name, - owner_email: owner.respond_to?(:email) ? owner.email : nil, + owner_email: owner.respond_to?(:email) ? owner.email : "", project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase }) when User diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb index 5cefa67d3ab..ea06e1f7333 100644 --- a/lib/gitlab/push_data_builder.rb +++ b/lib/gitlab/push_data_builder.rb @@ -58,6 +58,7 @@ module Gitlab data[:commits] << commit.hook_attrs(project) end + data[:commits] = "" if data[:commits].count == 0 data end From 61ed518781cfc78bf1710286d84d4e74521f48d4 Mon Sep 17 00:00:00 2001 From: Vyacheslav Slinko Date: Fri, 2 Jan 2015 15:47:22 +0300 Subject: [PATCH 2/2] Make email display name configurable --- CHANGELOG | 3 ++- app/mailers/notify.rb | 2 +- config/gitlab.yml.example | 1 + config/initializers/1_settings.rb | 1 + spec/mailers/notify_spec.rb | 3 ++- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b210a6b0155..52997ee8c95 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,7 +33,8 @@ v 7.9.0 (unreleased) - Send notifications and leave system comments when bulk updating issues. - Automatically link commit ranges to compare page: sha1...sha4 or sha1..sha4 (includes sha1 in comparison) - Move groups page from profile to dashboard - - Starred projects page at dashboard + - Starred projects page at dashboard + - Make email display name configurable v 7.8.2 - Fix service migration issue when upgrading from versions prior to 7.3 diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 65925b61e94..ee27879cf40 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -53,7 +53,7 @@ class Notify < ActionMailer::Base # The default email address to send emails from def default_sender_address address = Mail::Address.new(Gitlab.config.gitlab.email_from) - address.display_name = "GitLab" + address.display_name = Gitlab.config.gitlab.email_display_name address end diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 6dff07cf9df..75d9e65aefe 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -43,6 +43,7 @@ production: &base # email_enabled: true # Email address used in the "From" field in mails sent by GitLab email_from: example@example.com + email_display_name: GitLab # Email server smtp settings are in config/initializers/smtp_settings.rb.sample diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 6a8bbb80b9c..70af7a829c4 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -102,6 +102,7 @@ Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || '' Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http" Settings.gitlab['email_enabled'] ||= true if Settings.gitlab['email_enabled'].nil? Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}" +Settings.gitlab['email_display_name'] ||= "GitLab" Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) Settings.gitlab['user'] ||= 'git' Settings.gitlab['user_home'] ||= begin diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 4090fa46205..b3c507ccbe2 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -5,6 +5,7 @@ describe Notify do include EmailSpec::Matchers include RepoHelpers + let(:gitlab_sender_display_name) { Gitlab.config.gitlab.email_display_name } let(:gitlab_sender) { Gitlab.config.gitlab.email_from } let(:recipient) { create(:user, email: 'recipient@example.com') } let(:project) { create(:project) } @@ -23,7 +24,7 @@ describe Notify do shared_examples 'an email sent from GitLab' do it 'is sent from GitLab' do sender = subject.header[:from].addrs[0] - expect(sender.display_name).to eq('GitLab') + expect(sender.display_name).to eq(gitlab_sender_display_name) expect(sender.address).to eq(gitlab_sender) end end