rabbitt-githooks 1.5.4 → 1.5.5
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -4
- data/lib/githooks/repository.rb +7 -9
- data/lib/githooks/repository/config.rb +28 -21
- data/lib/githooks/runner.rb +1 -1
- data/lib/githooks/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b61c53d1075587aa48903e5e8d458e64ad00e3d4
|
|
4
|
+
data.tar.gz: 077f6f1aa451f7059bba3947647774fd06dfd772
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84d194395b306f6cdca5837351f2fe750e0b85cf69562717dfec06c67e3d58d0292e93489f274ae77d75507280ffb31a13810c813d7445371ce3cba72164251f
|
|
7
|
+
data.tar.gz: a8eede0ab599285938a71def5b385d25a3f76e7615b5164c84077b0c62bc240074fe8cce26d40564320186414d1f56dbe078b760f069375cd73cda5015776d47
|
data/Gemfile.lock
CHANGED
data/lib/githooks/repository.rb
CHANGED
|
@@ -60,13 +60,11 @@ module GitHooks
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def get_root_path(path)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
end.output.strip
|
|
69
|
-
end
|
|
63
|
+
git('rev-parse', '--show-toplevel', chdir: path).tap do |result|
|
|
64
|
+
unless result.status.success? && result.output !~ /not a git repository/i
|
|
65
|
+
fail Error::NotAGitRepo, "Unable to find a valid git repo in #{path}"
|
|
66
|
+
end
|
|
67
|
+
end.output.strip
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
def stash
|
|
@@ -123,8 +121,8 @@ module GitHooks
|
|
|
123
121
|
def unpushed_commits
|
|
124
122
|
result = git('log', '--format=%H', '@{upstream}..')
|
|
125
123
|
if result.failure?
|
|
126
|
-
if result.error =~
|
|
127
|
-
fail Error::RemoteNotSet, "No upstream remote configured for '#{$
|
|
124
|
+
if result.error =~ /no upstream configured for branch (["'])((?:(?!\1).)+)\1\z/i
|
|
125
|
+
fail Error::RemoteNotSet, "No upstream remote configured for '#{$2}'"
|
|
128
126
|
else
|
|
129
127
|
fail Error::CommandExecutionFailure, result.error
|
|
130
128
|
end
|
|
@@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
19
19
|
|
|
20
20
|
module GitHooks
|
|
21
21
|
class Repository
|
|
22
|
-
class Config
|
|
22
|
+
class Config
|
|
23
23
|
OPTIONS = {
|
|
24
24
|
'hooks-path' => { type: :path, multiple: false },
|
|
25
25
|
'script' => { type: :path, multiple: false },
|
|
@@ -28,7 +28,7 @@ module GitHooks
|
|
|
28
28
|
}.freeze unless defined? OPTIONS
|
|
29
29
|
|
|
30
30
|
OPTIONS.keys.each do |name|
|
|
31
|
-
method_name = name.
|
|
31
|
+
method_name = name.tr('-', '_')
|
|
32
32
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
|
33
33
|
def #{method_name}(options = {})
|
|
34
34
|
result = get('#{name}', options)
|
|
@@ -39,10 +39,11 @@ module GitHooks
|
|
|
39
39
|
|
|
40
40
|
def initialize(repository)
|
|
41
41
|
@repository = repository
|
|
42
|
+
@config = nil
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def [](option)
|
|
45
|
-
send(option.to_s.
|
|
46
|
+
send(option.to_s.tr('-', '_'))
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
def set(option, value, options = {}) # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity, AbcSize
|
|
@@ -76,17 +77,19 @@ module GitHooks
|
|
|
76
77
|
option = "githooks.#{repo}.#{option}"
|
|
77
78
|
git(global, var_type, add_type, option, value, chdir: repo).tap do |result|
|
|
78
79
|
puts "Added option #{option} with value #{value}" if result.status.success?
|
|
80
|
+
@config = nil # reset config
|
|
79
81
|
end
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
def remove_section(options = {})
|
|
83
|
-
repo
|
|
84
|
-
global
|
|
85
|
-
global
|
|
85
|
+
repo = options.delete(:repo_path) || @repository.path
|
|
86
|
+
global = (opt = options.delete(:global)).nil? ? false : opt
|
|
87
|
+
global = global ? '--global' : '--local'
|
|
88
|
+
@config = nil # reset config
|
|
86
89
|
git(global, '--remove-section', "githooks.#{repo}", chdir: repo)
|
|
87
90
|
end
|
|
88
91
|
|
|
89
|
-
def unset(option, *args) # rubocop:disable
|
|
92
|
+
def unset(option, *args) # rubocop:disable AbcSize
|
|
90
93
|
options = args.extract_options!
|
|
91
94
|
global = (opt = options.delete(:global)).nil? ? false : opt
|
|
92
95
|
global = global ? '--global' : '--local'
|
|
@@ -100,6 +103,8 @@ module GitHooks
|
|
|
100
103
|
git(global, '--unset', option, value_regex, options)
|
|
101
104
|
end
|
|
102
105
|
|
|
106
|
+
@config = nil # reset config
|
|
107
|
+
|
|
103
108
|
result.status.success?
|
|
104
109
|
end
|
|
105
110
|
|
|
@@ -140,23 +145,25 @@ module GitHooks
|
|
|
140
145
|
@repository.git(:config, *args)
|
|
141
146
|
end
|
|
142
147
|
|
|
143
|
-
def config(*args) # rubocop:disable
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
def config(*args) # rubocop:disable AbcSize
|
|
149
|
+
@config ||= begin
|
|
150
|
+
raw_config = git('--list', *args).output.split("\n").sort.uniq
|
|
151
|
+
raw_config.each_with_object({}) do |line, hash|
|
|
152
|
+
key, value = line.split(/\s*=\s*/)
|
|
153
|
+
key_parts = key.git_option_path_split
|
|
148
154
|
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
ptr = hash[key_parts.shift] ||= {}
|
|
156
|
+
ptr = ptr[key_parts.shift] ||= {} until key_parts.size == 1
|
|
151
157
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
key = key_parts.shift
|
|
159
|
+
case ptr[key]
|
|
160
|
+
when nil then ptr[key] = value
|
|
161
|
+
when Array then ptr[key] << value
|
|
162
|
+
else ptr[key] = [ptr[key], value].flatten
|
|
163
|
+
end
|
|
158
164
|
|
|
159
|
-
|
|
165
|
+
hash
|
|
166
|
+
end
|
|
160
167
|
end
|
|
161
168
|
end
|
|
162
169
|
end
|
data/lib/githooks/runner.rb
CHANGED
|
@@ -266,7 +266,7 @@ module GitHooks
|
|
|
266
266
|
def load_tests(skip_bundler = nil)
|
|
267
267
|
skip_bundler = skip_bundler.nil? ? options.skip_bundler : skip_bundler
|
|
268
268
|
|
|
269
|
-
hooks_path =
|
|
269
|
+
hooks_path = @hook_path.dup
|
|
270
270
|
hooks_libs = hooks_path.join('lib')
|
|
271
271
|
hooks_init = (p = hooks_path.join('hooks_init.rb')).exist? ? p : hooks_path.join('githooks_init.rb')
|
|
272
272
|
gemfile = hooks_path.join('Gemfile')
|
data/lib/githooks/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rabbitt-githooks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carl P. Corliss
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-09-
|
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rainbow
|
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
209
209
|
version: '0'
|
|
210
210
|
requirements: []
|
|
211
211
|
rubyforge_project:
|
|
212
|
-
rubygems_version: 2.
|
|
212
|
+
rubygems_version: 2.2.2
|
|
213
213
|
signing_key:
|
|
214
214
|
specification_version: 4
|
|
215
215
|
summary: framework for building git hooks tests
|