git_reflow 0.9.0 → 0.9.1

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
  SHA256:
3
- metadata.gz: 39852c57b3be6a203026afbf22cd14049d954674cceb146b54ab8ab2704d3717
4
- data.tar.gz: 1ed1b701de39c181c6ad5b791f48991c4a234caf721ddead4066866dc8d1e5f2
3
+ metadata.gz: 824f8b64c6d06856254f319565137a75873f33fa4020714ea873d343dc33a5e3
4
+ data.tar.gz: 7dd4f713c777d88bc6f36f472737aeeeeb8110efed81686b6f1bdb7c2de84e75
5
5
  SHA512:
6
- metadata.gz: bef6f0639dc9f9ab50b5977556ff48bb988fad2a92799f8ceba6adc6c0c8e156fc18885f16b433def991afddb59e760d12769c0c360cb2ada92c3a653f4f60df
7
- data.tar.gz: 38b2cb929a52092a933ed3c7d684f43146dca83e879700a0e796079868eab6bfaad7ec2e015fecb898e9b95a5d7e818bb50320a8f1273f0ef09d30f91c19d134
6
+ metadata.gz: 44c6a6508e52f95e8446c0cabd2bbecf93a1dff91172100e16d8f7920e02664ee8611781df0cdec03bc3df590023e4620946940790413e0e912d61436860a47a
7
+ data.tar.gz: d6b5164ce0ade6a15295f723f098b5ddc53278cc6db9118795357150b4baee00c49bc18843c680c7d863902566e1b6217de462d78284ed88dc17b367dcc25643
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.9.0)
4
+ git_reflow (0.9.1)
5
+ bundler (>= 1.10.0)
5
6
  colorize (>= 0.7.0)
6
7
  github_api (= 0.18.2)
7
8
  highline
@@ -11,12 +12,13 @@ PATH
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- addressable (2.4.0)
15
+ addressable (2.6.0)
16
+ public_suffix (>= 2.0.2, < 4.0)
15
17
  appraisal (2.2.0)
16
18
  bundler
17
19
  rake
18
20
  thor (>= 0.14.0)
19
- byebug (10.0.2)
21
+ byebug (11.0.1)
20
22
  chronic (0.10.2)
21
23
  coderay (1.1.2)
22
24
  colorize (0.8.1)
@@ -35,33 +37,34 @@ GEM
35
37
  faraday (~> 0.8)
36
38
  hashie (~> 3.5, >= 3.5.2)
37
39
  oauth2 (~> 1.0)
38
- hashdiff (0.3.7)
40
+ hashdiff (0.3.8)
39
41
  hashie (3.6.0)
40
- highline (2.0.0)
42
+ highline (2.0.2)
41
43
  httpclient (2.8.3)
42
44
  jwt (2.1.0)
43
- method_source (0.9.0)
44
- mini_portile2 (2.3.0)
45
+ method_source (0.9.2)
46
+ mini_portile2 (2.4.0)
45
47
  multi_json (1.13.1)
46
48
  multi_xml (0.6.0)
47
49
  multipart-post (2.0.0)
48
- nokogiri (1.8.5)
49
- mini_portile2 (~> 2.3.0)
50
+ nokogiri (1.10.2)
51
+ mini_portile2 (~> 2.4.0)
50
52
  oauth2 (1.4.1)
51
53
  faraday (>= 0.8, < 0.16.0)
52
54
  jwt (>= 1.0, < 3.0)
53
55
  multi_json (~> 1.3)
54
56
  multi_xml (~> 0.5)
55
57
  rack (>= 1.2, < 3)
56
- pry (0.11.3)
58
+ pry (0.12.2)
57
59
  coderay (~> 1.1.0)
58
60
  method_source (~> 0.9.0)
59
- pry-byebug (3.6.0)
60
- byebug (~> 10.0)
61
+ pry-byebug (3.7.0)
62
+ byebug (~> 11.0)
61
63
  pry (~> 0.10)
62
- rack (2.0.6)
63
- rake (12.3.1)
64
- rdoc (6.0.3)
64
+ public_suffix (3.0.3)
65
+ rack (2.0.7)
66
+ rake (12.3.2)
67
+ rdoc (6.1.1)
65
68
  reenhanced_bitbucket_api (0.3.2)
66
69
  faraday (~> 0.9.0)
67
70
  faraday_middleware (~> 0.9.0)
@@ -82,11 +85,11 @@ GEM
82
85
  diff-lcs (>= 1.2.0, < 2.0)
83
86
  rspec-support (~> 3.7.0)
84
87
  rspec-support (3.7.1)
85
- safe_yaml (1.0.4)
88
+ safe_yaml (1.0.5)
86
89
  simple_oauth (0.3.1)
87
- thor (0.20.0)
90
+ thor (0.20.3)
88
91
  thread_safe (0.3.6)
89
- webmock (3.3.0)
92
+ webmock (3.5.1)
90
93
  addressable (>= 2.3.6)
91
94
  crack (>= 0.3.2)
92
95
  hashdiff
@@ -97,7 +100,6 @@ PLATFORMS
97
100
 
98
101
  DEPENDENCIES
99
102
  appraisal (= 2.2.0)
100
- bundler (~> 1.16)
101
103
  chronic
102
104
  git_reflow!
103
105
  pry-byebug
data/Workflow ADDED
@@ -0,0 +1,3 @@
1
+ # This file is empty on purpose in case there are any custom workflows configured locally.
2
+ # Eventually we will update it to:
3
+ # use "OpenSourceWorkflow"
data/git_reflow.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.rdoc_options << '--title' << 'git_reflow' << '-ri'
20
20
 
21
21
  s.add_development_dependency('appraisal', '2.2.0')
22
- s.add_development_dependency('bundler', "~> 1.16")
23
22
  s.add_development_dependency('chronic')
24
23
  s.add_development_dependency('pry-byebug')
25
24
  s.add_development_dependency('rake', "~> 12.3")
@@ -28,6 +27,7 @@ Gem::Specification.new do |s|
28
27
  s.add_development_dependency('webmock')
29
28
  s.add_development_dependency('wwtd', '1.3.0')
30
29
 
30
+ s.add_dependency('bundler', '>= 1.10.0')
31
31
  s.add_dependency('colorize', '>= 0.7.0')
32
32
  s.add_dependency('highline')
33
33
  s.add_dependency('httpclient')
@@ -7,6 +7,7 @@ module GitReflow
7
7
  def stub_command_line
8
8
  $commands_ran = []
9
9
  $stubbed_commands = {}
10
+ $stubbed_runners = Set.new
10
11
  $output = []
11
12
  $says = []
12
13
 
@@ -33,6 +34,7 @@ module GitReflow
33
34
  end
34
35
 
35
36
  def stub_run_for(module_to_stub)
37
+ $stubbed_runners << module_to_stub
36
38
  allow(module_to_stub).to receive(:run) do |command, options|
37
39
  options = { loud: true, blocking: true }.merge(options || {})
38
40
  $commands_ran << Hashie::Mash.new(command: command, options: options)
@@ -52,24 +54,31 @@ module GitReflow
52
54
  $says = []
53
55
  end
54
56
 
55
- def stub_command(command, return_value)
57
+ def stub_command(command:, return_value: "", options: {})
56
58
  $stubbed_commands[command] = return_value
57
- allow(GitReflow::Sandbox).to receive(:run).with(command).and_return(return_value)
59
+ $stubbed_runners.each do |runner|
60
+ allow(runner).to receive(:run).with(command, options) do |command, options|
61
+ options = { loud: true, blocking: true }.merge(options || {})
62
+ $commands_ran << Hashie::Mash.new(command: command, options: options)
63
+ $stubbed_commands[command] = return_value
64
+ raise GitReflow::Sandbox::CommandError.new(return_value, "\"#{command}\" failed to run.") if options[:raise]
65
+ end
66
+ end
58
67
  end
59
68
 
60
69
  def stub_command_line_inputs_for(module_to_stub, inputs)
61
70
  allow(module_to_stub).to receive(:ask) do |terminal, question|
62
- return_value = inputs[question]
63
- question = ""
64
- return_value
71
+ return_value = inputs[question]
72
+ question = ""
73
+ return_value
65
74
  end
66
75
  end
67
76
 
68
77
  def stub_command_line_inputs(inputs)
69
78
  allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
70
- return_value = inputs[question]
71
- question = ""
72
- return_value
79
+ return_value = inputs[question]
80
+ question = ""
81
+ return_value
73
82
  end
74
83
  end
75
84
 
@@ -12,8 +12,16 @@ module GitReflow
12
12
  plain: :white
13
13
  }
14
14
 
15
+ class CommandError < StandardError;
16
+ attr_reader :output
17
+ def initialize(output, *args)
18
+ @output = output
19
+ super(*args)
20
+ end
21
+ end
22
+
15
23
  def run(command, options = {})
16
- options = { loud: true, blocking: true }.merge(options)
24
+ options = { loud: true, blocking: true, raise: false }.merge(options)
17
25
 
18
26
  GitReflow.logger.debug "Running... #{command}"
19
27
 
@@ -22,12 +30,13 @@ module GitReflow
22
30
  else
23
31
  output = %x{#{command}}
24
32
 
25
- if options[:blocking] == true && !$?.success?
26
- abort "\"#{command}\" failed to run."
27
- else
28
- puts output if options[:loud] == true
29
- output
33
+ if !$?.success?
34
+ raise CommandError.new(output, "\"#{command}\" failed to run.") if options[:raise] == true
35
+ abort "\"#{command}\" failed to run." if options[:blocking] == true
30
36
  end
37
+
38
+ puts output if options[:loud] == true
39
+ output
31
40
  end
32
41
  end
33
42
 
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'git_reflow/sandbox'
2
2
  require 'git_reflow/git_helpers'
3
+ require 'bundler/inline'
3
4
 
4
5
  module GitReflow
5
6
  module Workflow
@@ -80,6 +81,32 @@ module GitReflow
80
81
  GitReflow.logger
81
82
  end
82
83
 
84
+ # Checks for an installed gem, and if none is installed use bundler's
85
+ # inline gemfile to install it.
86
+ #
87
+ # @param name [String] the name of the gem to require as a dependency
88
+ def use_gem(name, *args)
89
+ run("gem list -ie #{name}", loud: false, raise: true)
90
+ logger.info "Using installed gem '#{name}' with options: #{args.inspect}"
91
+ rescue ::GitReflow::Sandbox::CommandError => e
92
+ abort e.message unless e.output =~ /\Afalse/
93
+ logger.info "Installing gem '#{name}' with options: #{args.inspect}"
94
+ say "Installing gem '#{name}'...", :notice
95
+ gemfile do
96
+ source "https://rubygems.org"
97
+ gem name, *args
98
+ end
99
+ end
100
+
101
+ # Use bundler's inline gemfile to install dependencies.
102
+ # See: https://bundler.io/v1.16/guides/bundler_in_a_single_file_ruby_script.html
103
+ #
104
+ # @yield A block to be executed in the context of Bundler's `gemfile` DSL
105
+ def use_gemfile(&block)
106
+ logger.info "Using a custom gemfile"
107
+ gemfile(true, &block)
108
+ end
109
+
83
110
  # Loads a pre-defined workflow (FlatMergeWorkflow) from within another
84
111
  # Workflow file
85
112
  #
@@ -153,7 +180,7 @@ module GitReflow
153
180
  args_with_defaults.merge!(argument_overrides) if argument_overrides.is_a?(Hash)
154
181
  end
155
182
 
156
- GitReflow.logger.debug "Running command `#{name}` with args: #{args_with_defaults.inspect}..."
183
+ GitReflow.logger.info "Running command `#{name}` with args: #{args_with_defaults.inspect}..."
157
184
  block.call(**args_with_defaults)
158
185
 
159
186
  Array(callbacks[:after][name]).each do |block|
@@ -6,6 +6,23 @@ describe GitReflow::Workflow do
6
6
  include GitReflow::Workflow
7
7
  end
8
8
 
9
+ class DummyBundler
10
+ def gemfile(&block)
11
+ instance_eval &block
12
+ end
13
+
14
+ def source(name); end
15
+ def gem(name, *args); end
16
+ end
17
+
18
+ class DummyGemifiedWorkflow
19
+ include GitReflow::Workflow
20
+
21
+ command :whirl do
22
+ puts "whirl"
23
+ end
24
+ end
25
+
9
26
  let(:workflow) { DummyWorkflow }
10
27
  let(:loader) { double() }
11
28
 
@@ -164,9 +181,6 @@ describe GitReflow::Workflow do
164
181
 
165
182
  describe ".command" do
166
183
  it "creates a class method for a bogus command" do
167
- class DummyWorkflow
168
- include GitReflow::Workflow
169
- end
170
184
  workflow.command :bogus do
171
185
  GitReflow.say "Woohoo"
172
186
  end
@@ -235,4 +249,56 @@ describe GitReflow::Workflow do
235
249
  end
236
250
  end
237
251
 
252
+ describe ".use_gem(name, *ags)" do
253
+ let(:mock_bundler) { DummyBundler.new }
254
+
255
+ before do
256
+ allow(DummyGemifiedWorkflow).to receive(:gemfile) do |&block|
257
+ mock_bundler.gemfile(&block)
258
+ end
259
+ stub_run_for(DummyGemifiedWorkflow)
260
+ end
261
+
262
+ it "Installs a gem using Bundler's inline gemfile" do
263
+ stub_command(command: "gem list -ie whirly", options: { loud: false, raise: true }, return_value: "false")
264
+ expect(mock_bundler).to receive(:source).with("https://rubygems.org")
265
+ expect(mock_bundler).to receive(:gem).with("whirly", "0.2.6")
266
+
267
+ DummyGemifiedWorkflow.class_eval do
268
+ use_gem "whirly", "0.2.6"
269
+ end
270
+ end
271
+
272
+ it "Uses an existing gem if it's already installed" do
273
+ stub_command(command: "gem list -ie whirly", options: { loud: false, raise: false }, return_value: "true")
274
+ expect(DummyGemifiedWorkflow).to_not receive(:gemfile)
275
+
276
+ DummyGemifiedWorkflow.class_eval do
277
+ use_gem "whirly", "0.2.6"
278
+ end
279
+ end
280
+ end
281
+
282
+ describe ".use_gemfile(&block)" do
283
+ let(:mock_bundler) { DummyBundler.new }
284
+
285
+ before do
286
+ allow(DummyGemifiedWorkflow).to receive(:gemfile) do |&block|
287
+ mock_bundler.gemfile(&block)
288
+ end
289
+ stub_run_for(DummyGemifiedWorkflow)
290
+ end
291
+
292
+ it "runs bundler's inline gemfile with the provided block" do
293
+ expect(mock_bundler).to receive(:source).with("https://rubygems.org")
294
+ expect(mock_bundler).to receive(:gem).with("standard")
295
+
296
+ DummyGemifiedWorkflow.class_eval do
297
+ use_gemfile do
298
+ source "https://rubygems.org"
299
+ gem "standard"
300
+ end
301
+ end
302
+ end
303
+ end
238
304
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_reflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentino Stoll
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-11-09 00:00:00.000000000 Z
13
+ date: 2019-04-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: appraisal
@@ -26,20 +26,6 @@ dependencies:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
28
  version: 2.2.0
29
- - !ruby/object:Gem::Dependency
30
- name: bundler
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: '1.16'
36
- type: :development
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '1.16'
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: chronic
45
31
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +124,20 @@ dependencies:
138
124
  - - '='
139
125
  - !ruby/object:Gem::Version
140
126
  version: 1.3.0
127
+ - !ruby/object:Gem::Dependency
128
+ name: bundler
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 1.10.0
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 1.10.0
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: colorize
143
143
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +226,7 @@ files:
226
226
  - LICENSE
227
227
  - README.md
228
228
  - Rakefile
229
+ - Workflow
229
230
  - _config.yml
230
231
  - bin/console
231
232
  - bin/setup