fit-commit 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d0e5940862e5d3bb79d5e2fd77eab59035ecb41
4
- data.tar.gz: 2fa241ffb6eae0aa6cfbfda5d12f8cba52bf4823
3
+ metadata.gz: c77c51765ec627e156a600d56c8b1482177a5c5c
4
+ data.tar.gz: caa7c6910ee5dace99a7f0e803c8e06695a7f91b
5
5
  SHA512:
6
- metadata.gz: 3024e9600be177394c86f8037f08d2ee8b0253008b22352da8b36378b9557511db17e9dd88c5f6efa03f37d68acc6a7b39b26bf1584fe63bfde58902bf8a590f
7
- data.tar.gz: e6ce9e0c4df171f734ad6dd613662e8d35fe31d7de4dc361a2f9546666b90cabce6709497d0b844aa670546cffdbca0347efc5feffcf3ac9484f3c6303a2701a
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, in increasing precedence: `/etc/fit_commit.yml`, `$HOME/.fit_commit.yml`, `config/fit_commit.yml`, `./.fit_commit.yml`.
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
- The default settings are:
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 are branch agnostic
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 ~/.git_templates/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:
@@ -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, :stdout, :stdin
13
- def initialize(message_path, branch_name, stdout = $stdout, stdin = $stdin)
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.stdout = stdout
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
- stdout.print "\nForce commit? [y/n] "
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
- stdout.print "\n"
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
- stdout.puts lines
56
- stdout.print "\n"
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
- stdout.puts "#{lineno}: Error: #{error}"
61
+ stderr.puts "#{lineno}: Error: #{error}"
62
62
  end
63
63
  warnings[lineno].each do |warning|
64
- stdout.puts "#{lineno}: Warning: #{warning}"
64
+ stderr.puts "#{lineno}: Warning: #{warning}"
65
65
  end
66
66
  end
67
67
  end
@@ -1,3 +1,3 @@
1
1
  module FitCommit
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
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
- stdout.rewind
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(:stdout) { StringIO.new }
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, stdout, stdin)
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 stdout" do
30
+ it "allows commit without printing to stderr" do
31
31
  assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
32
- assert stdout.read.empty?
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 stdout" do
38
+ it "allows commit without printing to stderr" do
39
39
  assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
40
- assert stdout.read.empty?
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 stdout" do
46
+ it "allows commit without printing to stderr" do
47
47
  assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
48
- assert stdout.read.empty?
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 stdout" do
59
+ it "allows commit without printing to stderr" do
60
60
  assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
61
- assert stdout.read.empty?
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
- stdout_lines = stdout.read.lines.map(&:chomp)
70
- assert_equal 7, stdout_lines.size
71
- assert_equal commit_msg, stdout_lines[0..1].join("\n")
72
- assert_empty stdout_lines[2]
73
- assert_match(/\A1: Error: /, stdout_lines[3])
74
- assert_match(/\A2: Error: /, stdout_lines[4])
75
- assert_empty stdout_lines[5]
76
- assert_equal "Force commit? [y/n] ", stdout_lines[6]
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 stdout and rejects commit" do
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 stdout and allows commit" do
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: swearjar