fit-commit 2.2.2 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d21bb9cb6c25372a6a849a323d359560e7124d6e
4
- data.tar.gz: e12f6bbacefa30b78bdb4164b887f9b0dd984402
3
+ metadata.gz: 993eadcd7440c4c9d90a439b33fe1267130b588e
4
+ data.tar.gz: 288bd8d1af9bcd4ad34b868019ef25e59d6c0005
5
5
  SHA512:
6
- metadata.gz: 4fb51830aeae8aef4eb048de4267777fd2652c4c0a1bf6325cbe2104e636fd08a9927c40f03aa0f827af295a7a695994ba95f1071afc34b9c69f396aeb736d0d
7
- data.tar.gz: 7e83385db30baf7bafb7606fe0bd1c358955baacc19f7486ccd1ffb347caf034064c5c3b9d0315577f3b165fb66b44f95e8cc4b143f0300a2a1a511ebbea5830
6
+ metadata.gz: 8657be275a9f8e7f1649b174fa01fc38e3f621eb546c138848f1269635b455e7f760dbfc38c653f2ea31feeb482ef40d0d1d4eb563a42afa976c9a1a04451509
7
+ data.tar.gz: 58084b2d2fb38dd72784ae8e44558c1b18f6b21caf51e190d1644a86fc0abe696c7cc7a583015a03cdf93d44d54ad6709e92821698b480f6aadc421903d42363
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  ### master
4
4
  - N/A
5
5
 
6
+ ### v3.0.0 (2015-09-18)
7
+ - Rename SummaryPeriod validator to SubjectPeriod (can break existing config files)
8
+ - Add CapitalizeSubject validator
9
+
10
+ ### v2.2.2 (2015-09-11)
11
+ - Fix bug where it wasn't working on the first commit of a repo.
12
+
6
13
  ### v2.2.0 (2015-09-09)
7
14
  - Configuration files to customize behavior.
8
15
 
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,24 @@
1
+ # Contributing
2
+
3
+ ## Reporting issues
4
+
5
+ We would love to help if you are having a problem. Feel free to open an issue. We ask that you please provide as much detail as possible.
6
+
7
+ ## Contributing code
8
+
9
+ Contributions are encouraged through GitHub Pull Requests.
10
+
11
+ Guidelines when adding new code:
12
+
13
+ * Create tests when possible.
14
+ * Ensure the entire test suite still passes by running `rake`.
15
+ * Ensure code conventions are maintained by running `rubocop`.
16
+
17
+ ### Adding validations
18
+
19
+ To submit your own validation:
20
+
21
+ * Create your new validation class in `lib/fit_commit/validators/`.
22
+ * Add an entry to the default config settings in `fit_commit.default.yml`. If it's a feature not everyone will want by default, set `Enabled: false`.
23
+ * Create a unit test in `test/unit/validators/`.
24
+ * Update the config defaults & validation descriptions in the README.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fit Commit
2
2
 
3
- A Git hook to validate your commit messages, based largely on Tim Pope's [authoritative guide](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
3
+ A Git hook to validate your commit messages based on [community standards](#who-decided-these-rules).
4
4
 
5
5
  ## Example
6
6
 
@@ -37,7 +37,8 @@ This creates a `.git/hooks/commit-msg` script which will automatically check you
37
37
 
38
38
  * **Line Length**: All lines must be <= 72 chars (URLs excluded). First line should be <= 50 chars. Second line must be blank.
39
39
  * **Tense**: Message must use imperative present tense: "Fix bug" and not "Fixed bug" or "Fixes bug."
40
- * **Summary Period**: Do not end your summary with a period.
40
+ * **Subject Period**: Do not end your subject line with a period.
41
+ * **Capitalize Subject**: Begin all subject lines with a capital letter.
41
42
  * **WIP**: Do not commit WIPs to shared branches.
42
43
  * **Frat House**: No frat house commit messages in shared branches.
43
44
 
@@ -52,11 +53,13 @@ These are the default settings that can be overridden:
52
53
  Validators/LineLength:
53
54
  Enabled: true
54
55
  MaxLineLength: 72
55
- SummaryWarnLength: 50
56
+ SubjectWarnLength: 50
56
57
  AllowLongUrls: true
57
58
  Validators/Tense:
58
59
  Enabled: true
59
- Validators/SummaryPeriod:
60
+ Validators/SubjectPeriod:
61
+ Enabled: true
62
+ Validators/CapitalizeSubject:
60
63
  Enabled: true
61
64
  Validators/Wip:
62
65
  Enabled:
@@ -103,15 +106,15 @@ $ git init
103
106
  ```
104
107
 
105
108
  ### Who decided these rules?
106
- Fit Commit aims to enforce *community standards*. The two influential guides on the subject are:
109
+ Fit Commit aims to enforce *community standards*. The two influential guides are:
107
110
 
108
111
  - [Tim Pope's blog](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
109
112
  - [The official Git documentation](http://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches?id=HEAD)
110
113
 
111
114
  The Git community has largely (but not completely) coalesced around these standards. [Chris Beams](http://chris.beams.io/posts/git-commit/) and the [Pro Git book](https://git-scm.com/book) also provide good summaries on why we have them.
112
115
 
113
- ### Fit Commit is too opinionated for me. What can I do?
114
- Fit Commit aims to be useful to everyone. If you can suggest an improvement to make it useful to more people, please open a GitHub Issue or Pull Request.
116
+ ### How can I improve Fit Commit?
117
+ Fit Commit aims to be useful to everyone. If you can suggest an improvement to make it useful to more people, please open a GitHub Issue or Pull Request. See [CONTRIBUTING.md](CONTRIBUTING.md) for more info.
115
118
 
116
119
 
117
120
  ## Credits
data/fit-commit.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.rdoc_options = ["--main", "README.md"]
20
20
 
21
21
  gem.post_install_message = <<-EOF
22
- Thank you for installing fit-commit!
22
+ Thank you for installing Fit Commit!
23
23
  Install the hook in each git repo you want to scan using:
24
24
 
25
25
  > fit-commit install
@@ -0,0 +1,13 @@
1
+ require "fit_commit/validators/base"
2
+
3
+ module FitCommit
4
+ module Validators
5
+ class CapitalizeSubject < Base
6
+ def validate_line(lineno, text)
7
+ if lineno == 1 && text[0] =~ /[[:lower:]]/
8
+ add_error(lineno, "Begin all subject lines with a capital letter.")
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -5,15 +5,15 @@ module FitCommit
5
5
  class LineLength < Base
6
6
  def validate_line(lineno, text)
7
7
  if lineno == 1 && text.empty?
8
- add_error(lineno, "First line cannot be blank.")
8
+ add_error(lineno, "Subject line cannot be blank.")
9
9
  elsif lineno == 2 && !text.empty?
10
10
  add_error(lineno, "Second line must be blank.")
11
11
  elsif line_too_long?(text)
12
12
  add_error(lineno, format("Lines should be <= %i chars. (%i)",
13
13
  max_line_length, text.length))
14
- elsif lineno == 1 && text.length > summary_warn_length
15
- add_warning(lineno, format("First line should be <= %i chars. (%i)",
16
- summary_warn_length, text.length))
14
+ elsif lineno == 1 && text.length > subject_warn_length
15
+ add_warning(lineno, format("Subject line should be <= %i chars. (%i)",
16
+ subject_warn_length, text.length))
17
17
  end
18
18
  end
19
19
 
@@ -29,8 +29,8 @@ module FitCommit
29
29
  config.fetch("MaxLineLength")
30
30
  end
31
31
 
32
- def summary_warn_length
33
- config.fetch("SummaryWarnLength")
32
+ def subject_warn_length
33
+ config.fetch("SubjectWarnLength")
34
34
  end
35
35
 
36
36
  def allow_long_urls?
@@ -2,10 +2,10 @@ require "fit_commit/validators/base"
2
2
 
3
3
  module FitCommit
4
4
  module Validators
5
- class SummaryPeriod < Base
5
+ class SubjectPeriod < Base
6
6
  def validate_line(lineno, text)
7
7
  if lineno == 1 && text.end_with?(".")
8
- add_error(lineno, "Do not end your summary with a period.")
8
+ add_error(lineno, "Do not end your subject line with a period.")
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module FitCommit
2
- VERSION = "2.2.2"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -2,11 +2,13 @@
2
2
  Validators/LineLength:
3
3
  Enabled: true
4
4
  MaxLineLength: 72
5
- SummaryWarnLength: 50
5
+ SubjectWarnLength: 50
6
6
  AllowLongUrls: true
7
7
  Validators/Tense:
8
8
  Enabled: true
9
- Validators/SummaryPeriod:
9
+ Validators/SubjectPeriod:
10
+ Enabled: true
11
+ Validators/CapitalizeSubject:
10
12
  Enabled: true
11
13
  Validators/Wip:
12
14
  Enabled:
@@ -42,7 +42,7 @@ describe FitCommit::Runner do
42
42
  end
43
43
 
44
44
  describe "commit msg is present but no errors" do
45
- let(:commit_msg) { "hello\n\nhi\n#" }
45
+ let(:commit_msg) { "Hello\n\nhi\n#" }
46
46
  it "allows commit without printing to stderr" do
47
47
  assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
48
48
  assert stderr.read.empty?
@@ -51,7 +51,7 @@ describe FitCommit::Runner do
51
51
 
52
52
  describe "commit msg in verbose format" do
53
53
  let(:commit_msg) do
54
- ["foo", "", "#",
54
+ ["Foo", "", "#",
55
55
  "# ------------------------ >8 ------------------------",
56
56
  "this difftext should be ignored." * 3
57
57
  ].join("\n")
@@ -67,13 +67,14 @@ describe FitCommit::Runner do
67
67
 
68
68
  def assert_error_output
69
69
  stderr_lines = stderr.read.lines.map(&:chomp)
70
- assert_equal 7, stderr_lines.size
70
+ assert_equal 8, stderr_lines.size
71
71
  assert_equal commit_msg, stderr_lines[0..1].join("\n")
72
72
  assert_empty stderr_lines[2]
73
73
  assert_match(/\A1: Error: /, stderr_lines[3])
74
- assert_match(/\A2: Error: /, stderr_lines[4])
75
- assert_empty stderr_lines[5]
76
- assert_equal "Force commit? [y/n] ", stderr_lines[6]
74
+ assert_match(/\A1: Error: /, stderr_lines[4])
75
+ assert_match(/\A2: Error: /, stderr_lines[5])
76
+ assert_empty stderr_lines[6]
77
+ assert_equal "Force commit? [y/n] ", stderr_lines[7]
77
78
  end
78
79
 
79
80
  describe "user does not force commit" do
@@ -7,23 +7,27 @@ describe FitCommit::ValidatorLoader do
7
7
  let(:loader) { FitCommit::ValidatorLoader.new(branch_name, configuration) }
8
8
  let(:branch_name) { "foo" }
9
9
  let(:configuration) do
10
- {
11
- "FitCommit::Validators::LineLength" => { "Enabled" => false },
12
- "FitCommit::Validators::Tense" => { "Enabled" => false },
13
- "FitCommit::Validators::SummaryPeriod" => { "Enabled" => true },
14
- "FitCommit::Validators::Wip" => { "Enabled" => true },
15
- "FitCommit::Validators::Frathouse" => { "Enabled" => ["bar", /\Abaz+/] }
16
- }
10
+ # Starting with all disabled because every validator needs at least a
11
+ # default entry.
12
+ # The ones specified here are the ones we care about testing.
13
+ all_disabled_configuration.merge(
14
+ FitCommit::Validators::LineLength.name => { "Enabled" => false },
15
+ FitCommit::Validators::Wip.name => { "Enabled" => true },
16
+ FitCommit::Validators::Frathouse.name => { "Enabled" => ["bar", /\Abaz+/] }
17
+ )
18
+ end
19
+ let(:all_disabled_configuration) do
20
+ FitCommit::Validators::Base.all.each_with_object({}) do |v, config|
21
+ config[v.name] = { "Enabled" => false }
22
+ end
17
23
  end
18
24
 
19
25
  it "loads enabled validators" do
20
- assert validators.any? { |v| v.is_a? FitCommit::Validators::SummaryPeriod }
21
26
  assert validators.any? { |v| v.is_a? FitCommit::Validators::Wip }
22
27
  end
23
28
 
24
29
  it "doesn't load disabled validators" do
25
30
  assert validators.none? { |v| v.is_a? FitCommit::Validators::LineLength }
26
- assert validators.none? { |v| v.is_a? FitCommit::Validators::Tense }
27
31
  end
28
32
 
29
33
  describe "non-boolean options for Enabled" do
@@ -0,0 +1,36 @@
1
+ require File.expand_path "../validator_helper.rb", __FILE__
2
+ require "fit_commit/validators/capitalize_subject"
3
+ require "fit_commit/line"
4
+
5
+ describe FitCommit::Validators::CapitalizeSubject do
6
+ let(:validator) { FitCommit::Validators::CapitalizeSubject.new(branch_name, config) }
7
+ let(:commit_lines) { FitCommit::Line.from_text_array(commit_msg.split("\n")) }
8
+ let(:default_config) { default_config_for("Validators/CapitalizeSubject") }
9
+ let(:config) { default_config }
10
+ let(:branch_name) { "any" }
11
+
12
+ describe "subject is not capitalized" do
13
+ let(:commit_msg) { "foo bar" }
14
+ it "has error" do
15
+ validator.validate(commit_lines)
16
+ assert_equal 1, validator.errors[1].size
17
+ assert_empty validator.warnings
18
+ end
19
+ end
20
+ describe "subject is capitalized" do
21
+ let(:commit_msg) { "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 capitalized but body is not" do
29
+ let(:commit_msg) { "Foo bar\n\nbaz" }
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
36
+ end
@@ -42,8 +42,8 @@ describe FitCommit::Validators::LineLength do
42
42
  assert_empty validator.warnings
43
43
  end
44
44
  end
45
- describe "SummaryWarnLength modified in config" do
46
- let(:config) { default_config.merge("SummaryWarnLength" => 5) }
45
+ describe "SubjectWarnLength modified in config" do
46
+ let(:config) { default_config.merge("SubjectWarnLength" => 5) }
47
47
  describe "first line is over modified warning limit" do
48
48
  let(:commit_msg) { "x" * 6 }
49
49
  it "has a warning" do
@@ -1,15 +1,15 @@
1
1
  require File.expand_path "../validator_helper.rb", __FILE__
2
- require "fit_commit/validators/summary_period"
2
+ require "fit_commit/validators/subject_period"
3
3
  require "fit_commit/line"
4
4
 
5
- describe FitCommit::Validators::SummaryPeriod do
6
- let(:validator) { FitCommit::Validators::SummaryPeriod.new(branch_name, config) }
5
+ describe FitCommit::Validators::SubjectPeriod do
6
+ let(:validator) { FitCommit::Validators::SubjectPeriod.new(branch_name, config) }
7
7
  let(:commit_lines) { FitCommit::Line.from_text_array(commit_msg.split("\n")) }
8
- let(:default_config) { default_config_for("Validators/SummaryPeriod") }
8
+ let(:default_config) { default_config_for("Validators/SubjectPeriod") }
9
9
  let(:config) { default_config }
10
10
  let(:branch_name) { "any" }
11
11
 
12
- describe "summary ends with period" do
12
+ describe "subject ends with period" do
13
13
  let(:commit_msg) { "foo bar." }
14
14
  it "has error" do
15
15
  validator.validate(commit_lines)
@@ -17,7 +17,7 @@ describe FitCommit::Validators::SummaryPeriod do
17
17
  assert_empty validator.warnings
18
18
  end
19
19
  end
20
- describe "summary does not end with period" do
20
+ describe "subject does not end with period" do
21
21
  let(:commit_msg) { "foo bar\n\nhi." }
22
22
  it "does not have errors/warnings" do
23
23
  validator.validate(commit_lines)
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: 2.2.2
4
+ version: 3.0.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-09-12 00:00:00.000000000 Z
11
+ date: 2015-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: swearjar
@@ -65,6 +65,7 @@ files:
65
65
  - ".gitignore"
66
66
  - ".rubocop.yml"
67
67
  - CHANGELOG.md
68
+ - CONTRIBUTING.md
68
69
  - Gemfile
69
70
  - LICENSE
70
71
  - README.md
@@ -81,9 +82,10 @@ files:
81
82
  - lib/fit_commit/runner.rb
82
83
  - lib/fit_commit/validator_loader.rb
83
84
  - lib/fit_commit/validators/base.rb
85
+ - lib/fit_commit/validators/capitalize_subject.rb
84
86
  - lib/fit_commit/validators/frathouse.rb
85
87
  - lib/fit_commit/validators/line_length.rb
86
- - lib/fit_commit/validators/summary_period.rb
88
+ - lib/fit_commit/validators/subject_period.rb
87
89
  - lib/fit_commit/validators/tense.rb
88
90
  - lib/fit_commit/validators/wip.rb
89
91
  - lib/fit_commit/version.rb
@@ -94,9 +96,10 @@ files:
94
96
  - test/unit/message_parser_test.rb
95
97
  - test/unit/runner_test.rb
96
98
  - test/unit/validator_loader_test.rb
99
+ - test/unit/validators/capitalize_subject_test.rb
97
100
  - test/unit/validators/frathouse_test.rb
98
101
  - test/unit/validators/line_length_test.rb
99
- - test/unit/validators/summary_period_test.rb
102
+ - test/unit/validators/subject_period_test.rb
100
103
  - test/unit/validators/tense_test.rb
101
104
  - test/unit/validators/validator_helper.rb
102
105
  - test/unit/validators/wip_test.rb
@@ -105,7 +108,7 @@ licenses:
105
108
  - MIT
106
109
  metadata: {}
107
110
  post_install_message: |2
108
- Thank you for installing fit-commit!
111
+ Thank you for installing Fit Commit!
109
112
  Install the hook in each git repo you want to scan using:
110
113
 
111
114
  > fit-commit install
@@ -138,9 +141,10 @@ test_files:
138
141
  - test/unit/message_parser_test.rb
139
142
  - test/unit/runner_test.rb
140
143
  - test/unit/validator_loader_test.rb
144
+ - test/unit/validators/capitalize_subject_test.rb
141
145
  - test/unit/validators/frathouse_test.rb
142
146
  - test/unit/validators/line_length_test.rb
143
- - test/unit/validators/summary_period_test.rb
147
+ - test/unit/validators/subject_period_test.rb
144
148
  - test/unit/validators/tense_test.rb
145
149
  - test/unit/validators/validator_helper.rb
146
150
  - test/unit/validators/wip_test.rb