git_reflow 0.8.10 → 0.9.0

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.ruby-version +1 -1
  4. data/Appraisals +1 -6
  5. data/CHANGELOG.md +426 -348
  6. data/Gemfile.lock +15 -19
  7. data/LICENSE +20 -20
  8. data/README.md +27 -7
  9. data/Rakefile +8 -8
  10. data/bin/console +7 -7
  11. data/bin/setup +6 -6
  12. data/circle.yml +5 -5
  13. data/exe/git-reflow +9 -30
  14. data/git_reflow.gemspec +1 -2
  15. data/lib/git_reflow/config.rb +22 -13
  16. data/lib/git_reflow/git_helpers.rb +69 -22
  17. data/lib/git_reflow/git_server/base.rb +68 -68
  18. data/lib/git_reflow/git_server/git_hub/pull_request.rb +15 -13
  19. data/lib/git_reflow/git_server/pull_request.rb +4 -2
  20. data/lib/git_reflow/merge_error.rb +9 -9
  21. data/lib/git_reflow/rspec/command_line_helpers.rb +9 -1
  22. data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
  23. data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
  24. data/lib/git_reflow/rspec.rb +1 -0
  25. data/lib/git_reflow/sandbox.rb +1 -0
  26. data/lib/git_reflow/version.rb +1 -1
  27. data/lib/git_reflow/workflow.rb +277 -9
  28. data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
  29. data/lib/git_reflow/workflows/core.rb +208 -79
  30. data/lib/git_reflow.rb +3 -14
  31. data/spec/fixtures/awesome_workflow.rb +2 -6
  32. data/spec/fixtures/git/git_config +7 -7
  33. data/spec/fixtures/issues/comment.json.erb +27 -27
  34. data/spec/fixtures/issues/comments.json +29 -29
  35. data/spec/fixtures/issues/comments.json.erb +15 -15
  36. data/spec/fixtures/pull_requests/comment.json.erb +45 -45
  37. data/spec/fixtures/pull_requests/comments.json +47 -47
  38. data/spec/fixtures/pull_requests/comments.json.erb +15 -15
  39. data/spec/fixtures/pull_requests/commits.json +29 -29
  40. data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
  41. data/spec/fixtures/pull_requests/pull_request.json +142 -142
  42. data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
  43. data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
  44. data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
  45. data/spec/fixtures/pull_requests/pull_requests.json +136 -136
  46. data/spec/fixtures/repositories/commit.json +53 -53
  47. data/spec/fixtures/repositories/commit.json.erb +53 -53
  48. data/spec/fixtures/repositories/commits.json.erb +13 -13
  49. data/spec/fixtures/repositories/statuses.json +31 -31
  50. data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
  51. data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +6 -6
  52. data/spec/lib/git_reflow/git_server/pull_request_spec.rb +9 -3
  53. data/spec/lib/git_reflow/workflow_spec.rb +190 -11
  54. data/spec/lib/git_reflow/workflows/core_spec.rb +224 -65
  55. data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +17 -6
  56. data/spec/lib/git_reflow_spec.rb +2 -25
  57. data/spec/spec_helper.rb +3 -0
  58. data/spec/support/github_helpers.rb +1 -1
  59. data/spec/support/mock_pull_request.rb +17 -17
  60. data/spec/support/web_mocks.rb +39 -39
  61. metadata +9 -28
  62. data/lib/git_reflow/commands/deliver.rb +0 -10
  63. data/lib/git_reflow/commands/refresh.rb +0 -20
  64. data/lib/git_reflow/commands/review.rb +0 -13
  65. data/lib/git_reflow/commands/setup.rb +0 -11
  66. data/lib/git_reflow/commands/stage.rb +0 -9
  67. data/lib/git_reflow/commands/start.rb +0 -18
  68. data/lib/git_reflow/commands/status.rb +0 -7
  69. data/lib/git_reflow/workflows/flat_merge.rb +0 -10
  70. data/spec/fixtures/workflow_with_super.rb +0 -8
@@ -17,24 +17,11 @@ describe GitReflow do
17
17
  end
18
18
  end
19
19
 
20
- describe ".default_editor" do
21
- subject { GitReflow.default_editor }
22
-
23
- context "when the environment has EDITOR set" do
24
- before { allow(ENV).to receive(:[]).with('EDITOR').and_return('emacs') }
25
- specify { expect( subject ).to eql('emacs') }
26
- end
27
-
28
- context "when the environment has no EDITOR set" do
29
- before { allow(ENV).to receive(:[]).with('EDITOR').and_return(nil) }
30
- specify { expect( subject ).to eql('vi') }
31
- end
32
- end
33
-
34
20
  describe ".git_server" do
35
21
  subject { GitReflow.git_server }
36
22
 
37
23
  before do
24
+ allow(GitReflow::Config).to receive(:get)
38
25
  allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GitHub ')
39
26
  end
40
27
 
@@ -52,23 +39,13 @@ describe GitReflow do
52
39
  end
53
40
 
54
41
  context "when a workflow is set" do
55
-
56
42
  it "calls the defined workflow methods instead of the default core" do
57
43
  workflow_path = File.join(File.expand_path("../../fixtures", __FILE__), "/awesome_workflow.rb")
58
44
  allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return(workflow_path)
45
+ expect(GitReflow::Workflows::Core).to receive(:load_raw_workflow).with(File.read(workflow_path)).and_call_original
59
46
 
60
- expect(GitReflow.workflow).to eql(GitReflow::Workflow::AwesomeWorkflow)
61
47
  expect{ subject.start }.to have_said "Awesome."
62
48
  end
63
-
64
- it "the workflow can call super" do
65
- workflow_path = File.join(File.expand_path("../../fixtures", __FILE__), "/workflow_with_super.rb")
66
- allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return(workflow_path)
67
-
68
- expect(GitReflow.workflow).to eql(GitReflow::Workflow::WorkflowWithSuper)
69
- expect{ subject.start }.to have_said "Super."
70
- expect{ subject.start }.to have_said "usage: git-reflow start [new-branch-name]", :error
71
- end
72
49
  end
73
50
 
74
51
  end
data/spec/spec_helper.rb CHANGED
@@ -16,6 +16,7 @@ RSpec.configure do |config|
16
16
  config.include GitReflow::RSpec::CommandLineHelpers
17
17
  config.include GithubHelpers
18
18
  config.include GitReflow::RSpec::StubHelpers
19
+ config.include GitReflow::RSpec::WorkflowHelpers
19
20
 
20
21
  config.expect_with :rspec do |c|
21
22
  c.syntax = [:should, :expect]
@@ -28,6 +29,8 @@ RSpec.configure do |config|
28
29
  config.before(:each) do
29
30
  WebMock.reset!
30
31
  stub_command_line
32
+ suppress_loading_of_external_workflows
33
+ GitReflow::Workflow.reset!
31
34
  allow_message_expectations_on_nil
32
35
  end
33
36
 
@@ -39,7 +39,7 @@ module GithubHelpers
39
39
  stub_request(:get, "#{api_endpoint}/authorizations?").to_return(:body => [oauth_token_hash].to_json, status: 200, headers: {})
40
40
  allow(Github::Client).to receive(:new).and_return(github)
41
41
  allow(GitReflow).to receive(:push_current_branch).and_return(true)
42
- allow(GitReflow).to receive(:github).and_return(github)
42
+ allow(GitReflow).to receive(:git_server).and_return(github)
43
43
  allow(GitReflow).to receive(:current_branch).and_return(branch)
44
44
  allow(GitReflow).to receive(:remote_repo_name).and_return(repo)
45
45
  allow(GitReflow).to receive(:remote_user).and_return(user)
@@ -1,17 +1,17 @@
1
- class MockPullRequest < GitReflow::GitServer::PullRequest
2
- DESCRIPTION = "Bingo! Unity."
3
- HTML_URL = "https://github.com/reenhanced/gitreflow/pulls/0"
4
- FEATURE_BRANCH_NAME = "feature_branch"
5
- BASE_BRANCH_NAME = "base"
6
- NUMBER = 0
7
-
8
- def initialize(attributes = Struct.new(:description, :html_url, :feature_branch_name, :base_branch_name, :number).new)
9
- self.description = attributes.description || DESCRIPTION
10
- self.html_url = attributes.html_url || HTML_URL
11
- self.feature_branch_name = attributes.feature_branch_name || FEATURE_BRANCH_NAME
12
- self.base_branch_name = attributes.base_branch_name || BASE_BRANCH_NAME
13
- self.build = Build.new
14
- self.number = attributes.number || NUMBER
15
- self.source_object = attributes
16
- end
17
- end
1
+ class MockPullRequest < GitReflow::GitServer::PullRequest
2
+ DESCRIPTION = "Bingo! Unity."
3
+ HTML_URL = "https://github.com/reenhanced/gitreflow/pulls/0"
4
+ FEATURE_BRANCH_NAME = "feature_branch"
5
+ BASE_BRANCH_NAME = "base"
6
+ NUMBER = 0
7
+
8
+ def initialize(attributes = Struct.new(:description, :html_url, :feature_branch_name, :base_branch_name, :number).new)
9
+ self.description = attributes.description || DESCRIPTION
10
+ self.html_url = attributes.html_url || HTML_URL
11
+ self.feature_branch_name = attributes.feature_branch_name || FEATURE_BRANCH_NAME
12
+ self.base_branch_name = attributes.base_branch_name || BASE_BRANCH_NAME
13
+ self.build = Build.new
14
+ self.number = attributes.number || NUMBER
15
+ self.source_object = attributes
16
+ end
17
+ end
@@ -1,39 +1,39 @@
1
- def stub_get(path, endpoint = GitReflow.git_server.class.api_endpoint)
2
- stub_request(:get, endpoint + path)
3
- end
4
-
5
- def stub_post(path, endpoint = GitReflow.git_server.class.api_endpoint)
6
- stub_request(:post, endpoint + path)
7
- end
8
-
9
- def stub_patch(path, endpoint = Github.endpoint.to_s)
10
- stub_request(:patch, endpoint + path)
11
- end
12
-
13
- def stub_put(path, endpoint = Github.endpoint.to_s)
14
- stub_request(:put, endpoint + path)
15
- end
16
-
17
- def stub_delete(path, endpoint = Github.endpoint.to_s)
18
- stub_request(:delete, endpoint + path)
19
- end
20
-
21
- def a_get(path, endpoint = Github.endpoint.to_s)
22
- a_request(:get, endpoint + path)
23
- end
24
-
25
- def a_post(path, endpoint = Github.endpoint.to_s)
26
- a_request(:post, endpoint + path)
27
- end
28
-
29
- def a_patch(path, endpoint = Github.endpoint.to_s)
30
- a_request(:patch, endpoint + path)
31
- end
32
-
33
- def a_put(path, endpoint = Github.endpoint)
34
- a_request(:put, endpoint + path)
35
- end
36
-
37
- def a_delete(path, endpoint = Github.endpoint)
38
- a_request(:delete, endpoint + path)
39
- end
1
+ def stub_get(path, endpoint = GitReflow.git_server.class.api_endpoint)
2
+ stub_request(:get, endpoint + path)
3
+ end
4
+
5
+ def stub_post(path, endpoint = GitReflow.git_server.class.api_endpoint)
6
+ stub_request(:post, endpoint + path)
7
+ end
8
+
9
+ def stub_patch(path, endpoint = Github.endpoint.to_s)
10
+ stub_request(:patch, endpoint + path)
11
+ end
12
+
13
+ def stub_put(path, endpoint = Github.endpoint.to_s)
14
+ stub_request(:put, endpoint + path)
15
+ end
16
+
17
+ def stub_delete(path, endpoint = Github.endpoint.to_s)
18
+ stub_request(:delete, endpoint + path)
19
+ end
20
+
21
+ def a_get(path, endpoint = Github.endpoint.to_s)
22
+ a_request(:get, endpoint + path)
23
+ end
24
+
25
+ def a_post(path, endpoint = Github.endpoint.to_s)
26
+ a_request(:post, endpoint + path)
27
+ end
28
+
29
+ def a_patch(path, endpoint = Github.endpoint.to_s)
30
+ a_request(:patch, endpoint + path)
31
+ end
32
+
33
+ def a_put(path, endpoint = Github.endpoint)
34
+ a_request(:put, endpoint + path)
35
+ end
36
+
37
+ def a_delete(path, endpoint = Github.endpoint)
38
+ a_request(:delete, endpoint + path)
39
+ 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.8.10
4
+ version: 0.9.0
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-04-19 00:00:00.000000000 Z
13
+ date: 2018-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: appraisal
@@ -152,20 +152,6 @@ dependencies:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: 0.7.0
155
- - !ruby/object:Gem::Dependency
156
- name: gli
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - '='
160
- - !ruby/object:Gem::Version
161
- version: 2.17.0
162
- type: :runtime
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - '='
167
- - !ruby/object:Gem::Version
168
- version: 2.17.0
169
155
  - !ruby/object:Gem::Dependency
170
156
  name: highline
171
157
  requirement: !ruby/object:Gem::Requirement
@@ -200,14 +186,14 @@ dependencies:
200
186
  requirements:
201
187
  - - '='
202
188
  - !ruby/object:Gem::Version
203
- version: 0.15.0
189
+ version: 0.18.2
204
190
  type: :runtime
205
191
  prerelease: false
206
192
  version_requirements: !ruby/object:Gem::Requirement
207
193
  requirements:
208
194
  - - '='
209
195
  - !ruby/object:Gem::Version
210
- version: 0.15.0
196
+ version: 0.18.2
211
197
  - !ruby/object:Gem::Dependency
212
198
  name: reenhanced_bitbucket_api
213
199
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +217,7 @@ extensions: []
231
217
  extra_rdoc_files: []
232
218
  files:
233
219
  - ".gitignore"
220
+ - ".rubocop.yml"
234
221
  - ".ruby-version"
235
222
  - Appraisals
236
223
  - CHANGELOG.md
@@ -247,13 +234,6 @@ files:
247
234
  - git_reflow.gemspec
248
235
  - lib/git_reflow.rb
249
236
  - lib/git_reflow/base.rb
250
- - lib/git_reflow/commands/deliver.rb
251
- - lib/git_reflow/commands/refresh.rb
252
- - lib/git_reflow/commands/review.rb
253
- - lib/git_reflow/commands/setup.rb
254
- - lib/git_reflow/commands/stage.rb
255
- - lib/git_reflow/commands/start.rb
256
- - lib/git_reflow/commands/status.rb
257
237
  - lib/git_reflow/config.rb
258
238
  - lib/git_reflow/git_helpers.rb
259
239
  - lib/git_reflow/git_server.rb
@@ -268,11 +248,12 @@ files:
268
248
  - lib/git_reflow/rspec.rb
269
249
  - lib/git_reflow/rspec/command_line_helpers.rb
270
250
  - lib/git_reflow/rspec/stub_helpers.rb
251
+ - lib/git_reflow/rspec/workflow_helpers.rb
271
252
  - lib/git_reflow/sandbox.rb
272
253
  - lib/git_reflow/version.rb
273
254
  - lib/git_reflow/workflow.rb
255
+ - lib/git_reflow/workflows/FlatMergeWorkflow
274
256
  - lib/git_reflow/workflows/core.rb
275
- - lib/git_reflow/workflows/flat_merge.rb
276
257
  - spec/fixtures/awesome_workflow.rb
277
258
  - spec/fixtures/git/git_config
278
259
  - spec/fixtures/issues/comment.json.erb
@@ -285,6 +266,7 @@ files:
285
266
  - spec/fixtures/pull_requests/external_pull_request.json
286
267
  - spec/fixtures/pull_requests/pull_request.json
287
268
  - spec/fixtures/pull_requests/pull_request.json.erb
269
+ - spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json
288
270
  - spec/fixtures/pull_requests/pull_request_exists_error.json
289
271
  - spec/fixtures/pull_requests/pull_requests.json
290
272
  - spec/fixtures/pull_requests/review.json.erb
@@ -293,7 +275,6 @@ files:
293
275
  - spec/fixtures/repositories/commit.json.erb
294
276
  - spec/fixtures/repositories/commits.json.erb
295
277
  - spec/fixtures/repositories/statuses.json
296
- - spec/fixtures/workflow_with_super.rb
297
278
  - spec/lib/git_reflow/config_spec.rb
298
279
  - spec/lib/git_reflow/git_helpers_spec.rb
299
280
  - spec/lib/git_reflow/git_server/bit_bucket_spec.rb
@@ -355,6 +336,7 @@ test_files:
355
336
  - spec/fixtures/pull_requests/external_pull_request.json
356
337
  - spec/fixtures/pull_requests/pull_request.json
357
338
  - spec/fixtures/pull_requests/pull_request.json.erb
339
+ - spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json
358
340
  - spec/fixtures/pull_requests/pull_request_exists_error.json
359
341
  - spec/fixtures/pull_requests/pull_requests.json
360
342
  - spec/fixtures/pull_requests/review.json.erb
@@ -363,7 +345,6 @@ test_files:
363
345
  - spec/fixtures/repositories/commit.json.erb
364
346
  - spec/fixtures/repositories/commits.json.erb
365
347
  - spec/fixtures/repositories/statuses.json
366
- - spec/fixtures/workflow_with_super.rb
367
348
  - spec/lib/git_reflow/config_spec.rb
368
349
  - spec/lib/git_reflow/git_helpers_spec.rb
369
350
  - spec/lib/git_reflow/git_server/bit_bucket_spec.rb
@@ -1,10 +0,0 @@
1
- desc 'deliver your feature branch'
2
- long_desc 'merge your feature branch down to your base branch, and cleanup your feature branch'
3
-
4
- command :deliver do |c|
5
- c.desc 'merge your feature branch down to your base branch, and cleanup your feature branch'
6
- c.switch [:f, :'skip-lgtm'], desc: 'skip the lgtm checks and deliver your feature branch'
7
- c.action do |global_options, options, args|
8
- GitReflow.deliver base: args[0], force: options[:'skip-lgtm']
9
- end
10
- end
@@ -1,20 +0,0 @@
1
- desc 'Updates and synchronizes your base branch and feature branch.'
2
- long_desc <<LONGTIME
3
- Performs the following:\n
4
- \t$ git checkout <base_branch>\n
5
- \t$ git pull <remote_location> <base_branch>\n
6
- \t$ git checkout <current_branch>\n
7
- \t$ git pull origin <current_branch>\n
8
- \t$ git merge <base_branch>\n
9
- LONGTIME
10
- arg_name '[remote_location] - remote repository name to fetch updates from (origin by default), [base_branch] - branch that you want to merge with (master by default)'
11
- command :refresh do |c|
12
- c.desc 'updates base_branch based on remote and merges the base with your feature_branch'
13
- c.flag [:r,:remote], default_value: 'origin'
14
- c.flag [:b,:base], default_value: 'master'
15
- c.action do |global_options, options, args|
16
-
17
- GitReflow.refresh base: options[:base], remote: options[:remote]
18
-
19
- end
20
- end
@@ -1,13 +0,0 @@
1
- desc 'review will push your latest feature branch changes to your remote repo and create a pull request'
2
- arg_name 'Describe arguments to review here'
3
- command :review do |c|
4
- c.desc 'push your latest feature branch changes to your remote repo and create a pull request against the destination branch'
5
- c.arg_name '[destination_branch] - the branch you want to merge your feature branch into'
6
- c.flag [:t, :title]
7
- c.flag [:m, :message]
8
- c.action do |global_options,options,args|
9
-
10
- GitReflow.review base: args[0], title: options[:title], body: options[:message]
11
-
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- desc 'Setup your GitHub account'
2
- command :setup do |c|
3
- c.desc 'sets up your api token with GitHub'
4
- c.switch [:l, :local], default_value: false, desc: 'setup GitReflow for the current project only'
5
- c.switch [:e, :enterprise], default_value: false, desc: 'setup GitReflow with a Github Enterprise account'
6
- c.action do |global_options, options, args|
7
-
8
- GitReflow.setup local: options[:local], enterprise: options[:enterprise]
9
-
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- desc 'Deliver your changes to a staging server'
2
- command :stage do |c|
3
- c.desc 'deliver your feature branch to the staging branch'
4
- c.action do |global_options, options, args|
5
-
6
- GitReflow.stage
7
-
8
- end
9
- end
@@ -1,18 +0,0 @@
1
-
2
- desc 'Start will create a new feature branch and setup remote tracking'
3
- long_desc <<LONGTIME
4
- Performs the following:\n
5
- \t$ git checkout <base_branch>\n
6
- \t$ git pull origin <base_branch>\n
7
- \t$ git push origin <base_branch>:refs/heads/[new_feature_branch]\n
8
- \t$ git checkout --track -b [new_feature_branch] origin/[new_feature_branch]\n
9
- LONGTIME
10
- arg_name '[new-feature-branch-name] - name of the new feature branch'
11
- command :start do |c|
12
- c.flag [:b,:base], default_value: 'master'
13
- c.action do |global_options, options, args|
14
-
15
- GitReflow.start feature_branch: args[0], base: options[:base]
16
-
17
- end
18
- end
@@ -1,7 +0,0 @@
1
- desc 'Display information about the status of your feature in the review process'
2
- arg_name "destination_branch - the branch you're merging your feature into ('master' is default)"
3
- command :status do |c|
4
- c.action do |global_options, options, args|
5
- GitReflow.status destination_branch: args[0]
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- class FlatMerge < GitReflow::Workflows::Core
2
- def self.deliver(**params)
3
- base_branch = params[:base] || 'master'
4
- params[:squash] = false
5
-
6
- super(**params)
7
- end
8
- end
9
-
10
- FlatMerge
@@ -1,8 +0,0 @@
1
- class WorkflowWithSuper < GitReflow::Workflows::Core
2
- def self.start(**args)
3
- GitReflow.say "Super."
4
- super(feature_branch: args[:feature_branch], base: args[:base])
5
- end
6
- end
7
-
8
- WorkflowWithSuper