fit-commit 1.1.0 → 2.0.0

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: 22158ab17b4462ca5896322c36f8466ffc029c2b
4
- data.tar.gz: 53e609a83fc276e43aba9d3c23c15dc971c71c10
3
+ metadata.gz: fc08ac065b8b63def448a55dde83e4c2415041eb
4
+ data.tar.gz: 2e32ba91af1f3d49d24fc1702995c34dc7e6a5e8
5
5
  SHA512:
6
- metadata.gz: f3aa2b49980aea8801f0675b72d7a72a1e8e6f3e17fba4827f3c14f6cd144681f50504ae66da81df5a5ac0bea70b63e496e4a9f2236444e863b6932c26b2279f
7
- data.tar.gz: 8db493b9b6665f618ab93769192908d8ab2c5fa14e7002706b59fb0fbb0c49747aee3d45a0fbdcb665d29fea06c4ec557bf74e5d3260848cb0fc37abfbb22894
6
+ metadata.gz: 7500dd39439a0c74810b31ee50c3d035ae5de0534e40d7d742a934061fbc3c5b7f6906bd536c23565aa65351bc4c29ae7bdc121f96d4ff8c6dc70ecc9f87f9ee
7
+ data.tar.gz: 595a6b8f2bdd25ab000e66c6014c64bdc62da3277764e44321570edcfb7026cc90f694619ab7d9edde1184a52e3c33e044285b45dce7728aa03053d96c61b845
data/.gitignore CHANGED
@@ -17,9 +17,9 @@
17
17
 
18
18
  # for a library or gem, you might want to ignore these files since the code is
19
19
  # intended to run in multiple environments; otherwise, check them in:
20
- # Gemfile.lock
21
- # .ruby-version
22
- # .ruby-gemset
20
+ Gemfile.lock
21
+ .ruby-version
22
+ .ruby-gemset
23
23
 
24
24
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
25
25
  .rvmrc
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ### master
4
+ - N/A
5
+
6
+ ### v2.0.0 (2015-08-27)
7
+ - Breaking changes made to Git hook. If upgrading from an older version you'll need to re-run `fit-commit install` in your repos.
8
+
9
+ ### v1.1.0 (2015-08-26)
10
+ - Add support for `git commit -v`.
11
+
12
+ ### v1.0.4 (2015-08-26)
13
+ - Improve error output in Git hook.
data/TODO.txt CHANGED
@@ -1,3 +1,4 @@
1
+ - Document adding fit-commit to ~/.git_template
1
2
  - Customize which are "business" branches (not just master)
2
3
  - Configuration to disable validations.
3
4
  - `fit-commit uninstall`
@@ -5,6 +5,9 @@ module FitCommit
5
5
  class Runner
6
6
  include FitCommit::HasErrors
7
7
 
8
+ EXIT_CODE_ALLOW_COMMIT = 0
9
+ EXIT_CODE_REJECT_COMMIT = 1
10
+
8
11
  attr_accessor :message_path, :branch_name, :stdout, :stdin
9
12
  def initialize(message_path, branch_name, stdout = $stdout, stdin = $stdin)
10
13
  self.message_path = message_path
@@ -14,22 +17,22 @@ module FitCommit
14
17
  end
15
18
 
16
19
  def run
17
- return true if empty_commit?
20
+ return EXIT_CODE_ALLOW_COMMIT if empty_commit?
18
21
  run_validators
19
- return true if [errors, warnings].all?(&:empty?)
22
+ return EXIT_CODE_ALLOW_COMMIT if [errors, warnings].all?(&:empty?)
20
23
  print_results
21
24
 
22
25
  allow_commit = errors.empty?
23
26
  unless allow_commit
24
27
  stdout.print "\nForce commit? [y/n] "
25
- return false unless stdin.gets =~ /y/i
28
+ return EXIT_CODE_REJECT_COMMIT unless stdin.gets =~ /y/i
26
29
  allow_commit = true
27
30
  end
28
31
 
29
32
  stdout.print "\n"
30
- allow_commit
33
+ allow_commit ? EXIT_CODE_ALLOW_COMMIT : EXIT_CODE_REJECT_COMMIT
31
34
  rescue Interrupt # Ctrl-c
32
- false
35
+ EXIT_CODE_REJECT_COMMIT
33
36
  end
34
37
 
35
38
  private
@@ -77,7 +80,7 @@ module FitCommit
77
80
  end
78
81
 
79
82
  def message_text
80
- File.open(message_path, "r").read
83
+ File.read(message_path)
81
84
  end
82
85
 
83
86
  def empty_commit?
@@ -1,3 +1,3 @@
1
1
  module FitCommit
2
- VERSION = "1.1.0"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/fit-commit.rb CHANGED
@@ -2,7 +2,8 @@ require "fit-commit/runner"
2
2
 
3
3
  module FitCommit
4
4
  def self.run
5
- runner.run || exit(1)
5
+ exit_code = runner.run
6
+ exit(exit_code)
6
7
  end
7
8
 
8
9
  private
@@ -16,6 +17,6 @@ module FitCommit
16
17
  end
17
18
 
18
19
  def self.branch_name
19
- `git branch | grep '^\*' | cut -b3-`.strip
20
+ ENV.fetch("GIT_BRANCH_NAME")
20
21
  end
21
22
  end
@@ -10,7 +10,6 @@ else cmd="ruby"
10
10
  fi
11
11
 
12
12
  export COMMIT_MESSAGE_PATH=$1
13
-
14
13
  if (! [[ "$COMMIT_MESSAGE_PATH" ]] ); then
15
14
  >&2 echo "fit-commit: WARNING: Skipping checks because the Git hook was not passed the"
16
15
  >&2 echo "fit-commit: commit message file path. This is usually \`.git/COMMIT_EDITMSG\`."
@@ -19,6 +18,13 @@ if (! [[ "$COMMIT_MESSAGE_PATH" ]] ); then
19
18
  exit 0
20
19
  fi
21
20
 
21
+ export GIT_BRANCH_NAME=`git name-rev --name-only HEAD`
22
+ if (! [[ "$GIT_BRANCH_NAME" ]] ); then
23
+ >&2 echo "fit-commit: WARNING: Skipping checks because the Git branch cannot be determined."
24
+ >&2 echo "fit-commit: Please submit a bug report with the project."
25
+ exit 0
26
+ fi
27
+
22
28
  ${cmd} -rrubygems -e '
23
29
  begin
24
30
  require "fit-commit"
data/test/runner_test.rb CHANGED
@@ -7,9 +7,9 @@ describe FitCommit::Runner do
7
7
  end
8
8
 
9
9
  def call_runner
10
- allow_commit = runner.run
10
+ exit_code = runner.run
11
11
  stdout.rewind
12
- allow_commit
12
+ exit_code
13
13
  end
14
14
 
15
15
  let(:commit_msg_file) do
@@ -28,7 +28,7 @@ describe FitCommit::Runner do
28
28
  describe "empty commit msg" do
29
29
  let(:commit_msg) { "" }
30
30
  it "returns truthy value without printing to stdout" do
31
- assert call_runner
31
+ assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
32
32
  assert stdout.read.empty?
33
33
  end
34
34
  end
@@ -36,7 +36,7 @@ describe FitCommit::Runner do
36
36
  describe "commit msg consists of all comments" do
37
37
  let(:commit_msg) { "\n#hi\n#yo\n#" }
38
38
  it "returns truthy value without printing to stdout" do
39
- assert call_runner
39
+ assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
40
40
  assert stdout.read.empty?
41
41
  end
42
42
  end
@@ -44,7 +44,7 @@ describe FitCommit::Runner do
44
44
  describe "commit msg is present but no errors" do
45
45
  let(:commit_msg) { "hello\n\nhi\n#" }
46
46
  it "returns truthy value without printing to stdout" do
47
- assert call_runner
47
+ assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
48
48
  assert stdout.read.empty?
49
49
  end
50
50
  end
@@ -57,7 +57,7 @@ describe FitCommit::Runner do
57
57
  ].join("\n")
58
58
  end
59
59
  it "returns truthy value without printing to stdout" do
60
- assert call_runner
60
+ assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
61
61
  assert stdout.read.empty?
62
62
  end
63
63
  end
@@ -79,14 +79,14 @@ describe FitCommit::Runner do
79
79
  describe "user does not force commit" do
80
80
  let(:stdin) { StringIO.new("n") }
81
81
  it "prints errors to stdout and returns falsey value" do
82
- assert !call_runner
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
88
  it "prints errors to stdout and returns truthy value" do
89
- assert call_runner
89
+ assert_equal FitCommit::Runner::EXIT_CODE_ALLOW_COMMIT, call_runner
90
90
  assert_error_output
91
91
  end
92
92
  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: 1.1.0
4
+ version: 2.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-08-27 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: swearjar
@@ -63,8 +63,8 @@ extra_rdoc_files:
63
63
  - README.md
64
64
  files:
65
65
  - ".gitignore"
66
+ - CHANGELOG.md
66
67
  - Gemfile
67
- - Gemfile.lock
68
68
  - LICENSE
69
69
  - README.md
70
70
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,25 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- fit-commit (1.0.0)
5
- swearjar (~> 1.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- fuzzyhash (0.0.11)
11
- minitest (5.8.0)
12
- rake (10.4.2)
13
- swearjar (1.0.0)
14
- fuzzyhash (~> 0.0.11)
15
-
16
- PLATFORMS
17
- ruby
18
-
19
- DEPENDENCIES
20
- fit-commit!
21
- minitest (~> 5.8)
22
- rake (~> 10.4)
23
-
24
- BUNDLED WITH
25
- 1.10.6