From 8282535ad2607dc5e287f86da68620026a491c1f Mon Sep 17 00:00:00 2001 From: Alexey Yamshikov Date: Thu, 19 Apr 2018 12:52:31 +0200 Subject: [PATCH 1/2] Fix file permissions instead of just checking them. --- Rakefile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 3b21dc0..90c2c94 100644 --- a/Rakefile +++ b/Rakefile @@ -24,15 +24,26 @@ Rake::TestTask.new(:test) do |test| end # Building the gem will use the local file mode, so ensure it's world-readable. -desc 'Check plugin file permissions' -task :check_perms do - plugin = 'lib/fluent/plugin/out_detect_exceptions.rb' - mode = File.stat(plugin).mode & 0o777 - raise "Unexpected mode #{mode.to_s(8)} for #{plugin}" unless - mode & 0o444 == 0o444 +# https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions/issues/32 +desc 'Fix file permissions' +task :fix_perms do + files = [ + 'lib/fluent/plugin/exception_detector.rb', + 'lib/fluent/plugin/out_detect_exceptions.rb' + ].flat_map do |file| + file.include?('*') ? Dir.glob(file) : [file] + end + + files.each do |file| + mode = File.stat(file).mode & 0o777 + next unless mode & 0o444 != 0o444 + puts "Changing mode of #{file} from #{mode.to_s(8)} to "\ + "#{(mode | 0o444).to_s(8)}" + chmod mode | 0o444, file + end end desc 'Run unit tests and RuboCop to check for style violations' -task all: [:test, :rubocop, :check_perms] +task all: [:test, :rubocop, :fix_perms] task default: :all From 7540461428e52533c79e8f28103aa737fbec14ce Mon Sep 17 00:00:00 2001 From: Alexey Yamschikov Date: Mon, 23 Apr 2018 15:49:00 +0200 Subject: [PATCH 2/2] change: select files by wildcard --- Rakefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 90c2c94..959b345 100644 --- a/Rakefile +++ b/Rakefile @@ -28,8 +28,7 @@ end desc 'Fix file permissions' task :fix_perms do files = [ - 'lib/fluent/plugin/exception_detector.rb', - 'lib/fluent/plugin/out_detect_exceptions.rb' + 'lib/fluent/plugin/*.rb' ].flat_map do |file| file.include?('*') ? Dir.glob(file) : [file] end