danger-commit_lint 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -11
- data/lib/commit_lint/gem_version.rb +1 -1
- data/lib/commit_lint/plugin.rb +5 -6
- data/lib/commit_lint/subject_cap_check.rb +19 -0
- data/lib/danger_plugin.rb +1 -0
- data/spec/commit_lint_spec.rb +12 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17d0cf1ee03d53740dba93d7473a038edef5004b
|
4
|
+
data.tar.gz: 62c86199bef076c8b1843ff6135cda719a489945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ecc81d9d7a04407a91766f1461ef7084c7c5595f4582799f7b69803892c5f5c7e3dc96a482fad6de0c028d2bd6bd6fd860164f4612831e8a9870cec19338a85
|
7
|
+
data.tar.gz: 5978036983219fe4ab704ff39a25df63b32f78a09d943d00ecbf15e56f79402bd52e0e531e592d75c89591faec4078446445673f80276fd2f0a12deb28de85ac
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
This is a [Danger Plugin][danger] that ensures nice and tidy commit messages.
|
6
6
|
|
7
|
+
[danger]: https://github.com/danger/danger
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
```
|
@@ -20,6 +22,7 @@ commit_lint.check
|
|
20
22
|
|
21
23
|
That will check each commit in the PR to ensure the following is true:
|
22
24
|
|
25
|
+
* Commit subject begins with a capital letter (`subject_cap`)
|
23
26
|
* Commit subject is no longer than 50 characters (`subject_length`)
|
24
27
|
* Commit subject does not end in a period (`subject_period`)
|
25
28
|
* Commit subject and body are separated by an empty line (`empty_line`)
|
@@ -56,17 +59,7 @@ commit_lint.check fail: :all
|
|
56
59
|
Also note that there is one more way that Commit Lint can behave:
|
57
60
|
|
58
61
|
```ruby
|
59
|
-
commit_lint.check
|
62
|
+
commit_lint.check disable: :all
|
60
63
|
```
|
61
64
|
|
62
65
|
This will actually throw a warning that Commit Lint isn't doing anything.
|
63
|
-
|
64
|
-
## Development
|
65
|
-
|
66
|
-
1. Clone this repo
|
67
|
-
2. Run `bundle install` to setup dependencies.
|
68
|
-
3. Run `bundle exec rake spec` to run the tests.
|
69
|
-
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
70
|
-
5. Make your changes.
|
71
|
-
|
72
|
-
[danger]: https://github.com/danger/danger
|
data/lib/commit_lint/plugin.rb
CHANGED
@@ -30,6 +30,7 @@ module Danger
|
|
30
30
|
#
|
31
31
|
# The current check types are:
|
32
32
|
#
|
33
|
+
# * `subject_cap`
|
33
34
|
# * `subject_length`
|
34
35
|
# * `subject_period`
|
35
36
|
# * `empty_line`
|
@@ -42,7 +43,7 @@ module Danger
|
|
42
43
|
@config = config
|
43
44
|
|
44
45
|
if all_checks_disabled?
|
45
|
-
warn NOOP_MESSAGE
|
46
|
+
messaging.warn NOOP_MESSAGE
|
46
47
|
else
|
47
48
|
check_messages
|
48
49
|
end
|
@@ -53,19 +54,17 @@ module Danger
|
|
53
54
|
def check_messages
|
54
55
|
for message in messages
|
55
56
|
for klass in warning_checkers
|
56
|
-
warn klass::MESSAGE if klass.fail? message
|
57
|
+
messaging.warn klass::MESSAGE if klass.fail? message
|
57
58
|
end
|
58
59
|
|
59
60
|
for klass in failing_checkers
|
60
|
-
|
61
|
-
fail klass::MESSAGE if klass.fail? message
|
62
|
-
# rubocop:enable Style/SignalException
|
61
|
+
messaging.fail klass::MESSAGE if klass.fail? message
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
66
|
def checkers
|
68
|
-
[SubjectLengthCheck, SubjectPeriodCheck, EmptyLineCheck]
|
67
|
+
[SubjectCapCheck, SubjectLengthCheck, SubjectPeriodCheck, EmptyLineCheck]
|
69
68
|
end
|
70
69
|
|
71
70
|
def checks
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Danger
|
2
|
+
class DangerCommitLint < Plugin
|
3
|
+
class SubjectCapCheck < CommitCheck # :nodoc:
|
4
|
+
MESSAGE = 'Please start subject with capital letter.'.freeze
|
5
|
+
|
6
|
+
def self.type
|
7
|
+
:subject_cap
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(message)
|
11
|
+
@first_character = message[:subject].split('').first
|
12
|
+
end
|
13
|
+
|
14
|
+
def fail?
|
15
|
+
@first_character != @first_character.upcase
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/danger_plugin.rb
CHANGED
data/spec/commit_lint_spec.rb
CHANGED
@@ -3,10 +3,11 @@ require File.expand_path('../spec_helper', __FILE__)
|
|
3
3
|
# rubocop:disable Metrics/LineLength
|
4
4
|
|
5
5
|
TEST_MESSAGES = {
|
6
|
+
subject_cap: 'this subject needs a capital',
|
6
7
|
subject_length: 'This is a really long subject line and should result in an error',
|
7
8
|
subject_period: 'This subject line ends in a period.',
|
8
9
|
empty_line: "This subject line is fine\nBut then I forgot the empty line separating the subject and the body.",
|
9
|
-
all_errors: "
|
10
|
+
all_errors: "this is a really long subject and it even ends in a period.\nNot to mention the missing empty line!",
|
10
11
|
valid: "This is a valid message\n\nYou can tell because it meets all the criteria and the linter does not complain."
|
11
12
|
}.freeze
|
12
13
|
|
@@ -30,6 +31,7 @@ module Danger
|
|
30
31
|
context 'with invalid messages' do
|
31
32
|
it 'fails those checks' do
|
32
33
|
checks = {
|
34
|
+
subject_cap: SubjectCapCheck::MESSAGE,
|
33
35
|
subject_length: SubjectLengthCheck::MESSAGE,
|
34
36
|
subject_period: SubjectPeriodCheck::MESSAGE,
|
35
37
|
empty_line: EmptyLineCheck::MESSAGE
|
@@ -58,8 +60,9 @@ module Danger
|
|
58
60
|
commit_lint.check
|
59
61
|
|
60
62
|
status_report = commit_lint.status_report
|
61
|
-
expect(report_counts(status_report)).to eq
|
63
|
+
expect(report_counts(status_report)).to eq 4
|
62
64
|
expect(status_report[:errors]).to eq [
|
65
|
+
SubjectCapCheck::MESSAGE,
|
63
66
|
SubjectLengthCheck::MESSAGE,
|
64
67
|
SubjectPeriodCheck::MESSAGE,
|
65
68
|
EmptyLineCheck::MESSAGE
|
@@ -119,7 +122,9 @@ module Danger
|
|
119
122
|
commit = double(:commit, message: TEST_MESSAGES[:all_errors])
|
120
123
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
121
124
|
|
122
|
-
all_checks = [
|
125
|
+
all_checks = [
|
126
|
+
:subject_cap, :subject_length, :subject_period, :empty_line
|
127
|
+
]
|
123
128
|
commit_lint.check disable: all_checks
|
124
129
|
|
125
130
|
status_report = commit_lint.status_report
|
@@ -199,8 +204,9 @@ module Danger
|
|
199
204
|
commit_lint.check warn: :all
|
200
205
|
|
201
206
|
status_report = commit_lint.status_report
|
202
|
-
expect(report_counts(status_report)).to eq
|
207
|
+
expect(report_counts(status_report)).to eq 4
|
203
208
|
expect(status_report[:warnings]).to eq [
|
209
|
+
SubjectCapCheck::MESSAGE,
|
204
210
|
SubjectLengthCheck::MESSAGE,
|
205
211
|
SubjectPeriodCheck::MESSAGE,
|
206
212
|
EmptyLineCheck::MESSAGE
|
@@ -279,8 +285,9 @@ module Danger
|
|
279
285
|
commit_lint.check fail: :all
|
280
286
|
|
281
287
|
status_report = commit_lint.status_report
|
282
|
-
expect(report_counts(status_report)).to eq
|
288
|
+
expect(report_counts(status_report)).to eq 4
|
283
289
|
expect(status_report[:errors]).to eq [
|
290
|
+
SubjectCapCheck::MESSAGE,
|
284
291
|
SubjectLengthCheck::MESSAGE,
|
285
292
|
SubjectPeriodCheck::MESSAGE,
|
286
293
|
EmptyLineCheck::MESSAGE
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-commit_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Allured
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/commit_lint/empty_line_check.rb
|
128
128
|
- lib/commit_lint/gem_version.rb
|
129
129
|
- lib/commit_lint/plugin.rb
|
130
|
+
- lib/commit_lint/subject_cap_check.rb
|
130
131
|
- lib/commit_lint/subject_length_check.rb
|
131
132
|
- lib/commit_lint/subject_period_check.rb
|
132
133
|
- lib/danger_commit_lint.rb
|