git-catch 0.1.3 → 0.1.4

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: 71834585678905b5c9866622d52b2dd5f655bed5
4
- data.tar.gz: c616e75f8f73ec82b688075e8d4c2f0d8492fb80
3
+ metadata.gz: acfe4df3b3c7627d8693978e4504b1127ffeb8bf
4
+ data.tar.gz: 8d2cab43d97f941b44071fe3dd8bdf013321832b
5
5
  SHA512:
6
- metadata.gz: 7cfc5f7b907e5cfeb9148feac8ebe955924cbfa011e986ed54ecf2523737f6aabfc41eaf51af522630feb236f983853b3631b639cb0e7994097c07ec26de8a71
7
- data.tar.gz: 90a1cff23986315c64f777c8cda54bd20b62ebfe1a2cf580931a3626a98d35ea919239575c2cd1d4d3c41934f6d8a6b67b990f3d46038bd94ae9fd0ca8232a84
6
+ metadata.gz: 8f6732cf83f70c5d929e77de6061c5a93e1be6f3a2ff5892b7db3cd6d86ab1d9a4ef9c56b4f0b5f0bf524144c347bea9f181df9ab138025c7e2eeb31026f21c4
7
+ data.tar.gz: 4865fba333a36ce0bf48791387a15d36d822c664f5861841c32ce4b3fa02a214f7823871a684b1d8372fc269106d14b1dda31a1a663922bbcb1e728c17df0b00
data/.git-catch.yaml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ pre-commit:
3
+ - test/pre-commit-1
4
+ - test/pre-commit-2
data/bin/git-catch CHANGED
@@ -11,6 +11,7 @@ module Git
11
11
  desc "init", "Hooks up the git hooks"
12
12
  def init
13
13
  puts "==> Init"
14
+ Runner.new.init()
14
15
  end
15
16
 
16
17
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Catch
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
data/lib/git/catch.rb CHANGED
@@ -1,7 +1,51 @@
1
+ require "yaml"
2
+ require "fileutils"
3
+
1
4
  require "git/catch/version"
2
5
 
6
+
3
7
  module Git
4
8
  module Catch
5
- # Your code goes here...
9
+ class Runner
10
+
11
+ def init
12
+ hooks = [
13
+ "applypatch-msg",
14
+ "commit-msg",
15
+ "post-update",
16
+ "pre-applypatch",
17
+ "pre-commit",
18
+ "pre-push",
19
+ "pre-rebase",
20
+ "prepare-commit-msg",
21
+ "update",
22
+ ]
23
+ config = YAML.load_file("./.git-catch.yaml")
24
+ config.each do |name, files|
25
+ if !hooks.include? name
26
+ puts "==> Hook #{name} is not known"
27
+ next
28
+ end
29
+ build name, files
30
+ end
31
+ end
32
+
33
+ private
34
+ def build(name, files)
35
+ file = ".git/hooks/#{name}"
36
+ content = <<~EOS
37
+ #!/usr/bin/env bash
38
+ set -eu
39
+
40
+ EOS
41
+ files.each do |file|
42
+ content << "#{file}\n"
43
+ end
44
+ File.write file, content
45
+ FileUtils.chmod "+x", file
46
+ puts "==> File #{file} written"
47
+ end
48
+
49
+ end
6
50
  end
7
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-catch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Barbosa
@@ -60,6 +60,7 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".git-catch.yaml"
63
64
  - ".gitignore"
64
65
  - ".travis.yml"
65
66
  - Gemfile
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  version: '0'
91
92
  requirements: []
92
93
  rubyforge_project:
93
- rubygems_version: 2.6.14
94
+ rubygems_version: 2.5.2.1
94
95
  signing_key:
95
96
  specification_version: 4
96
97
  summary: Hooks up your git hooks