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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 537d8b0aba4a78077a2a83811f61275e92675096
4
- data.tar.gz: 35f7835256d75573db5d1e2ab1390b0b9dba7e91
3
+ metadata.gz: b61c53d1075587aa48903e5e8d458e64ad00e3d4
4
+ data.tar.gz: 077f6f1aa451f7059bba3947647774fd06dfd772
5
5
  SHA512:
6
- metadata.gz: d0a01ba51f8a80696f79fd3f1acac240419cc59d032b65473c5b9ba98808c7222f062fe31b4bf6a3fe3f9b22cdc9c96d7ebe2c0acb4953faa8ee4906e0c10758
7
- data.tar.gz: 5da65f00da85068723387ff697f53feb488d1f2418021de602b4a22258282f3471f60772c9ea455b499361f55d79cbeb0b58a2e97e511035d195fde4c0647368
6
+ metadata.gz: 84d194395b306f6cdca5837351f2fe750e0b85cf69562717dfec06c67e3d58d0292e93489f274ae77d75507280ffb31a13810c813d7445371ce3cba72164251f
7
+ data.tar.gz: a8eede0ab599285938a71def5b385d25a3f76e7615b5164c84077b0c62bc240074fe8cce26d40564320186414d1f56dbe078b760f069375cd73cda5015776d47
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rabbitt-githooks (1.5.4)
4
+ rabbitt-githooks (1.5.5)
5
5
  rainbow (~> 2.0.0)
6
6
  thor (~> 0.18)
7
7
 
@@ -60,6 +60,3 @@ DEPENDENCIES
60
60
  ruby-lint (~> 2.0)
61
61
  simplecov (~> 0.9)
62
62
  yard (~> 0.7)
63
-
64
- BUNDLED WITH
65
- 1.10.6
@@ -60,13 +60,11 @@ module GitHooks
60
60
  end
61
61
 
62
62
  def get_root_path(path)
63
- @root_path ||= begin
64
- git('rev-parse', '--show-toplevel', chdir: path).tap do |result|
65
- unless result.status.success? && result.output !~ /not a git repository/i
66
- fail Error::NotAGitRepo, "Unable to find a valid git repo in #{path}"
67
- end
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 =~ /^fatal: no upstream configured for branch '([^']+)'/
127
- fail Error::RemoteNotSet, "No upstream remote configured for '#{$1}'"
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 # rubocop:disable ClassLength
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.gsub(/-/, '_')
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.gsub('-', '_'))
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 = options.delete(:repo_path) || @repository.path
84
- global = (opt = options.delete(:global)).nil? ? false : opt
85
- global = global ? '--global' : '--local'
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 CyclomaticComplexity, MethodLength, PerceivedComplexity
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 CyclomaticComplexity, MethodLength, PerceivedComplexity, AbcSize
144
- raw_config = git('--list', *args).output.split("\n").sort.uniq
145
- raw_config.each_with_object({}) do |line, hash|
146
- key, value = line.split(/\s*=\s*/)
147
- key_parts = key.git_option_path_split
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
- ptr = hash[key_parts.shift] ||= {} # rubocop:disable IndentationWidth
150
- ptr = ptr[key_parts.shift] ||= {} until key_parts.size == 1
155
+ ptr = hash[key_parts.shift] ||= {}
156
+ ptr = ptr[key_parts.shift] ||= {} until key_parts.size == 1
151
157
 
152
- key = key_parts.shift
153
- case ptr[key]
154
- when nil then ptr[key] = value
155
- when Array then ptr[key] << value
156
- else ptr[key] = [ptr[key], value].flatten
157
- end
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
- hash
165
+ hash
166
+ end
160
167
  end
161
168
  end
162
169
  end
@@ -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 = repository.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')
@@ -18,5 +18,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
18
18
  =end
19
19
 
20
20
  module GitHooks
21
- VERSION = '1.5.4' unless defined? VERSION
21
+ VERSION = '1.5.5' unless defined? VERSION
22
22
  end
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
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-24 00:00:00.000000000 Z
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.4.8
212
+ rubygems_version: 2.2.2
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: framework for building git hooks tests