diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-31 10:07:13 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-31 10:07:13 +0200 |
commit | ed6f524c49ad1356e6b7ce35a6fe79632e24b015 (patch) | |
tree | 5a3e6d7bc13be35b7cb518baf394530c65e71e96 /lib | |
parent | 5ac61d7b241b2332513650e2287cfde09d9c1fb7 (diff) | |
parent | 0af8587d88bd03d107438343b7895ad30f7a9308 (diff) | |
download | gitlab-ce-ed6f524c49ad1356e6b7ce35a6fe79632e24b015.tar.gz |
Merge branch 'master' into fix/issue-move-rewrite-uploads
* master: (27 commits)
Fix commit comment alignment
minor cleanup in system_hook_spec
Pre-calculate Emoji digests
Clear .todo listener
Change window.location to use turbolinks
Make entire todo row clickable
Add 8.6.2 CHANGELOG items
Ensure uploads dir exists when running backup specs
Move CarrierWave test env config to separate file
Remove console logs
Off the event initially
Collapsed sidebar opens over instead of pushing content.
Sidebar collapse update issue
User selection from collapsed sidebar
Add json response for user avatar in merge request
Make changed values visible in minimized sidebar.
Fixed MergeRequestController spec
We need `sha` reference from `diff_base_commit` to generate the diff
Use `diff_base_commit` instead of `target_branch` to generate diffs
Isolate CarrierWave uploads in test enviroment
...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/award_emoji.rb | 19 | ||||
-rw-r--r-- | lib/gitlab/badge/build.rb | 24 | ||||
-rw-r--r-- | lib/gitlab/email/receiver.rb | 15 | ||||
-rw-r--r-- | lib/gitlab/incoming_email.rb | 16 | ||||
-rw-r--r-- | lib/tasks/gemojione.rake | 48 | ||||
-rw-r--r-- | lib/tasks/gitlab/check.rake | 15 |
6 files changed, 102 insertions, 35 deletions
diff --git a/lib/award_emoji.rb b/lib/award_emoji.rb index 783fcfb61ad..4fc3443ac68 100644 --- a/lib/award_emoji.rb +++ b/lib/award_emoji.rb @@ -48,4 +48,23 @@ class AwardEmoji JSON.parse(File.read(json_path)) end end + + # Returns an Array of Emoji names and their asset URLs. + def self.urls + @urls ||= begin + path = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json') + prefix = Gitlab::Application.config.assets.prefix + digest = Gitlab::Application.config.assets.digest + + JSON.parse(File.read(path)).map do |hash| + if digest + fname = "#{hash['unicode']}-#{hash['digest']}" + else + fname = hash['unicode'] + end + + { name: hash['name'], path: "#{prefix}/#{fname}.png" } + end + end + end end diff --git a/lib/gitlab/badge/build.rb b/lib/gitlab/badge/build.rb new file mode 100644 index 00000000000..28a2391dbf8 --- /dev/null +++ b/lib/gitlab/badge/build.rb @@ -0,0 +1,24 @@ +module Gitlab + module Badge + ## + # Build badge + # + class Build + def initialize(project, ref) + @image = ::Ci::ImageForBuildService.new.execute(project, ref: ref) + end + + def to_s + @image[:name].sub(/\.svg$/, '') + end + + def type + 'image/svg+xml' + end + + def data + File.read(@image[:path]) + end + end + end +end diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index d4b6f6d120d..97ef9851d71 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -63,6 +63,10 @@ module Gitlab end def reply_key + key_from_to_header || key_from_additional_headers + end + + def key_from_to_header key = nil message.to.each do |address| key = Gitlab::IncomingEmail.key_from_address(address) @@ -72,6 +76,17 @@ module Gitlab key end + def key_from_additional_headers + reply_key = nil + + Array(message.references).each do |message_id| + reply_key = Gitlab::IncomingEmail.key_from_fallback_reply_message_id(message_id) + break if reply_key + end + + reply_key + end + def sent_notification return nil unless reply_key diff --git a/lib/gitlab/incoming_email.rb b/lib/gitlab/incoming_email.rb index 9068d79c95e..8ce9d32abe0 100644 --- a/lib/gitlab/incoming_email.rb +++ b/lib/gitlab/incoming_email.rb @@ -1,13 +1,10 @@ module Gitlab module IncomingEmail class << self - def enabled? - config.enabled && address_formatted_correctly? - end + FALLBACK_REPLY_MESSAGE_ID_REGEX = /\Areply\-(.+)@#{Gitlab.config.gitlab.host}\Z/.freeze - def address_formatted_correctly? - config.address && - config.address.include?("%{key}") + def enabled? + config.enabled && config.address end def reply_address(key) @@ -24,6 +21,13 @@ module Gitlab match[1] end + def key_from_fallback_reply_message_id(message_id) + match = message_id.match(FALLBACK_REPLY_MESSAGE_ID_REGEX) + return unless match + + match[1] + end + def config Gitlab.config.incoming_email end diff --git a/lib/tasks/gemojione.rake b/lib/tasks/gemojione.rake index cfaf4a129b1..7ec00a898fd 100644 --- a/lib/tasks/gemojione.rake +++ b/lib/tasks/gemojione.rake @@ -1,19 +1,39 @@ -# This task will generate a standard and Retina sprite of all of the current -# Gemojione Emojis, with the accompanying SCSS map. -# -# It will not appear in `rake -T` output, and the dependent gems are not -# included in the Gemfile by default, because this task will only be needed -# occasionally, such as when new Emojis are added to Gemojione. - -begin - require 'sprite_factory' - require 'rmagick' -rescue LoadError - # noop -end - namespace :gemojione do + desc 'Generates Emoji SHA256 digests' + task digests: :environment do + require 'digest/sha2' + require 'json' + + dir = Gemojione.index.images_path + + digests = AwardEmoji.emojis.map do |name, emoji_hash| + fpath = File.join(dir, "#{emoji_hash['unicode']}.png") + digest = Digest::SHA256.file(fpath).hexdigest + + { name: name, unicode: emoji_hash['unicode'], digest: digest } + end + + out = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json') + + File.open(out, 'w') do |handle| + handle.write(JSON.pretty_generate(digests)) + end + end + + # This task will generate a standard and Retina sprite of all of the current + # Gemojione Emojis, with the accompanying SCSS map. + # + # It will not appear in `rake -T` output, and the dependent gems are not + # included in the Gemfile by default, because this task will only be needed + # occasionally, such as when new Emojis are added to Gemojione. task sprite: :environment do + begin + require 'sprite_factory' + require 'rmagick' + rescue LoadError + # noop + end + check_requirements! SIZE = 20 diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 27ed57efe55..effb8eb6001 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -623,7 +623,6 @@ namespace :gitlab do start_checking "Reply by email" if Gitlab.config.incoming_email.enabled - check_address_formatted_correctly check_imap_authentication if Rails.env.production? @@ -643,20 +642,6 @@ namespace :gitlab do # Checks ######################## - def check_address_formatted_correctly - print "Address formatted correctly? ... " - - if Gitlab::IncomingEmail.address_formatted_correctly? - puts "yes".green - else - puts "no".red - try_fixing_it( - "Make sure that the address in config/gitlab.yml includes the '%{key}' placeholder." - ) - fix_and_rerun - end - end - def check_initd_configured_correctly print "Init.d configured correctly? ... " |