Class: Danger::DangerWCC::CommitLint
- Inherits:
-
Object
- Object
- Danger::DangerWCC::CommitLint
- Defined in:
- lib/wcc/commit_lint.rb
Overview
Run each commit in the PR through a message linting.
Commit lint will check each commit in the PR to ensure the following is
true:
* Commit subject begins with a capital letter (`subject_cap`)
* Commit subject is more than one word (`subject_word`)
* Commit subject is no longer than 50 characters (`subject_length`)
* Commit subject does not end in a period (`subject_period`)
* Commit subject and body are separated by an empty line (`empty_line`)
By default, Commit Lint fails, but you can configure this behavior.
Constant Summary collapse
- NOOP_MESSAGE =
'All checks were disabled, nothing to do.'
Instance Method Summary collapse
- #git ⇒ Object
-
#initialize(plugin, config = {}) ⇒ CommitLint
constructor
A new instance of CommitLint.
- #messaging ⇒ Object
-
#perform ⇒ void
Checks the commits with whatever config the user passes.
Constructor Details
#initialize(plugin, config = {}) ⇒ CommitLint
Returns a new instance of CommitLint.
43 44 45 46 |
# File 'lib/wcc/commit_lint.rb', line 43 def initialize(plugin, config = {}) @plugin = plugin @config = config end |
Instance Method Details
#git ⇒ Object
48 49 50 |
# File 'lib/wcc/commit_lint.rb', line 48 def git @plugin.git end |
#messaging ⇒ Object
52 53 54 |
# File 'lib/wcc/commit_lint.rb', line 52 def messaging @plugin end |
#perform ⇒ void
This method returns an undefined value.
Checks 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:
* `subject_cap`
* `subject_word`
* `subject_length`
* `subject_period`
* `empty_line`
Note: you can pass :all instead of an array to target all checks.
78 79 80 81 82 83 84 |
# File 'lib/wcc/commit_lint.rb', line 78 def perform if all_checks_disabled? messaging.warn NOOP_MESSAGE else end end |