Sha256: 7faf5434bb5386b417deea16cc26d55a2eda52b5717f9fe41e91991eedcedc9a

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.files_modified.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.0 lib/danger/plugins/protect_files.rb