fit-commit 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +14 -1
- data/lib/fit_commit/validators/capitalize_subject.rb +3 -1
- data/lib/fit_commit/version.rb +1 -1
- data/test/unit/validators/capitalize_subject_test.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 053fd82df69f6a201bc1c341874d19f93fc4d0d3
|
4
|
+
data.tar.gz: 896366baa5268106e54a6cb61d2bd4ee580174ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5c3aa65688d618f04095870d714d12175c8d44b3f91c17a49ca0f64164a5f7e52c32ac60469bca960cc41952d089daea751e8197931807ca003c2d1325fd4b8
|
7
|
+
data.tar.gz: 31771420bda1375395de7753d8dec5d6133ac7d07cb96a19a770ccbc8c59740a69e059855b3c115c1e89dfb3e856efeeafbcde828522575df55bf95e8e4d8c8c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -82,7 +82,7 @@ Validators/Bar:
|
|
82
82
|
- !ruby/regexp /\Afoo.+bar/
|
83
83
|
```
|
84
84
|
|
85
|
-
## Adding
|
85
|
+
## Adding Custom Validators
|
86
86
|
|
87
87
|
Create your custom validator as a `FitCommit::Validators::Base` subclass:
|
88
88
|
|
@@ -98,6 +98,19 @@ module FitCommit
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
# A validator can also validate the commit message as a whole:
|
103
|
+
module FitCommit
|
104
|
+
module Validators
|
105
|
+
class MyCustomValidator < Base
|
106
|
+
def validate(lines)
|
107
|
+
if lines.none? { |line| line.text =~ /#\d+/ }
|
108
|
+
add_warning(lines.last.lineno, "Related issue not referenced.")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
101
114
|
```
|
102
115
|
|
103
116
|
`Require` the file and enable the validator in your config:
|
@@ -3,8 +3,10 @@ require "fit_commit/validators/base"
|
|
3
3
|
module FitCommit
|
4
4
|
module Validators
|
5
5
|
class CapitalizeSubject < Base
|
6
|
+
AUTOSQUASH = /\A(fixup|squash)! /
|
7
|
+
|
6
8
|
def validate_line(lineno, text)
|
7
|
-
if lineno == 1 && text[0] =~ /[[:lower:]]/
|
9
|
+
if lineno == 1 && text[0] =~ /[[:lower:]]/ && text !~ AUTOSQUASH
|
8
10
|
add_error(lineno, "Begin all subject lines with a capital letter.")
|
9
11
|
end
|
10
12
|
end
|
data/lib/fit_commit/version.rb
CHANGED
@@ -17,6 +17,22 @@ describe FitCommit::Validators::CapitalizeSubject do
|
|
17
17
|
assert_empty validator.warnings
|
18
18
|
end
|
19
19
|
end
|
20
|
+
describe "subject is fixup commit" do
|
21
|
+
let(:commit_msg) { "fixup! foo bar" }
|
22
|
+
it "does not have errors/warnings" do
|
23
|
+
validator.validate(commit_lines)
|
24
|
+
assert_empty validator.errors
|
25
|
+
assert_empty validator.warnings
|
26
|
+
end
|
27
|
+
end
|
28
|
+
describe "subject is squash commit" do
|
29
|
+
let(:commit_msg) { "squash! foo bar" }
|
30
|
+
it "does not have errors/warnings" do
|
31
|
+
validator.validate(commit_lines)
|
32
|
+
assert_empty validator.errors
|
33
|
+
assert_empty validator.warnings
|
34
|
+
end
|
35
|
+
end
|
20
36
|
describe "subject is capitalized" do
|
21
37
|
let(:commit_msg) { "Foo bar" }
|
22
38
|
it "does not have errors/warnings" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fit-commit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Foley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: swearjar
|