fit-commit 2.2.0 → 2.2.1
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/README.md +5 -4
- data/lib/fit_commit/runner.rb +9 -9
- data/lib/fit_commit/version.rb +1 -1
- data/test/runner_test.rb +21 -21
- 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: c77c51765ec627e156a600d56c8b1482177a5c5c
|
4
|
+
data.tar.gz: caa7c6910ee5dace99a7f0e803c8e06695a7f91b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2d08fbaf7df3343c3cec005bd5bde68d3837775c3c3659e7aea47aca5f48315abfc45c9e237f609016d6f876196bc640f417717b3b2a0df82c90ddf208ab90
|
7
|
+
data.tar.gz: 76b7092a38bed2ca405ffc9bf000a004689939b6aa9caa6c370a313747c6f5aae965683d4afd8d93e417cfe8d14cbec5168f01483e47a3a865bc5a6f048fa029
|
data/README.md
CHANGED
@@ -43,9 +43,9 @@ This creates a `.git/hooks/commit-msg` script which will automatically check you
|
|
43
43
|
|
44
44
|
## Configuration
|
45
45
|
|
46
|
-
Settings are read from these files
|
46
|
+
Settings are read from these files in increasing precedence: `/etc/fit_commit.yml`, `$HOME/.fit_commit.yml`, `config/fit_commit.yml`, `./.fit_commit.yml`.
|
47
47
|
|
48
|
-
|
48
|
+
These are the default settings that can be overridden:
|
49
49
|
|
50
50
|
```yaml
|
51
51
|
---
|
@@ -69,7 +69,7 @@ Validators/Frathouse:
|
|
69
69
|
The `Enabled` property accepts multiple formats:
|
70
70
|
|
71
71
|
```yaml
|
72
|
-
# true/false
|
72
|
+
# true/false to enable/disable the validation (branch agnostic)
|
73
73
|
Validators/Foo:
|
74
74
|
Enabled: false
|
75
75
|
# Array of String/Regex matching each branch for which it's enabled
|
@@ -86,13 +86,14 @@ First set your global Git template directory:
|
|
86
86
|
|
87
87
|
```
|
88
88
|
$ git config --global init.templatedir '~/.git_template'
|
89
|
+
$ mkdir -p ~/.git_template/hooks
|
89
90
|
```
|
90
91
|
|
91
92
|
Now you can copy the hooks you want installed in new repos by default:
|
92
93
|
|
93
94
|
```
|
94
95
|
# From a repo where Fit Commit is already installed
|
95
|
-
$ cp .git/hooks/commit-msg ~/.
|
96
|
+
$ cp .git/hooks/commit-msg ~/.git_template/hooks/commit-msg
|
96
97
|
```
|
97
98
|
|
98
99
|
To copy your default hooks into existing repos:
|
data/lib/fit_commit/runner.rb
CHANGED
@@ -9,11 +9,11 @@ module FitCommit
|
|
9
9
|
EXIT_CODE_ALLOW_COMMIT = 0
|
10
10
|
EXIT_CODE_REJECT_COMMIT = 1
|
11
11
|
|
12
|
-
attr_accessor :message_path, :branch_name, :
|
13
|
-
def initialize(message_path, branch_name,
|
12
|
+
attr_accessor :message_path, :branch_name, :stderr, :stdin
|
13
|
+
def initialize(message_path, branch_name, stderr = $stderr, stdin = $stdin)
|
14
14
|
self.message_path = message_path
|
15
15
|
self.branch_name = branch_name
|
16
|
-
self.
|
16
|
+
self.stderr = stderr
|
17
17
|
self.stdin = stdin
|
18
18
|
end
|
19
19
|
|
@@ -25,12 +25,12 @@ module FitCommit
|
|
25
25
|
|
26
26
|
allow_commit = errors.empty?
|
27
27
|
unless allow_commit
|
28
|
-
|
28
|
+
stderr.print "\nForce commit? [y/n] "
|
29
29
|
return EXIT_CODE_REJECT_COMMIT unless stdin.gets =~ /y/i
|
30
30
|
allow_commit = true
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
stderr.print "\n"
|
34
34
|
allow_commit ? EXIT_CODE_ALLOW_COMMIT : EXIT_CODE_REJECT_COMMIT
|
35
35
|
rescue Interrupt # Ctrl-c
|
36
36
|
EXIT_CODE_REJECT_COMMIT
|
@@ -52,16 +52,16 @@ module FitCommit
|
|
52
52
|
|
53
53
|
def print_results
|
54
54
|
unless errors.empty?
|
55
|
-
|
56
|
-
|
55
|
+
stderr.puts lines
|
56
|
+
stderr.print "\n"
|
57
57
|
end
|
58
58
|
|
59
59
|
(errors.keys | warnings.keys).sort.each do |lineno|
|
60
60
|
errors[lineno].each do |error|
|
61
|
-
|
61
|
+
stderr.puts "#{lineno}: Error: #{error}"
|
62
62
|
end
|
63
63
|
warnings[lineno].each do |warning|
|
64
|
-
|
64
|
+
stderr.puts "#{lineno}: Warning: #{warning}"
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/lib/fit_commit/version.rb
CHANGED
data/test/runner_test.rb
CHANGED
@@ -8,7 +8,7 @@ describe FitCommit::Runner do
|
|
8
8
|
|
9
9
|
def call_runner
|
10
10
|
exit_code = runner.run
|
11
|
-
|
11
|
+
stderr.rewind
|
12
12
|
exit_code
|
13
13
|
end
|
14
14
|
|
@@ -18,34 +18,34 @@ describe FitCommit::Runner do
|
|
18
18
|
f.close
|
19
19
|
end
|
20
20
|
end
|
21
|
-
let(:
|
21
|
+
let(:stderr) { StringIO.new }
|
22
22
|
let(:stdin) { StringIO.new }
|
23
23
|
let(:branch_name) { "any" }
|
24
24
|
let(:runner) do
|
25
|
-
FitCommit::Runner.new(commit_msg_file.path, branch_name,
|
25
|
+
FitCommit::Runner.new(commit_msg_file.path, branch_name, stderr, stdin)
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "empty commit msg" do
|
29
29
|
let(:commit_msg) { "" }
|
30
|
-
it "allows commit without printing to
|
30
|
+
it "allows commit without printing to stderr" do
|
31
31
|
assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
|
32
|
-
assert
|
32
|
+
assert stderr.read.empty?
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "commit msg consists of all comments" do
|
37
37
|
let(:commit_msg) { "\n#hi\n#yo\n#" }
|
38
|
-
it "allows commit without printing to
|
38
|
+
it "allows commit without printing to stderr" do
|
39
39
|
assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
|
40
|
-
assert
|
40
|
+
assert stderr.read.empty?
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "commit msg is present but no errors" do
|
45
45
|
let(:commit_msg) { "hello\n\nhi\n#" }
|
46
|
-
it "allows commit without printing to
|
46
|
+
it "allows commit without printing to stderr" do
|
47
47
|
assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
|
48
|
-
assert
|
48
|
+
assert stderr.read.empty?
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -56,9 +56,9 @@ describe FitCommit::Runner do
|
|
56
56
|
"this difftext should be ignored." * 3
|
57
57
|
].join("\n")
|
58
58
|
end
|
59
|
-
it "allows commit without printing to
|
59
|
+
it "allows commit without printing to stderr" do
|
60
60
|
assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
|
61
|
-
assert
|
61
|
+
assert stderr.read.empty?
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -66,26 +66,26 @@ describe FitCommit::Runner do
|
|
66
66
|
let(:commit_msg) { "foo.\nbar" }
|
67
67
|
|
68
68
|
def assert_error_output
|
69
|
-
|
70
|
-
assert_equal 7,
|
71
|
-
assert_equal commit_msg,
|
72
|
-
assert_empty
|
73
|
-
assert_match(/\A1: Error: /,
|
74
|
-
assert_match(/\A2: Error: /,
|
75
|
-
assert_empty
|
76
|
-
assert_equal "Force commit? [y/n] ",
|
69
|
+
stderr_lines = stderr.read.lines.map(&:chomp)
|
70
|
+
assert_equal 7, stderr_lines.size
|
71
|
+
assert_equal commit_msg, stderr_lines[0..1].join("\n")
|
72
|
+
assert_empty stderr_lines[2]
|
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]
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "user does not force commit" do
|
80
80
|
let(:stdin) { StringIO.new("n") }
|
81
|
-
it "prints errors to
|
81
|
+
it "prints errors to stderr and rejects commit" do
|
82
82
|
assert_equal FitCommit::Runner::EXIT_CODE_REJECT_COMMIT, call_runner
|
83
83
|
assert_error_output
|
84
84
|
end
|
85
85
|
end
|
86
86
|
describe "user forces commit" do
|
87
87
|
let(:stdin) { StringIO.new("y") }
|
88
|
-
it "prints errors to
|
88
|
+
it "prints errors to stderr and allows commit" do
|
89
89
|
assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
|
90
90
|
assert_error_output
|
91
91
|
end
|
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.
|
4
|
+
version: 2.2.1
|
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-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: swearjar
|