Class: Danger::Dangerfile::DSL::ProtectFiles
- Defined in:
- lib/danger/plugins/protect_files.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Plugin
Constructor Details
This class inherits a constructor from Danger::Dangerfile::DSL::Plugin
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Danger::Dangerfile::DSL::Plugin
Class Method Details
.description ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/danger/plugins/protect_files.rb', line 24 def self.description [ "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" ].join(" ") end |
Instance Method Details
#run(path: nil, message: nil, fail_build: true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/danger/plugins/protect_files.rb', line 5 def run(path: nil, message: nil, fail_build: true) raise "You have to provide a message" if .to_s.length == 0 raise "You have to provide a path" if path.to_s.length == 0 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 @dsl.errors << else @dsl.warnings << end end |