sentia_git_hooks 0.2.0 → 0.3.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: 527233af4d756879927bbf07f705f8f08ded3738
4
- data.tar.gz: 4947f3b755ae919842563024c05235ff1df40ce4
3
+ metadata.gz: a26779000878621cd43af13929782c7fa112872a
4
+ data.tar.gz: 8436acdf1e93346213ebabf55333e8f77103e7db
5
5
  SHA512:
6
- metadata.gz: c35ee95f2e1e6d9acc2fb18a8309899f65b4938609b7d82382a21391903c5a863f4a84a6a6ee44cf71254088247d4d4d462956f96f7abb5257e8978479d5ae34
7
- data.tar.gz: 614027894bc9ae9cc0c7ffb2dc0e32d24a7085276320d0f9d6939a9c958d34aec5ffa53777ebba8617d8b53d25f045a82ac3025e8df72675711074e29729bbe1
6
+ metadata.gz: 4e05c6f12fa9d021cead42a9c9e915e59f6f794ce606e7e817de0db5059e803e09bf11d4eb83be057ab29ea100d38dddd48f3608448b83bbdaf43977f3b88d36
7
+ data.tar.gz: b418798aecfdf7e2a9376181f3ef0c2377132f48de62d8b7001d66954bbb7e9371c5671a68647b61820327b7b7c564649c3187da637966c5926a9b262a2af16b
data/bin/sentia_git_hooks CHANGED
@@ -1,28 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- scripts_dir = File.expand_path "../../lib/scripts/", __FILE__
3
- hooks_dir = File.expand_path ".git/hooks", Dir.pwd
2
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
3
 
5
- script_files = Dir.entries(scripts_dir)
6
- script_files.delete(".")
7
- script_files.delete("..")
4
+ require 'sentia_git_hooks'
8
5
 
9
-
10
- script_files.each do |file|
11
- path_to_script = File.expand_path file, scripts_dir
12
- path_to_hook = File.expand_path file, hooks_dir
13
- command = "ln -s '#{path_to_script}' '#{path_to_hook}'"
14
-
15
- puts "Issuing command: #{command}"
16
-
17
- `#{command}`
18
- if $?.exitstatus != 0
19
- puts "Failed
20
- If a hook file already exists then we refuse to clobber it,
21
- you'll have to delete it manually, or have it call the functionality
22
- in our hook."
23
- exit 1
24
- end
25
- end
26
-
27
- puts "Success"
28
- exit 0
6
+ SentiaGitHooks::Cli.start(ARGV)
@@ -24,8 +24,8 @@ message = `cat #{commit_file}`
24
24
  # Definitely something here
25
25
  # More optional stuff"
26
26
  #
27
- message_filter = /\A(\d[\d ,]+) - ([^\n]+)\n(\n+(.+))?\z/m
28
- bump_filter = /\ABump version number to ([\d.]+)\n\z/
27
+ message_filter = /\A(\d[\d ,]*) - ([^\n]+)\n(\n+(.+))?\z/m
28
+ bump_filter = /\ABump version number to (\d\.\d\.\d[\d.]*)\n\z/
29
29
  merge_filter = /\AMerge \w* '(.*)' into (.*)\n\z/
30
30
 
31
31
  if message_filter.match message
@@ -0,0 +1,72 @@
1
+ require 'thor'
2
+ require 'pathname'
3
+ require 'fileutils'
4
+
5
+ module SentiaGitHooks
6
+ class Cli < Thor
7
+
8
+ def initialize(*args)
9
+ super
10
+
11
+ @scripts_dir = Pathname.new File.expand_path("../../scripts", __FILE__)
12
+ @sentia_dir = Pathname.new("~/.sentia/").expand_path
13
+ @sentia_hooks_dir = @sentia_dir + "git-hooks"
14
+ @new_hooks_dir = Pathname.new(Dir.pwd) + ".git/hooks"
15
+ end
16
+
17
+
18
+
19
+ desc "update", "Update the git hooks on your system"
20
+ def update
21
+ FileUtils.mkdir_p @sentia_dir
22
+ FileUtils.rm_f @sentia_hooks_dir
23
+ FileUtils.ln_s @scripts_dir, @sentia_hooks_dir, force: true
24
+ end
25
+
26
+
27
+
28
+ desc "install", "Install sentia git hooks into the current repository"
29
+ def install
30
+ script_files = Dir.entries @sentia_hooks_dir
31
+ script_files.delete(".")
32
+ script_files.delete("..")
33
+
34
+ script_files.each do |file|
35
+ existing_script = @sentia_hooks_dir + file
36
+ new_hook = File.expand_path file, @new_hooks_dir
37
+
38
+ begin
39
+ FileUtils.ln_s existing_script, new_hook
40
+ exit 0
41
+ rescue
42
+ puts "Failed
43
+ If a hook file already exists then we refuse to clobber it,
44
+ you'll have to delete it manually, or have it call the functionality
45
+ in our hook."
46
+ exit 1
47
+ end
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+
54
+
55
+
56
+
57
+ # scripts_dir = Pathname.new File.expand_path("../../lib/scripts", __FILE__)
58
+ # sentia_dir = Pathname.new("~/.sentia/").expand_path
59
+ # sentia_hooks_dir = sentia_dir + "git-hooks"
60
+ # new_hooks_dir = Pathname.new(Dir.pwd) + ".git/hooks"
61
+
62
+ # FileUitels.rm_f sentia_hooks_dir
63
+ # FileUtils.ln_s scripts_dir, sentia_hooks_dir, force: true
64
+
65
+
66
+
67
+ # puts script_files
68
+
69
+
70
+
71
+ # puts "Success"
72
+ # exit 0
@@ -1,3 +1,3 @@
1
1
  module SentiaGitHooks
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,5 +1,6 @@
1
- require "sentia_git_hooks/version"
1
+ require 'sentia_git_hooks/version'
2
+ require 'sentia_git_hooks/cli'
2
3
 
3
4
  module SentiaGitHooks
4
- # Your code goes here...
5
+
5
6
  end
@@ -18,9 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = ["sentia_git_hooks"]
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "thor"
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.9"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "pry"
24
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "fakefs"
25
28
 
26
29
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentia_git_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sia. S.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fakefs
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: ''
70
98
  email:
71
99
  - sia.s.saj@gmail.com
@@ -86,6 +114,7 @@ files:
86
114
  - bin/setup
87
115
  - lib/scripts/commit-msg
88
116
  - lib/sentia_git_hooks.rb
117
+ - lib/sentia_git_hooks/cli.rb
89
118
  - lib/sentia_git_hooks/version.rb
90
119
  - sentia_git_hooks.gemspec
91
120
  homepage: http://github.com/Sentia/git-hooks