Class: Danger::DangerSemanticCommit
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerSemanticCommit
- Defined in:
- lib/semantic_commit/plugin.rb
Overview
Run each commit in the PR through a message linting.
Semantic commit lint will validate each commit in the PR to ensure the
following is true:
* Commit subject begins with a type
* Commit subject is no longer than 70 characters (`length`)
By default, Semantic Commit Lint fails, but you can configure this behavior.
Instance Method Summary collapse
-
#validate(config = {}) ⇒ void
Validates the commits with whatever config the user passes.
Instance Method Details
#validate(config = {}) ⇒ void
This method returns an undefined value.
Validates the commits with whatever config the user passes.
Passing in a hash which contain the following keys:
* `disable` - array of checks to skip
* `fail` - array of checks to fail on
* `warn` - array of checks to warn on
The current check types are:
* `length`
Note: you can pass :all instead of an array to target all checks.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/semantic_commit/plugin.rb', line 57 def validate(config = {}) self.config = config commits.each do |commit| enabled_validators.each do |validator| if !validator.valid?(commit) = validator.(commit) messaging.fail([, commit.fetch(:sha)].join("\n")) end end end end |