danger-commit_lint 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +77 -0
- data/Dangerfile +1 -0
- data/README.md +1 -0
- data/lib/commit_lint/gem_version.rb +1 -1
- data/lib/commit_lint/plugin.rb +24 -4
- data/lib/commit_lint/subject_words_check.rb +19 -0
- data/lib/danger_plugin.rb +1 -0
- data/spec/commit_lint_spec.rb +80 -30
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f4dbf495b8baeb61eb02cd6966df4da7c2a0a58
|
4
|
+
data.tar.gz: a2042652a29ce9ac46e469fc5a4e31dbdee03b2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72e792a4cbea18e5678b7cd348d8cf5315bcad18f1b7a29844f00376e7441b93c1b7c8f30feda43922c5bca815c8b96036d9009bfb581fbc4112ba0c484d6e2
|
7
|
+
data.tar.gz: 05c59322a26736290fc1eda2e06afdf300ea1d782d7afd15b24ba8815de0bb6a622b08afcd3a52a33ea44bfe2dc90199fb2365fdb790bfe8699ebf4082013cd8
|
data/.travis.yml
CHANGED
@@ -3,16 +3,17 @@ language: ruby
|
|
3
3
|
cache: bundler
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
- 2.1
|
7
6
|
- 2.2
|
8
|
-
- 2.3.
|
7
|
+
- 2.3.3
|
8
|
+
- 2.4.0
|
9
9
|
- jruby-9
|
10
10
|
|
11
11
|
script:
|
12
12
|
- bundle exec rake
|
13
|
+
- bundle exec danger
|
13
14
|
|
14
15
|
notifications:
|
15
16
|
email: false
|
16
17
|
webhooks:
|
17
18
|
urls:
|
18
|
-
|
19
|
+
secure: F8ECoiEAmcEvw3rC/BtacmqhCfc+uAn8WhwH0ockorPdWIbOihnxGz8C3QIz+Cl8QTAuG9hY5lp/VG5UfpX0XirhuJ1FH9AmIUYnIWkWois6UKyjmBV4VitQDtGAkFzK7hCLZjrAT9PBpeJKkljltRgGQaeMDLpasxzgGO8MlcKe6hoZP6AoUdesOu10kePl6eQN4jXkg0Cr9BrYq93tZuCKvKkkVbTgeyni5RjxfMVyARGsu5+OWcMjMmaTYzs1+FNb+d7odvzMaIpJywS/MKAyE3QmXi2QFTb6ij/A77Z7Cj3MzWSD8MvVQdRfOBNfUhWYQzvaD79JR2ijYajxvcrZN/3gpi8CemKrMrqlPmDtRn/mcY3+37U/wfZfJIfhEYnQDkxR+OszaE2abbI0yYC4xQGySnHMltFkALxIdoPixir/OsO/KgDPMtuuQ2zG9d9xHp0rgeW6MEF99pOHNvCSxdny/p57GyFwKtAf+y37RwegTw6V3SU4hyfiofnndDGWX9F19TrFWwNFd9c2oPOkGdNqUahitEzmkQBFZQ76UPNLX9k1k/dzm0RLW8l1Ypa7J2B/aW6WNOT6Ucz0LvNCIte8svtyRgi60emy1r7uL1ltZ7lafP4eLQnWzyBClW7yTkU4F5AcrQFVuGuaq6up5wYfbIK9RU7ocbsOo10=
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog][keep] and this project adheres to
|
6
|
+
[Semantic Versioning][semver].
|
7
|
+
|
8
|
+
[keep]: http://keepachangelog.com/
|
9
|
+
[semver]: http://semver.org/
|
10
|
+
|
11
|
+
## [Unreleased]
|
12
|
+
|
13
|
+
[Unreleased]: https://github.com/jonallured/danger-commit_lint/compare/v0.0.5...master
|
14
|
+
|
15
|
+
## [0.0.5] - 2016-12-28
|
16
|
+
|
17
|
+
### Added
|
18
|
+
|
19
|
+
* Add Ruby 2.4 to Travis [1aa9cff][1aa9cff]
|
20
|
+
* Add a Dangerfile [51c597a][51c597a]
|
21
|
+
* Add SHA to feedback [35044ae][35044ae]
|
22
|
+
* Add check for one-word commit messages [c2dce9c][c2dce9c]
|
23
|
+
* Add this very CHANGELOG
|
24
|
+
|
25
|
+
### Removed
|
26
|
+
|
27
|
+
* Drop Ruby 2.2 from Travis [1aa9cff][1aa9cff]
|
28
|
+
|
29
|
+
[0.0.5]: https://github.com/jonallured/danger-commit_lint/compare/v0.0.4...0.0.5
|
30
|
+
[1aa9cff]: https://github.com/jonallured/danger-commit_lint/commit/1aa9cff
|
31
|
+
[51c597a]: https://github.com/jonallured/danger-commit_lint/commit/51c597a
|
32
|
+
[35044ae]: https://github.com/jonallured/danger-commit_lint/commit/35044ae
|
33
|
+
[c2dce9c]: https://github.com/jonallured/danger-commit_lint/commit/c2dce9c
|
34
|
+
|
35
|
+
## [0.0.4] - 2016-11-03
|
36
|
+
|
37
|
+
### Changed
|
38
|
+
|
39
|
+
* Upgrade to newest Danger [6fbbdd3][6fbbdd3]
|
40
|
+
|
41
|
+
[0.0.4]: https://github.com/jonallured/danger-commit_lint/compare/v0.0.3...v0.0.4
|
42
|
+
[6fbbdd3]: https://github.com/jonallured/danger-commit_lint/commit/6fbbdd3
|
43
|
+
|
44
|
+
## [0.0.3] - 2016-10-07
|
45
|
+
|
46
|
+
### Added
|
47
|
+
|
48
|
+
* Added JRuby to Travis [2266134][2266134]
|
49
|
+
|
50
|
+
### Changed
|
51
|
+
|
52
|
+
* Improved the inline docs [c5f7408][c5f7408]
|
53
|
+
* Improved README [71ce9f9][71ce9f9] [c58e34c][c58e34c]
|
54
|
+
|
55
|
+
[0.0.3]: https://github.com/jonallured/danger-commit_lint/compare/v0.0.2...v0.0.3
|
56
|
+
[2266134]: https://github.com/jonallured/danger-commit_lint/commit/2266134
|
57
|
+
[c5f7408]: https://github.com/jonallured/danger-commit_lint/commit/c5f7408
|
58
|
+
[71ce9f9]: https://github.com/jonallured/danger-commit_lint/commit/71ce9f9
|
59
|
+
[c58e34c]: https://github.com/jonallured/danger-commit_lint/commit/c58e34c
|
60
|
+
|
61
|
+
## [0.0.2] - 2016-09-01
|
62
|
+
|
63
|
+
### Added
|
64
|
+
|
65
|
+
* Added a check to ensure first letter is capitalized [4a691ef][4a691ef]
|
66
|
+
|
67
|
+
### Changed
|
68
|
+
|
69
|
+
* Switched to using the internal API for warn/error [9ca11d6][9ca11d6]
|
70
|
+
|
71
|
+
[0.0.2]: https://github.com/jonallured/danger-commit_lint/compare/v0.0.1...v0.0.2
|
72
|
+
[4a691ef]: https://github.com/jonallured/danger-commit_lint/commit/4a691ef
|
73
|
+
[9ca11d6]: https://github.com/jonallured/danger-commit_lint/commit/9ca11d6
|
74
|
+
|
75
|
+
## 0.0.1 - 2016-08-26
|
76
|
+
|
77
|
+
Initial release
|
data/Dangerfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
commit_lint.check
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ commit_lint.check
|
|
28
28
|
That will check each commit in the PR to ensure the following is true:
|
29
29
|
|
30
30
|
* Commit subject begins with a capital letter (`subject_cap`)
|
31
|
+
* Commit subject is more than one word (`subject_word`)
|
31
32
|
* Commit subject is no longer than 50 characters (`subject_length`)
|
32
33
|
* Commit subject does not end in a period (`subject_period`)
|
33
34
|
* Commit subject and body are separated by an empty line (`empty_line`)
|
data/lib/commit_lint/plugin.rb
CHANGED
@@ -5,6 +5,7 @@ module Danger
|
|
5
5
|
# true:
|
6
6
|
#
|
7
7
|
# * Commit subject begins with a capital letter (`subject_cap`)
|
8
|
+
# * Commit subject is more than one word (`subject_word`)
|
8
9
|
# * Commit subject is no longer than 50 characters (`subject_length`)
|
9
10
|
# * Commit subject does not end in a period (`subject_period`)
|
10
11
|
# * Commit subject and body are separated by an empty line (`empty_line`)
|
@@ -41,6 +42,7 @@ module Danger
|
|
41
42
|
# The current check types are:
|
42
43
|
#
|
43
44
|
# * `subject_cap`
|
45
|
+
# * `subject_word`
|
44
46
|
# * `subject_length`
|
45
47
|
# * `subject_period`
|
46
48
|
# * `empty_line`
|
@@ -66,17 +68,23 @@ module Danger
|
|
66
68
|
def check_messages
|
67
69
|
for message in messages
|
68
70
|
for klass in warning_checkers
|
69
|
-
|
71
|
+
issue_warning(klass::MESSAGE, message[:sha]) if klass.fail? message
|
70
72
|
end
|
71
73
|
|
72
74
|
for klass in failing_checkers
|
73
|
-
|
75
|
+
issue_failure(klass::MESSAGE, message[:sha]) if klass.fail? message
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
80
|
def checkers
|
79
|
-
[
|
81
|
+
[
|
82
|
+
SubjectCapCheck,
|
83
|
+
SubjectWordsCheck,
|
84
|
+
SubjectLengthCheck,
|
85
|
+
SubjectPeriodCheck,
|
86
|
+
EmptyLineCheck
|
87
|
+
]
|
80
88
|
end
|
81
89
|
|
82
90
|
def checks
|
@@ -111,8 +119,20 @@ module Danger
|
|
111
119
|
def messages
|
112
120
|
git.commits.map do |commit|
|
113
121
|
(subject, empty_line) = commit.message.split("\n")
|
114
|
-
{
|
122
|
+
{
|
123
|
+
subject: subject,
|
124
|
+
empty_line: empty_line,
|
125
|
+
sha: commit.sha
|
126
|
+
}
|
115
127
|
end
|
116
128
|
end
|
129
|
+
|
130
|
+
def issue_warning(message, sha)
|
131
|
+
messaging.warn [message, sha].join("\n")
|
132
|
+
end
|
133
|
+
|
134
|
+
def issue_failure(message, sha)
|
135
|
+
messaging.fail [message, sha].join("\n")
|
136
|
+
end
|
117
137
|
end
|
118
138
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Danger
|
2
|
+
class DangerCommitLint < Plugin
|
3
|
+
class SubjectWordsCheck < CommitCheck # :nodoc:
|
4
|
+
MESSAGE = 'Please use more than one word.'.freeze
|
5
|
+
|
6
|
+
def self.type
|
7
|
+
:subject_words
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(message)
|
11
|
+
@subject = message[:subject]
|
12
|
+
end
|
13
|
+
|
14
|
+
def fail?
|
15
|
+
@subject.split.count < 2
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/danger_plugin.rb
CHANGED
data/spec/commit_lint_spec.rb
CHANGED
@@ -4,6 +4,7 @@ require File.expand_path('../spec_helper', __FILE__)
|
|
4
4
|
|
5
5
|
TEST_MESSAGES = {
|
6
6
|
subject_cap: 'this subject needs a capital',
|
7
|
+
subject_words: 'Fixed',
|
7
8
|
subject_length: 'This is a really long subject line and should result in an error',
|
8
9
|
subject_period: 'This subject line ends in a period.',
|
9
10
|
empty_line: "This subject line is fine\nBut then I forgot the empty line separating the subject and the body.",
|
@@ -28,10 +29,18 @@ module Danger
|
|
28
29
|
end
|
29
30
|
|
30
31
|
describe 'check without configuration' do
|
32
|
+
let(:sha) { '1234567' }
|
33
|
+
let(:commit) { double(:commit, message: message, sha: sha) }
|
34
|
+
|
35
|
+
def message_with_sha(message)
|
36
|
+
[message, sha].join "\n"
|
37
|
+
end
|
38
|
+
|
31
39
|
context 'with invalid messages' do
|
32
40
|
it 'fails those checks' do
|
33
41
|
checks = {
|
34
42
|
subject_cap: SubjectCapCheck::MESSAGE,
|
43
|
+
subject_words: SubjectWordsCheck::MESSAGE,
|
35
44
|
subject_length: SubjectLengthCheck::MESSAGE,
|
36
45
|
subject_period: SubjectPeriodCheck::MESSAGE,
|
37
46
|
empty_line: EmptyLineCheck::MESSAGE
|
@@ -39,22 +48,25 @@ module Danger
|
|
39
48
|
|
40
49
|
for (check, warning) in checks
|
41
50
|
commit_lint = testing_dangerfile.commit_lint
|
42
|
-
commit = double(:commit, message: TEST_MESSAGES[check])
|
51
|
+
commit = double(:commit, message: TEST_MESSAGES[check], sha: sha)
|
43
52
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
44
53
|
|
45
54
|
commit_lint.check
|
46
55
|
|
47
56
|
status_report = commit_lint.status_report
|
48
57
|
expect(report_counts(status_report)).to eq 1
|
49
|
-
expect(status_report[:errors]).to eq [
|
58
|
+
expect(status_report[:errors]).to eq [
|
59
|
+
message_with_sha(warning)
|
60
|
+
]
|
50
61
|
end
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
54
65
|
context 'with all errors' do
|
66
|
+
let(:message) { TEST_MESSAGES[:all_errors] }
|
67
|
+
|
55
68
|
it 'fails every check' do
|
56
69
|
commit_lint = testing_dangerfile.commit_lint
|
57
|
-
commit = double(:commit, message: TEST_MESSAGES[:all_errors])
|
58
70
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
59
71
|
|
60
72
|
commit_lint.check
|
@@ -62,15 +74,17 @@ module Danger
|
|
62
74
|
status_report = commit_lint.status_report
|
63
75
|
expect(report_counts(status_report)).to eq 4
|
64
76
|
expect(status_report[:errors]).to eq [
|
65
|
-
SubjectCapCheck::MESSAGE,
|
66
|
-
SubjectLengthCheck::MESSAGE,
|
67
|
-
SubjectPeriodCheck::MESSAGE,
|
68
|
-
EmptyLineCheck::MESSAGE
|
77
|
+
message_with_sha(SubjectCapCheck::MESSAGE),
|
78
|
+
message_with_sha(SubjectLengthCheck::MESSAGE),
|
79
|
+
message_with_sha(SubjectPeriodCheck::MESSAGE),
|
80
|
+
message_with_sha(EmptyLineCheck::MESSAGE)
|
69
81
|
]
|
70
82
|
end
|
71
83
|
end
|
72
84
|
|
73
85
|
context 'with valid messages' do
|
86
|
+
let(:message) { TEST_MESSAGES[:valid] }
|
87
|
+
|
74
88
|
it 'does nothing' do
|
75
89
|
checks = {
|
76
90
|
subject_length: SubjectLengthCheck::MESSAGE,
|
@@ -80,7 +94,6 @@ module Danger
|
|
80
94
|
|
81
95
|
for _ in checks
|
82
96
|
commit_lint = testing_dangerfile.commit_lint
|
83
|
-
commit = double(:commit, message: TEST_MESSAGES[:valid])
|
84
97
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
85
98
|
|
86
99
|
commit_lint.check
|
@@ -93,6 +106,13 @@ module Danger
|
|
93
106
|
end
|
94
107
|
|
95
108
|
describe 'disable configuration' do
|
109
|
+
let(:sha) { '1234567' }
|
110
|
+
let(:commit) { double(:commit, message: message, sha: sha) }
|
111
|
+
|
112
|
+
def message_with_sha(message)
|
113
|
+
[message, sha].join "\n"
|
114
|
+
end
|
115
|
+
|
96
116
|
context 'with individual checks' do
|
97
117
|
context 'with invalid messages' do
|
98
118
|
it 'does nothing' do
|
@@ -104,7 +124,7 @@ module Danger
|
|
104
124
|
|
105
125
|
for (check, _) in checks
|
106
126
|
commit_lint = testing_dangerfile.commit_lint
|
107
|
-
commit = double(:commit, message: TEST_MESSAGES[check])
|
127
|
+
commit = double(:commit, message: TEST_MESSAGES[check], sha: sha)
|
108
128
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
109
129
|
|
110
130
|
commit_lint.check disable: [check]
|
@@ -117,13 +137,18 @@ module Danger
|
|
117
137
|
end
|
118
138
|
|
119
139
|
context 'with all checks, implicitly' do
|
140
|
+
let(:message) { TEST_MESSAGES[:all_errors] }
|
141
|
+
|
120
142
|
it 'warns that nothing was checked' do
|
121
143
|
commit_lint = testing_dangerfile.commit_lint
|
122
|
-
commit = double(:commit, message: TEST_MESSAGES[:all_errors])
|
123
144
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
124
145
|
|
125
146
|
all_checks = [
|
126
|
-
:subject_cap,
|
147
|
+
:subject_cap,
|
148
|
+
:subject_words,
|
149
|
+
:subject_length,
|
150
|
+
:subject_period,
|
151
|
+
:empty_line
|
127
152
|
]
|
128
153
|
commit_lint.check disable: all_checks
|
129
154
|
|
@@ -134,9 +159,10 @@ module Danger
|
|
134
159
|
end
|
135
160
|
|
136
161
|
context 'with all checks, explicitly' do
|
162
|
+
let(:message) { TEST_MESSAGES[:all_errors] }
|
163
|
+
|
137
164
|
it 'warns that nothing was checked' do
|
138
165
|
commit_lint = testing_dangerfile.commit_lint
|
139
|
-
commit = double(:commit, message: TEST_MESSAGES[:all_errors])
|
140
166
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
141
167
|
|
142
168
|
commit_lint.check disable: :all
|
@@ -149,6 +175,13 @@ module Danger
|
|
149
175
|
end
|
150
176
|
|
151
177
|
describe 'warn configuration' do
|
178
|
+
let(:sha) { '1234567' }
|
179
|
+
let(:commit) { double(:commit, message: message, sha: sha) }
|
180
|
+
|
181
|
+
def message_with_sha(message)
|
182
|
+
[message, sha].join "\n"
|
183
|
+
end
|
184
|
+
|
152
185
|
context 'with individual checks' do
|
153
186
|
context 'with invalid messages' do
|
154
187
|
it 'warns instead of failing' do
|
@@ -160,19 +193,23 @@ module Danger
|
|
160
193
|
|
161
194
|
for (check, warning) in checks
|
162
195
|
commit_lint = testing_dangerfile.commit_lint
|
163
|
-
commit = double(:commit, message: TEST_MESSAGES[check])
|
196
|
+
commit = double(:commit, message: TEST_MESSAGES[check], sha: sha)
|
164
197
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
165
198
|
|
166
199
|
commit_lint.check warn: [check]
|
167
200
|
|
168
201
|
status_report = commit_lint.status_report
|
169
202
|
expect(report_counts(status_report)).to eq 1
|
170
|
-
expect(status_report[:warnings]).to eq [
|
203
|
+
expect(status_report[:warnings]).to eq [
|
204
|
+
message_with_sha(warning)
|
205
|
+
]
|
171
206
|
end
|
172
207
|
end
|
173
208
|
end
|
174
209
|
|
175
210
|
context 'with valid messages' do
|
211
|
+
let(:message) { TEST_MESSAGES[:valid] }
|
212
|
+
|
176
213
|
it 'does nothing' do
|
177
214
|
checks = {
|
178
215
|
subject_length: SubjectLengthCheck::MESSAGE,
|
@@ -182,7 +219,6 @@ module Danger
|
|
182
219
|
|
183
220
|
for (check, _) in checks
|
184
221
|
commit_lint = testing_dangerfile.commit_lint
|
185
|
-
commit = double(:commit, message: TEST_MESSAGES[:valid])
|
186
222
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
187
223
|
|
188
224
|
commit_lint.check warn: [check]
|
@@ -196,9 +232,10 @@ module Danger
|
|
196
232
|
|
197
233
|
context 'with all checks' do
|
198
234
|
context 'with all errors' do
|
235
|
+
let(:message) { TEST_MESSAGES[:all_errors] }
|
236
|
+
|
199
237
|
it 'warns instead of failing' do
|
200
238
|
commit_lint = testing_dangerfile.commit_lint
|
201
|
-
commit = double(:commit, message: TEST_MESSAGES[:all_errors])
|
202
239
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
203
240
|
|
204
241
|
commit_lint.check warn: :all
|
@@ -206,18 +243,19 @@ module Danger
|
|
206
243
|
status_report = commit_lint.status_report
|
207
244
|
expect(report_counts(status_report)).to eq 4
|
208
245
|
expect(status_report[:warnings]).to eq [
|
209
|
-
SubjectCapCheck::MESSAGE,
|
210
|
-
SubjectLengthCheck::MESSAGE,
|
211
|
-
SubjectPeriodCheck::MESSAGE,
|
212
|
-
EmptyLineCheck::MESSAGE
|
246
|
+
message_with_sha(SubjectCapCheck::MESSAGE),
|
247
|
+
message_with_sha(SubjectLengthCheck::MESSAGE),
|
248
|
+
message_with_sha(SubjectPeriodCheck::MESSAGE),
|
249
|
+
message_with_sha(EmptyLineCheck::MESSAGE)
|
213
250
|
]
|
214
251
|
end
|
215
252
|
end
|
216
253
|
|
217
254
|
context 'with a valid message' do
|
255
|
+
let(:message) { TEST_MESSAGES[:valid] }
|
256
|
+
|
218
257
|
it 'does nothing' do
|
219
258
|
commit_lint = testing_dangerfile.commit_lint
|
220
|
-
commit = double(:commit, message: TEST_MESSAGES[:valid])
|
221
259
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
222
260
|
|
223
261
|
commit_lint.check warn: :all
|
@@ -230,6 +268,13 @@ module Danger
|
|
230
268
|
end
|
231
269
|
|
232
270
|
describe 'fail configuration' do
|
271
|
+
let(:sha) { '1234567' }
|
272
|
+
let(:commit) { double(:commit, message: message, sha: sha) }
|
273
|
+
|
274
|
+
def message_with_sha(message)
|
275
|
+
[message, sha].join "\n"
|
276
|
+
end
|
277
|
+
|
233
278
|
context 'with individual checks' do
|
234
279
|
context 'with invalid messages' do
|
235
280
|
it 'fails those checks' do
|
@@ -241,19 +286,23 @@ module Danger
|
|
241
286
|
|
242
287
|
for (check, warning) in checks
|
243
288
|
commit_lint = testing_dangerfile.commit_lint
|
244
|
-
commit = double(:commit, message: TEST_MESSAGES[check])
|
289
|
+
commit = double(:commit, message: TEST_MESSAGES[check], sha: sha)
|
245
290
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
246
291
|
|
247
292
|
commit_lint.check fail: [check]
|
248
293
|
|
249
294
|
status_report = commit_lint.status_report
|
250
295
|
expect(report_counts(status_report)).to eq 1
|
251
|
-
expect(status_report[:errors]).to eq [
|
296
|
+
expect(status_report[:errors]).to eq [
|
297
|
+
message_with_sha(warning)
|
298
|
+
]
|
252
299
|
end
|
253
300
|
end
|
254
301
|
end
|
255
302
|
|
256
303
|
context 'with valid messages' do
|
304
|
+
let(:message) { TEST_MESSAGES[:valid] }
|
305
|
+
|
257
306
|
it 'does nothing' do
|
258
307
|
checks = {
|
259
308
|
subject_length: SubjectLengthCheck::MESSAGE,
|
@@ -263,7 +312,6 @@ module Danger
|
|
263
312
|
|
264
313
|
for (check, _) in checks
|
265
314
|
commit_lint = testing_dangerfile.commit_lint
|
266
|
-
commit = double(:commit, message: TEST_MESSAGES[:valid])
|
267
315
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
268
316
|
|
269
317
|
commit_lint.check fail: [check]
|
@@ -277,9 +325,10 @@ module Danger
|
|
277
325
|
|
278
326
|
context 'with all checks' do
|
279
327
|
context 'with all errors' do
|
328
|
+
let(:message) { TEST_MESSAGES[:all_errors] }
|
329
|
+
|
280
330
|
it 'fails those checks' do
|
281
331
|
commit_lint = testing_dangerfile.commit_lint
|
282
|
-
commit = double(:commit, message: TEST_MESSAGES[:all_errors])
|
283
332
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
284
333
|
|
285
334
|
commit_lint.check fail: :all
|
@@ -287,18 +336,19 @@ module Danger
|
|
287
336
|
status_report = commit_lint.status_report
|
288
337
|
expect(report_counts(status_report)).to eq 4
|
289
338
|
expect(status_report[:errors]).to eq [
|
290
|
-
SubjectCapCheck::MESSAGE,
|
291
|
-
SubjectLengthCheck::MESSAGE,
|
292
|
-
SubjectPeriodCheck::MESSAGE,
|
293
|
-
EmptyLineCheck::MESSAGE
|
339
|
+
message_with_sha(SubjectCapCheck::MESSAGE),
|
340
|
+
message_with_sha(SubjectLengthCheck::MESSAGE),
|
341
|
+
message_with_sha(SubjectPeriodCheck::MESSAGE),
|
342
|
+
message_with_sha(EmptyLineCheck::MESSAGE)
|
294
343
|
]
|
295
344
|
end
|
296
345
|
end
|
297
346
|
|
298
347
|
context 'with a valid message' do
|
348
|
+
let(:message) { TEST_MESSAGES[:valid] }
|
349
|
+
|
299
350
|
it 'does nothing' do
|
300
351
|
commit_lint = testing_dangerfile.commit_lint
|
301
|
-
commit = double(:commit, message: TEST_MESSAGES[:valid])
|
302
352
|
allow(commit_lint.git).to receive(:commits).and_return([commit])
|
303
353
|
|
304
354
|
commit_lint.check fail: :all
|
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.5
|
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-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -118,6 +118,8 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rubocop.yml"
|
120
120
|
- ".travis.yml"
|
121
|
+
- CHANGELOG.md
|
122
|
+
- Dangerfile
|
121
123
|
- Gemfile
|
122
124
|
- LICENSE.txt
|
123
125
|
- README.md
|
@@ -130,6 +132,7 @@ files:
|
|
130
132
|
- lib/commit_lint/subject_cap_check.rb
|
131
133
|
- lib/commit_lint/subject_length_check.rb
|
132
134
|
- lib/commit_lint/subject_period_check.rb
|
135
|
+
- lib/commit_lint/subject_words_check.rb
|
133
136
|
- lib/danger_commit_lint.rb
|
134
137
|
- lib/danger_plugin.rb
|
135
138
|
- spec/commit_lint_spec.rb
|
@@ -154,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
157
|
version: '0'
|
155
158
|
requirements: []
|
156
159
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.6.8
|
158
161
|
signing_key:
|
159
162
|
specification_version: 4
|
160
163
|
summary: A Danger Plugin that ensure commit messages are not too long, don't end in
|