raincoat 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -61,6 +61,10 @@ representation of the change that is being made in git. For example in
61
61
  the case of `pre-commit` it is the difference between the files that
62
62
  are currently staged and the `HEAD` commit.
63
63
 
64
+ If the `call` method returns `false` then the operation will be
65
+ unsuccessful and git will not proceed. If it returns `true` the hook
66
+ will have a `0` exit status so git can continue.
67
+
64
68
  ## TODO
65
69
 
66
70
  * Add support for additional git-hooks
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = 'raincoat'
5
- s.version = '0.1'
5
+ s.version = '0.1.1'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.summary = 'Easily define git-hooks that can be passed with your project'
8
8
  s.description = s.summary
data/lib/raincoat/hook.rb CHANGED
@@ -24,8 +24,15 @@ module Raincoat
24
24
  # This number becomes the overall exit status of the hook.
25
25
  def run
26
26
  diff = git_diff.freeze
27
- scripts.inject(0) do |result, script|
28
- result + script.call(diff)
27
+ success = scripts.inject(true) do |result, script|
28
+ script.call(diff) && result
29
+ end
30
+ if success
31
+ 0
32
+ else
33
+ $stderr.puts "Operation unsuccessful!"
34
+ $stderr.puts "One or more of your raincoat scripts failed"
35
+ 1
29
36
  end
30
37
  end
31
38
 
@@ -27,6 +27,12 @@ module Raincoat
27
27
  def write(hook_name)
28
28
  init_script_directory(File.join(@script_dir, hook_name))
29
29
  path = File.join(GIT_HOOK_DIR, hook_name)
30
+
31
+ if File.exists?(path)
32
+ $stderr.puts "#{path} already exists. Please delete it and re-run the installation."
33
+ return
34
+ end
35
+
30
36
  File.open(path, "w") do |f|
31
37
  f.puts(build_script(hook_name))
32
38
  end
@@ -61,7 +67,6 @@ class ActiveHook < Raincoat::Hook
61
67
  end
62
68
  end
63
69
 
64
- puts "RUNNING!"
65
70
  exit(ActiveHook.new("<%= script_dir %>").run)
66
71
 
67
72
  TEMPLATE
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raincoat
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Burrows