git_reflow 0.8.9 → 0.9.3

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 (87) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/multi-ruby-tests.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +2 -0
  5. data/.ruby-version +1 -0
  6. data/Appraisals +1 -6
  7. data/CHANGELOG.md +466 -348
  8. data/Gemfile.lock +99 -72
  9. data/LICENSE +20 -20
  10. data/README.md +481 -0
  11. data/Rakefile +15 -8
  12. data/Workflow +3 -0
  13. data/_config.yml +1 -0
  14. data/bin/console +7 -7
  15. data/bin/setup +6 -6
  16. data/exe/git-reflow +20 -36
  17. data/git_reflow.gemspec +26 -30
  18. data/lib/git_reflow.rb +3 -15
  19. data/lib/git_reflow/config.rb +48 -13
  20. data/lib/git_reflow/git_helpers.rb +69 -22
  21. data/lib/git_reflow/git_server.rb +63 -63
  22. data/lib/git_reflow/git_server/base.rb +68 -68
  23. data/lib/git_reflow/git_server/bit_bucket.rb +101 -101
  24. data/lib/git_reflow/git_server/bit_bucket/pull_request.rb +84 -84
  25. data/lib/git_reflow/git_server/git_hub.rb +53 -41
  26. data/lib/git_reflow/git_server/git_hub/pull_request.rb +16 -14
  27. data/lib/git_reflow/git_server/pull_request.rb +4 -2
  28. data/lib/git_reflow/merge_error.rb +9 -9
  29. data/lib/git_reflow/rspec.rb +3 -2
  30. data/lib/git_reflow/rspec/command_line_helpers.rb +23 -6
  31. data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
  32. data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
  33. data/lib/git_reflow/sandbox.rb +16 -6
  34. data/lib/git_reflow/version.rb +1 -1
  35. data/lib/git_reflow/workflow.rb +304 -9
  36. data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
  37. data/lib/git_reflow/workflows/core.rb +364 -238
  38. data/spec/fixtures/authentication_failure.json +3 -0
  39. data/spec/fixtures/awesome_workflow.rb +3 -7
  40. data/spec/fixtures/git/git_config +7 -7
  41. data/spec/fixtures/issues/comment.json.erb +27 -27
  42. data/spec/fixtures/issues/comments.json +29 -29
  43. data/spec/fixtures/issues/comments.json.erb +15 -15
  44. data/spec/fixtures/pull_requests/comment.json.erb +45 -45
  45. data/spec/fixtures/pull_requests/comments.json +47 -47
  46. data/spec/fixtures/pull_requests/comments.json.erb +15 -15
  47. data/spec/fixtures/pull_requests/commits.json +29 -29
  48. data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
  49. data/spec/fixtures/pull_requests/pull_request.json +142 -142
  50. data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
  51. data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
  52. data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
  53. data/spec/fixtures/pull_requests/pull_requests.json +136 -136
  54. data/spec/fixtures/repositories/commit.json +53 -53
  55. data/spec/fixtures/repositories/commit.json.erb +53 -53
  56. data/spec/fixtures/repositories/commits.json.erb +13 -13
  57. data/spec/fixtures/repositories/statuses.json +31 -31
  58. data/spec/fixtures/users/user.json +32 -0
  59. data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
  60. data/spec/lib/git_reflow/git_server/bit_bucket_spec.rb +81 -81
  61. data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +10 -10
  62. data/spec/lib/git_reflow/git_server/git_hub_spec.rb +77 -3
  63. data/spec/lib/git_reflow/git_server/pull_request_spec.rb +9 -3
  64. data/spec/lib/git_reflow/git_server_spec.rb +101 -101
  65. data/spec/lib/git_reflow/sandbox_spec.rb +1 -1
  66. data/spec/lib/git_reflow/workflow_spec.rb +304 -59
  67. data/spec/lib/git_reflow/workflows/core_spec.rb +225 -67
  68. data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +71 -59
  69. data/spec/lib/git_reflow_spec.rb +2 -25
  70. data/spec/spec_helper.rb +3 -0
  71. data/spec/support/fixtures.rb +54 -54
  72. data/spec/support/github_helpers.rb +99 -109
  73. data/spec/support/mock_pull_request.rb +17 -17
  74. data/spec/support/web_mocks.rb +39 -39
  75. metadata +51 -74
  76. data/README.rdoc +0 -461
  77. data/circle.yml +0 -26
  78. data/lib/git_reflow/commands/deliver.rb +0 -10
  79. data/lib/git_reflow/commands/refresh.rb +0 -20
  80. data/lib/git_reflow/commands/review.rb +0 -13
  81. data/lib/git_reflow/commands/setup.rb +0 -11
  82. data/lib/git_reflow/commands/stage.rb +0 -9
  83. data/lib/git_reflow/commands/start.rb +0 -18
  84. data/lib/git_reflow/commands/status.rb +0 -7
  85. data/lib/git_reflow/os_detector.rb +0 -23
  86. data/lib/git_reflow/workflows/flat_merge.rb +0 -10
  87. data/spec/fixtures/workflow_with_super.rb +0 -8
@@ -1,63 +1,63 @@
1
- module GitReflow
2
- module GitServer
3
- autoload :Base, 'git_reflow/git_server/base'
4
- autoload :GitHub, 'git_reflow/git_server/git_hub'
5
- autoload :PullRequest, 'git_reflow/git_server/pull_request'
6
-
7
- extend self
8
-
9
- class ConnectionError < StandardError; end
10
-
11
- def connect(options = {})
12
- options ||= {}
13
- options[:provider] = 'GitHub' if "#{options[:provider]}".length <= 0
14
- begin
15
- provider_name = options[:provider]
16
- provider = provider_class_for(options.delete(:provider)).new(options)
17
- provider.authenticate(options.keep_if {|key, value| key == :silent })
18
- provider
19
- rescue ConnectionError => e
20
- GitReflow.say "Error connecting to #{provider_name}: #{e.message}", :error
21
- end
22
- end
23
-
24
- def connection
25
- return nil unless current_provider
26
- current_provider.connection
27
- end
28
-
29
- def current_provider
30
- provider = "#{GitReflow::Config.get('reflow.git-server', local: true) || GitReflow::Config.get('reflow.git-server')}"
31
- if provider.length > 0
32
- begin
33
- provider_class_for(provider)
34
- rescue ConnectionError => e
35
- GitReflow.say e.message, :error
36
- nil
37
- end
38
- else
39
- GitReflow.say "Reflow hasn't been setup yet. Run 'git reflow setup' to continue", :notice
40
- nil
41
- end
42
- end
43
-
44
- def can_connect_to?(provider)
45
- GitReflow::GitServer.const_defined?(provider)
46
- end
47
-
48
- def create_pull_request(options = {})
49
- raise "#{self.class.to_s}#create_pull_request method must be implemented"
50
- end
51
-
52
- def find_open_pull_request(options = {})
53
- raise "#{self.class.to_s}#find_open_pull_request method must be implemented"
54
- end
55
-
56
- private
57
-
58
- def provider_class_for(provider)
59
- raise ConnectionError, "GitServer not setup for \"#{provider}\"" unless self.can_connect_to?(provider)
60
- GitReflow::GitServer.const_get(provider)
61
- end
62
- end
63
- end
1
+ module GitReflow
2
+ module GitServer
3
+ autoload :Base, 'git_reflow/git_server/base'
4
+ autoload :GitHub, 'git_reflow/git_server/git_hub'
5
+ autoload :PullRequest, 'git_reflow/git_server/pull_request'
6
+
7
+ extend self
8
+
9
+ class ConnectionError < StandardError; end
10
+
11
+ def connect(options = {})
12
+ options ||= {}
13
+ options[:provider] = 'GitHub' if "#{options[:provider]}".length <= 0
14
+ begin
15
+ provider_name = options[:provider]
16
+ provider = provider_class_for(options.delete(:provider)).new(options)
17
+ provider.authenticate(options.keep_if {|key, value| key == :silent })
18
+ provider
19
+ rescue ConnectionError => e
20
+ GitReflow.say "Error connecting to #{provider_name}: #{e.message}", :error
21
+ end
22
+ end
23
+
24
+ def connection
25
+ return nil unless current_provider
26
+ current_provider.connection
27
+ end
28
+
29
+ def current_provider
30
+ provider = "#{GitReflow::Config.get('reflow.git-server', local: true) || GitReflow::Config.get('reflow.git-server')}"
31
+ if provider.length > 0
32
+ begin
33
+ provider_class_for(provider)
34
+ rescue ConnectionError => e
35
+ GitReflow.say e.message, :error
36
+ nil
37
+ end
38
+ else
39
+ GitReflow.say "Reflow hasn't been setup yet. Run 'git reflow setup' to continue", :notice
40
+ nil
41
+ end
42
+ end
43
+
44
+ def can_connect_to?(provider)
45
+ GitReflow::GitServer.const_defined?(provider)
46
+ end
47
+
48
+ def create_pull_request(options = {})
49
+ raise "#{self.class.to_s}#create_pull_request method must be implemented"
50
+ end
51
+
52
+ def find_open_pull_request(options = {})
53
+ raise "#{self.class.to_s}#find_open_pull_request method must be implemented"
54
+ end
55
+
56
+ private
57
+
58
+ def provider_class_for(provider)
59
+ raise ConnectionError, "GitServer not setup for \"#{provider}\"" unless self.can_connect_to?(provider)
60
+ GitReflow::GitServer.const_get(provider)
61
+ end
62
+ end
63
+ end
@@ -1,68 +1,68 @@
1
- require 'git_reflow/config'
2
-
3
- module GitReflow
4
- class GitServer::Base
5
- extend GitHelpers
6
-
7
- @@connection = nil
8
-
9
- def initialize(options)
10
- site_url = self.class.site_url
11
- api_endpoint = self.class.api_endpoint
12
-
13
- self.class.site_url = site_url
14
- self.class.api_endpoint = api_endpoint
15
-
16
- authenticate
17
- end
18
-
19
- def self.connection
20
- raise "#{self.class.to_s}.connection method must be implemented"
21
- end
22
-
23
- def self.user
24
- raise "#{self.class.to_s}.user method must be implemented"
25
- end
26
-
27
- def self.api_endpoint
28
- raise "#{self.class.to_s}.api_endpoint method must be implemented"
29
- end
30
-
31
- def self.api_endpoint=(api_endpoint, options = {local: false})
32
- raise "#{self.class.to_s}.api_endpoint= method must be implemented"
33
- end
34
-
35
- def self.site_url
36
- raise "#{self.class.to_s}.site_url method must be implemented"
37
- end
38
-
39
- def self.site_url=(site_url, options = {local: false})
40
- raise "#{self.class.to_s}.site_url= method must be implemented"
41
- end
42
-
43
- def self.project_only?
44
- GitReflow::Config.get("reflow.local-projects", all: true).include? "#{remote_user}/#{remote_repo_name}"
45
- end
46
-
47
- def connection
48
- @connection ||= self.class.connection
49
- end
50
-
51
- def authenticate
52
- raise "#{self.class.to_s}#authenticate method must be implemented"
53
- end
54
-
55
- def find_open_pull_request(options)
56
- raise "#{self.class.to_s}#find_open_pull_request(options) method must be implemented"
57
- end
58
-
59
- def get_build_status sha
60
- raise "#{self.class.to_s}#get_build_status(sha) method must be implemented"
61
- end
62
-
63
- def colorized_build_description status
64
- raise "#{self.class.to_s}#colorized_build_description(status) method must be implemented"
65
- end
66
-
67
- end
68
- end
1
+ require 'git_reflow/config'
2
+
3
+ module GitReflow
4
+ class GitServer::Base
5
+ extend GitHelpers
6
+
7
+ @@connection = nil
8
+
9
+ def initialize(options)
10
+ site_url = self.class.site_url
11
+ api_endpoint = self.class.api_endpoint
12
+
13
+ self.class.site_url = site_url
14
+ self.class.api_endpoint = api_endpoint
15
+
16
+ authenticate
17
+ end
18
+
19
+ def self.connection
20
+ raise "#{self.class.to_s}.connection method must be implemented"
21
+ end
22
+
23
+ def self.user
24
+ raise "#{self.class.to_s}.user method must be implemented"
25
+ end
26
+
27
+ def self.api_endpoint
28
+ raise "#{self.class.to_s}.api_endpoint method must be implemented"
29
+ end
30
+
31
+ def self.api_endpoint=(api_endpoint, options = {local: false})
32
+ raise "#{self.class.to_s}.api_endpoint= method must be implemented"
33
+ end
34
+
35
+ def self.site_url
36
+ raise "#{self.class.to_s}.site_url method must be implemented"
37
+ end
38
+
39
+ def self.site_url=(site_url, options = {local: false})
40
+ raise "#{self.class.to_s}.site_url= method must be implemented"
41
+ end
42
+
43
+ def self.project_only?
44
+ GitReflow::Config.get("reflow.local-projects", all: true).include? "#{remote_user}/#{remote_repo_name}"
45
+ end
46
+
47
+ def connection
48
+ @connection ||= self.class.connection
49
+ end
50
+
51
+ def authenticate
52
+ raise "#{self.class.to_s}#authenticate method must be implemented"
53
+ end
54
+
55
+ def find_open_pull_request(options)
56
+ raise "#{self.class.to_s}#find_open_pull_request(options) method must be implemented"
57
+ end
58
+
59
+ def get_build_status sha
60
+ raise "#{self.class.to_s}#get_build_status(sha) method must be implemented"
61
+ end
62
+
63
+ def colorized_build_description status
64
+ raise "#{self.class.to_s}#colorized_build_description(status) method must be implemented"
65
+ end
66
+
67
+ end
68
+ end
@@ -1,101 +1,101 @@
1
- require 'bitbucket_rest_api'
2
- require 'git_reflow/git_helpers'
3
-
4
- module GitReflow
5
- module GitServer
6
- class BitBucket < Base
7
- require_relative 'bit_bucket/pull_request'
8
-
9
- attr_accessor :connection
10
-
11
- def initialize(config_options = {})
12
- project_only = !!config_options.delete(:project_only)
13
-
14
- # We remove any existing setup first, then setup our required config settings
15
- GitReflow::Config.unset('reflow.local-projects', value: "#{self.class.remote_user}/#{self.class.remote_repo_name}")
16
- GitReflow::Config.add('reflow.local-projects', "#{self.class.remote_user}/#{self.class.remote_repo_name}") if project_only
17
- GitReflow::Config.set('reflow.git-server', 'BitBucket', local: project_only)
18
- end
19
-
20
- def self.connection
21
- if api_key_setup?
22
- @connection ||= ::BitBucket.new login: remote_user, password: api_key
23
- end
24
- end
25
-
26
- def self.api_endpoint
27
- endpoint = GitReflow::Config.get("bitbucket.endpoint", local: project_only?)
28
- (endpoint.length > 0) ? endpoint : ::BitBucket::Configuration::DEFAULT_ENDPOINT
29
- end
30
-
31
- def self.site_url
32
- site_url = GitReflow::Config.get("bitbucket.site", local: project_only?)
33
- (site_url.length > 0) ? site_url : 'https://bitbucket.org'
34
- end
35
-
36
- def self.api_key
37
- GitReflow::Config.get("bitbucket.api-key", reload: true, local: project_only?)
38
- end
39
-
40
- def self.api_key=(key)
41
- GitReflow::Config.set("bitbucket.api-key", key, local: project_only?)
42
- end
43
- def self.api_key_setup?
44
- (self.api_key.length > 0)
45
- end
46
-
47
- def self.user
48
- GitReflow::Config.get('bitbucket.user', local: project_only?)
49
- end
50
-
51
- def self.user=(bitbucket_user)
52
- GitReflow::Config.set('bitbucket.user', bitbucket_user, local: project_only?)
53
- end
54
-
55
- def authenticate(options = {silent: false})
56
- begin
57
- if connection and self.class.api_key_setup?
58
- unless options[:silent]
59
- GitReflow.say "\nYour BitBucket account was already setup with:"
60
- GitReflow.say "\tUser Name: #{self.class.user}"
61
- end
62
- else
63
- self.class.user = options[:user] || ask("Please enter your BitBucket username: ")
64
- GitReflow.say "\nIn order to connect your BitBucket account,"
65
- GitReflow.say "you'll need to generate an API key for your team"
66
- GitReflow.say "Visit #{self.class.site_url}/account/user/#{self.class.remote_user}/api-key/, to generate it\n"
67
- self.class.api_key = ask("Please enter your team's API key: ")
68
- connection.repos.all(self.class.remote_user).count
69
- GitReflow.say "Connected to BitBucket\!", :success
70
- end
71
- rescue ::BitBucket::Error::Unauthorized => e
72
- GitReflow::Config.unset('bitbucket.api-key', local: self.class.project_only?)
73
- GitReflow.say "Invalid API key for team #{self.class.remote_user}.", :error
74
- end
75
- end
76
-
77
- def connection
78
- @connection ||= self.class.connection
79
- end
80
-
81
- def get_build_status(sha)
82
- # BitBucket does not currently support build status via API
83
- # for updates: https://bitbucket.org/site/master/issue/8548/better-ci-integration-add-a-build-status
84
- return nil
85
- end
86
-
87
- def colorized_build_description(state, description)
88
- ""
89
- end
90
-
91
- def create_pull_request(options = {})
92
- PullRequest.create(options)
93
- end
94
-
95
- def find_open_pull_request(options = {})
96
- PullRequest.find_open(options)
97
- end
98
-
99
- end
100
- end
101
- end
1
+ require 'bitbucket_rest_api'
2
+ require 'git_reflow/git_helpers'
3
+
4
+ module GitReflow
5
+ module GitServer
6
+ class BitBucket < Base
7
+ require_relative 'bit_bucket/pull_request'
8
+
9
+ attr_reader :connection
10
+
11
+ def initialize(config_options = {})
12
+ project_only = !!config_options.delete(:project_only)
13
+
14
+ # We remove any existing setup first, then setup our required config settings
15
+ GitReflow::Config.unset('reflow.local-projects', value: "#{self.class.remote_user}/#{self.class.remote_repo_name}")
16
+ GitReflow::Config.add('reflow.local-projects', "#{self.class.remote_user}/#{self.class.remote_repo_name}") if project_only
17
+ GitReflow::Config.set('reflow.git-server', 'BitBucket', local: project_only)
18
+ end
19
+
20
+ def self.connection
21
+ if api_key_setup?
22
+ @connection ||= ::BitBucket.new login: remote_user, password: api_key
23
+ end
24
+ end
25
+
26
+ def self.api_endpoint
27
+ endpoint = GitReflow::Config.get("bitbucket.endpoint", local: project_only?)
28
+ (endpoint.length > 0) ? endpoint : ::BitBucket::Configuration::DEFAULT_ENDPOINT
29
+ end
30
+
31
+ def self.site_url
32
+ site_url = GitReflow::Config.get("bitbucket.site", local: project_only?)
33
+ (site_url.length > 0) ? site_url : 'https://bitbucket.org'
34
+ end
35
+
36
+ def self.api_key
37
+ GitReflow::Config.get("bitbucket.api-key", reload: true, local: project_only?)
38
+ end
39
+
40
+ def self.api_key=(key)
41
+ GitReflow::Config.set("bitbucket.api-key", key, local: project_only?)
42
+ end
43
+ def self.api_key_setup?
44
+ (self.api_key.length > 0)
45
+ end
46
+
47
+ def self.user
48
+ GitReflow::Config.get('bitbucket.user', local: project_only?)
49
+ end
50
+
51
+ def self.user=(bitbucket_user)
52
+ GitReflow::Config.set('bitbucket.user', bitbucket_user, local: project_only?)
53
+ end
54
+
55
+ def authenticate(options = {silent: false})
56
+ begin
57
+ if connection and self.class.api_key_setup?
58
+ unless options[:silent]
59
+ GitReflow.say "\nYour BitBucket account was already setup with:"
60
+ GitReflow.say "\tUser Name: #{self.class.user}"
61
+ end
62
+ else
63
+ self.class.user = options[:user] || ask("Please enter your BitBucket username: ")
64
+ GitReflow.say "\nIn order to connect your BitBucket account,"
65
+ GitReflow.say "you'll need to generate an API key for your team"
66
+ GitReflow.say "Visit #{self.class.site_url}/account/user/#{self.class.remote_user}/api-key/, to generate it\n"
67
+ self.class.api_key = ask("Please enter your team's API key: ")
68
+ connection.repos.all(self.class.remote_user).count
69
+ GitReflow.say "Connected to BitBucket\!", :success
70
+ end
71
+ rescue ::BitBucket::Error::Unauthorized => e
72
+ GitReflow::Config.unset('bitbucket.api-key', local: self.class.project_only?)
73
+ GitReflow.say "Invalid API key for team #{self.class.remote_user}.", :error
74
+ end
75
+ end
76
+
77
+ def connection
78
+ @connection ||= self.class.connection
79
+ end
80
+
81
+ def get_build_status(sha)
82
+ # BitBucket does not currently support build status via API
83
+ # for updates: https://bitbucket.org/site/master/issue/8548/better-ci-integration-add-a-build-status
84
+ return nil
85
+ end
86
+
87
+ def colorized_build_description(state, description)
88
+ ""
89
+ end
90
+
91
+ def create_pull_request(options = {})
92
+ PullRequest.create(options)
93
+ end
94
+
95
+ def find_open_pull_request(options = {})
96
+ PullRequest.find_open(options)
97
+ end
98
+
99
+ end
100
+ end
101
+ end