Sha256: 9284ef94b365020f347ba88865cc7a835b654328868cac20f892148d38fbcf17

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

module Danger
  class Dangerfile
    module DSL
      # Protect a file from being changed. This can
      # be used in combination with some kind of
      # permission check if a user is inside the org
      def protect_files(path: nil, message: nil, fail_build: true)
        broken_rule = false
        Dir.glob(path) do |current|
          broken_rule = true if self.env.scm.modified_files.include?(current)
        end

        return unless broken_rule

        if fail_build
          self.errors << message
        else
          self.messages << message
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-0.6.5 lib/danger/plugins/protect_files.rb