raincoat 0.1 → 0.1.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.
- data/README.markdown +4 -0
- data/Rakefile +1 -1
- data/lib/raincoat/hook.rb +9 -2
- data/lib/raincoat/script_writer.rb +6 -1
- metadata +1 -1
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
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(
|
28
|
-
|
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
|