git_reflow 0.8.3 → 0.8.4

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
  SHA1:
3
- metadata.gz: b1b9acdcd9558da180198608f42c0e65f51ce6ae
4
- data.tar.gz: 161108a3bf8877b1b7ec8893e379d2d16a87cd22
3
+ metadata.gz: 34e27773b70add5bd01632ee991dda30f839404e
4
+ data.tar.gz: 499009182bc3266f823a20fb82149c595d1d5f6f
5
5
  SHA512:
6
- metadata.gz: 581c01a3ba9c9db3a19a60cd69d92364e4387a650b649450f823d2a2b41b33cc7eb4820e031318316de6b8bf6c4f22b96294a074d4b797fb533e7d6f38c6b771
7
- data.tar.gz: b443cfbc4749b6e85f0ceb9338f6c9fe7f4ded9d0eff3f9f0f29581856e9a50e053acb83f779c1cbb8dcfb2e3a3b7697fbd59196a1964c6f7f79748dc3ef4cc9
6
+ metadata.gz: 15bd0fdd708a8f75caff0dbcb68330b5958de09fc763b50e48b264070508844ac63f2b006b33130b326ce365fa674bb1db18f9dafaf5a77f4acfa74812bb69aa
7
+ data.tar.gz: 1efb8f91ea481b608320f0284717f303b36d21392966c344aff27215bd3a7791cd40a54093e55c9ba860a2e6eec0c6b3836eccf94b8930cbbb4483e55c578982
data/CHANGELOG.md CHANGED
@@ -1,7 +1,22 @@
1
1
  # Change Log
2
2
 
3
- ## [v0.8.2](https://github.com/reenhanced/gitreflow/tree/v0.8.2) (2016-08-01)
3
+ ## [Unreleased](https://github.com/reenhanced/gitreflow/tree/v0.8.4)
4
+
5
+ [Full Changelog](https://github.com/reenhanced/gitreflow/compare/v0.8.3...v0.8.4)
6
+
7
+ **Closed issues:**
8
+
9
+ - Introduce the idea of "Workflows" to customize steps [\#53](https://github.com/reenhanced/gitreflow/issues/53)
10
+ - undefined method for strip during setup [\#197](https://github.com/reenhanced/gitreflow/issues/197)
4
11
 
12
+ **Merged pull requests:**
13
+
14
+ - \[53\] Create core workflow module to consolidate commands [\#198](https://github.com/reenhanced/gitreflow/pull/198) ([codenamev](https://github.com/codenamev))
15
+
16
+ ## [v0.8.3](https://github.com/reenhanced/gitreflow/tree/v0.8.3) (2016-08-04)
17
+ [Full Changelog](https://github.com/reenhanced/gitreflow/compare/v0.8.2...v0.8.3)
18
+
19
+ ## [v0.8.2](https://github.com/reenhanced/gitreflow/tree/v0.8.2) (2016-08-01)
5
20
  [Full Changelog](https://github.com/reenhanced/gitreflow/compare/v0.8.1...v0.8.2)
6
21
 
7
22
  **Fixed bugs:**
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.8.3)
4
+ git_reflow (0.8.4)
5
5
  colorize (>= 0.7.0)
6
6
  github_api (= 0.14.0)
7
7
  gli (= 2.14.0)
8
8
  highline
9
9
  httpclient
10
+ rack (>= 1.2, < 2)
10
11
  reenhanced_bitbucket_api (= 0.3.2)
11
12
 
12
13
  GEM
@@ -42,7 +43,7 @@ GEM
42
43
  highline (1.7.8)
43
44
  httpclient (2.8.0)
44
45
  json (1.8.3)
45
- jwt (1.5.1)
46
+ jwt (1.5.4)
46
47
  method_source (0.8.2)
47
48
  mini_portile2 (2.1.0)
48
49
  multi_json (1.12.1)
@@ -51,9 +52,9 @@ GEM
51
52
  nokogiri (1.6.8)
52
53
  mini_portile2 (~> 2.1.0)
53
54
  pkg-config (~> 1.1.7)
54
- oauth2 (1.1.0)
55
+ oauth2 (1.2.0)
55
56
  faraday (>= 0.8, < 0.10)
56
- jwt (~> 1.0, < 1.5.2)
57
+ jwt (~> 1.0)
57
58
  multi_json (~> 1.3)
58
59
  multi_xml (~> 0.5)
59
60
  rack (>= 1.2, < 3)
@@ -65,7 +66,7 @@ GEM
65
66
  pry-byebug (3.4.0)
66
67
  byebug (~> 9.0)
67
68
  pry (~> 0.10)
68
- rack (2.0.1)
69
+ rack (1.6.4)
69
70
  rake (11.1.2)
70
71
  rdoc (4.2.2)
71
72
  json (~> 1.4)
data/git_reflow.gemspec CHANGED
@@ -34,6 +34,10 @@ Gem::Specification.new do |s|
34
34
  s.add_dependency('highline')
35
35
  s.add_dependency('httpclient')
36
36
  s.add_dependency('github_api', '0.14.0')
37
+ # rack is a dependency of oauth2, which is a dependency of github_api
38
+ # The latest rack only supports ruby > 2.2.2, so we lock this down until
39
+ # support for ruby 2.1.x is dropped
40
+ s.add_dependency('rack', ['>= 1.2', '< 2'])
37
41
  s.add_dependency('reenhanced_bitbucket_api', '0.3.2')
38
42
 
39
43
  s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
@@ -5,11 +5,6 @@ command :deliver do |c|
5
5
  c.desc 'merge your feature branch down to your base branch, and cleanup your feature branch'
6
6
  c.switch [:f, :'skip-lgtm'], desc: 'skip the lgtm checks and deliver your feature branch'
7
7
  c.action do |global_options, options, args|
8
- deliver_options = {
9
- base: args[0],
10
- skip_lgtm: options[:'skip-lgtm']
11
- }
12
-
13
- GitReflow.deliver deliver_options
8
+ GitReflow.deliver base: args[0], force: options[:'skip-lgtm']
14
9
  end
15
10
  end
@@ -13,11 +13,8 @@ command :refresh do |c|
13
13
  c.flag [:r,:remote], default_value: 'origin'
14
14
  c.flag [:b,:base], default_value: 'master'
15
15
  c.action do |global_options, options, args|
16
- refresh_options = {
17
- :remote => options[:remote],
18
- :base => options[:base]
19
- }
20
16
 
21
- GitReflow.update_feature_branch(refresh_options)
17
+ GitReflow.refresh base: options[:base], remote: options[:remote]
18
+
22
19
  end
23
20
  end
@@ -6,16 +6,8 @@ command :review do |c|
6
6
  c.flag [:t, :title]
7
7
  c.flag [:m, :message]
8
8
  c.action do |global_options,options,args|
9
- if options[:title] || options[:message]
10
- review_options = {
11
- :base => args[0],
12
- :title => options[:title],
13
- :body => options[:message]
14
- }
15
- else
16
- review_options = { :base => args[0] }
17
- end
18
9
 
19
- GitReflow.review(review_options)
10
+ GitReflow.review base: args[0], title: options[:title], body: options[:message]
11
+
20
12
  end
21
13
  end
@@ -4,30 +4,8 @@ command :setup do |c|
4
4
  c.switch [:l, :local], default_value: false, desc: 'setup GitReflow for the current project only'
5
5
  c.switch [:e, :enterprise], default_value: false, desc: 'setup GitReflow with a Github Enterprise account'
6
6
  c.action do |global_options, options, args|
7
- reflow_options = { project_only: options[:local], enterprise: options[:enterprise] }
8
- existing_git_include_paths = GitReflow::Config.get('include.path', all: true).split("\n")
9
7
 
10
- unless File.exist?(GitReflow::Config::CONFIG_FILE_PATH) or existing_git_include_paths.include?(GitReflow::Config::CONFIG_FILE_PATH)
11
- GitReflow.run "touch #{GitReflow::Config::CONFIG_FILE_PATH}"
12
- GitReflow.say "Created #{GitReflow::Config::CONFIG_FILE_PATH} for Reflow specific configurations", :notice
13
- GitReflow::Config.add "include.path", GitReflow::Config::CONFIG_FILE_PATH, global: true
14
- GitReflow.say "Added #{GitReflow::Config::CONFIG_FILE_PATH} to ~/.gitconfig include paths", :notice
15
- end
8
+ GitReflow.setup local: options[:local], enterprise: options[:enterprise]
16
9
 
17
- choose do |menu|
18
- menu.header = "Available remote Git Server services"
19
- menu.prompt = "Which service would you like to use for this project? "
20
-
21
- menu.choice('GitHub') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'GitHub', silent: false }) }
22
- menu.choice('BitBucket (team-owned repos only)') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'BitBucket', silent: false }) }
23
- end
24
-
25
- GitReflow::Config.set "constants.minimumApprovals", ask("Set the minimum number of approvals (leaving blank will require approval from all commenters): "), local: reflow_options[:project_only]
26
- GitReflow::Config.set "constants.approvalRegex", GitReflow::GitServer::PullRequest::DEFAULT_APPROVAL_REGEX, local: reflow_options[:project_only]
27
-
28
- if GitReflow::Config.get('core.editor').length <= 0
29
- GitReflow::Config.set('core.editor', GitReflow.default_editor, local: reflow_options[:project_only])
30
- GitReflow.say "Updated git's editor (via git config key 'core.editor') to: #{GitReflow.default_editor}.", :notice
31
- end
32
10
  end
33
11
  end
@@ -2,30 +2,8 @@ desc 'Deliver your changes to a staging server'
2
2
  command :stage do |c|
3
3
  c.desc 'deliver your feature branch to the staging branch'
4
4
  c.action do |global_options, options, args|
5
- feature_branch_name = GitReflow.current_branch
6
- staging_branch_name = GitReflow::Config.get('reflow.staging-branch', local: true)
7
5
 
8
- if staging_branch_name.empty?
9
- staging_branch_name = GitReflow.ask("What's the name of your staging branch? (default: 'staging') ")
10
- staging_branch_name = 'staging' if staging_branch_name.strip == ''
11
- GitReflow::Config.set('reflow.staging-branch', staging_branch_name, local: true)
12
- end
6
+ GitReflow.stage
13
7
 
14
- GitReflow.run_command_with_label "git checkout #{staging_branch_name}"
15
- GitReflow.run_command_with_label "git pull origin #{staging_branch_name}"
16
-
17
- if GitReflow.run_command_with_label "git merge #{feature_branch_name}", with_system: true
18
- GitReflow.run_command_with_label "git push origin #{staging_branch_name}"
19
-
20
- staged = GitReflow.deploy(:staging)
21
-
22
- if staged
23
- GitReflow.say "Deployed to Staging.", :success
24
- else
25
- GitReflow.say "There were issues deploying to staging.", :error
26
- end
27
- else
28
- GitReflow.say "There were issues merging your feature branch to staging.", :error
29
- end
30
8
  end
31
9
  end
@@ -11,17 +11,12 @@ arg_name '[new-feature-branch-name] - name of the new feature branch'
11
11
  command :start do |c|
12
12
  c.flag [:b,:base], default_value: 'master'
13
13
  c.action do |global_options, options, args|
14
+
14
15
  if args.empty?
15
16
  raise "usage: git-reflow start [new-branch-name]"
16
17
  else
17
- # base_branch is the branch that you want to base your feature branch off of
18
- # This command allows you to 'git reflow start' off your base branch
19
- base_branch = options[:base]
20
-
21
- GitReflow.run_command_with_label "git checkout #{base_branch}"
22
- GitReflow.run_command_with_label "git pull origin #{base_branch}"
23
- GitReflow.run_command_with_label "git push origin #{GitReflow.current_branch}:refs/heads/#{args[0]}"
24
- GitReflow.run_command_with_label "git checkout --track -b #{args[0]} origin/#{args[0]}"
18
+ GitReflow.start feature_branch: args[0], base: options[:base]
25
19
  end
20
+
26
21
  end
27
22
  end
@@ -2,7 +2,6 @@ desc 'Display information about the status of your feature in the review process
2
2
  arg_name "destination_branch - the branch you're merging your feature into ('master' is default)"
3
3
  command :status do |c|
4
4
  c.action do |global_options, options, args|
5
- destination_branch = args[0] || 'master'
6
- GitReflow.status destination_branch
5
+ GitReflow.status destination_branch: args[0]
7
6
  end
8
7
  end
@@ -19,7 +19,7 @@ module GitReflow
19
19
  end
20
20
 
21
21
  def set(key, value, local: false)
22
- value = value.strip
22
+ value = "#{value}".strip
23
23
  if local
24
24
  GitReflow::Sandbox.run "git config --replace-all #{key} \"#{value}\"", loud: false
25
25
  else
@@ -25,7 +25,7 @@ module GitReflow
25
25
  end
26
26
 
27
27
  def self.find_open(to: 'master', from: GitReflow.git_server.class.current_branch)
28
- matching_pull = GitReflow.git_server.connection.pull_requests.all(GitReflow.git_server.class.remote_user, GitReflow.git_server.class.remote_repo_name, base: to, head: "#{GitReflow.git_server.class.remote_user}:#{from}", state: 'open').first
28
+ matching_pull = GitReflow.git_server.connection.pull_requests.all(GitReflow.remote_user, GitReflow.remote_repo_name, base: to, head: "#{GitReflow.remote_user}:#{from}", state: 'open').first
29
29
  if matching_pull
30
30
  self.new matching_pull
31
31
  end
@@ -56,8 +56,8 @@ module GitReflow
56
56
  end
57
57
 
58
58
  def comments
59
- comments = GitReflow.git_server.connection.issues.comments.all GitReflow.git_server.class.remote_user, GitReflow.git_server.class.remote_repo_name, number: self.number
60
- review_comments = GitReflow.git_server.connection.pull_requests.comments.all GitReflow.git_server.class.remote_user, GitReflow.git_server.class.remote_repo_name, number: self.number
59
+ comments = GitReflow.git_server.connection.issues.comments.all GitReflow.remote_user, GitReflow.remote_repo_name, number: self.number
60
+ review_comments = GitReflow.git_server.connection.pull_requests.comments.all GitReflow.remote_user, GitReflow.remote_repo_name, number: self.number
61
61
 
62
62
  review_comments.to_a + comments.to_a
63
63
  end
@@ -1,3 +1,5 @@
1
+ require "highline"
2
+
1
3
  module GitReflow
2
4
  module RSpec
3
5
  module CommandLineHelpers
@@ -10,9 +12,12 @@ module GitReflow
10
12
 
11
13
  stub_run_for GitReflow
12
14
  stub_run_for GitReflow::Sandbox
15
+ stub_run_for GitReflow::Workflow
16
+ stub_run_for GitReflow::Workflows::Core if defined? GitReflow::Workflows
13
17
 
14
18
  stub_output_for(GitReflow)
15
19
  stub_output_for(GitReflow::Sandbox)
20
+ stub_output_for(GitReflow::Workflow)
16
21
 
17
22
  allow_any_instance_of(GitReflow::GitServer::PullRequest).to receive(:printf) do |format, *output|
18
23
  $output << Array(output).join(" ")
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.8.3"
2
+ VERSION = "0.8.4"
3
3
  end
@@ -0,0 +1,54 @@
1
+ require 'git_reflow/sandbox'
2
+ require 'git_reflow/git_helpers'
3
+
4
+ module GitReflow
5
+ module Workflow
6
+ def self.included base
7
+ base.extend ClassMethods
8
+ end
9
+
10
+ # @nodoc
11
+ def self.current
12
+ GitReflow::Workflows::Core
13
+ end
14
+
15
+ module ClassMethods
16
+ include GitReflow::Sandbox
17
+ include GitReflow::GitHelpers
18
+
19
+ # Creates a singleton method on the inlcuded class
20
+ #
21
+ # This method will take any number of keyword parameters. If @defaults keyword is provided, and the given
22
+ # key(s) in the defaults are not provided as keyword parameters, then it will use the value given in the
23
+ # defaults for that parameter.
24
+ #
25
+ # @param name [Symbol] the name of the method to create
26
+ # @param defaults [Hash] keyword arguments to provide fallbacks for
27
+ #
28
+ # @yield [a:, b:, c:, ...] Invokes the block with an arbitrary number of keyword arguments
29
+ def command(name, **params, &block)
30
+ defaults = params[:defaults] || {}
31
+ self.define_singleton_method(name) do |**args|
32
+ args_with_defaults = {}
33
+ args.each do |name, value|
34
+ if "#{value}".length <= 0
35
+ args_with_defaults[name] = defaults[name]
36
+ else
37
+ args_with_defaults[name] = value
38
+ end
39
+ end
40
+
41
+ defaults.each do |name, value|
42
+ if "#{args_with_defaults[name]}".length <= 0
43
+ args_with_defaults[name] = value
44
+ end
45
+ end
46
+
47
+ block.call(**args_with_defaults)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ extend GitReflow::Workflow
@@ -0,0 +1,240 @@
1
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../..')
2
+ require 'git_reflow/workflow'
3
+
4
+ module GitReflow
5
+ module Workflows
6
+ # This class contains the core workflow for git-reflow. Going forward, this
7
+ # will act as the base class for customizing and extending git-reflow.
8
+ module Core
9
+ include GitReflow::Workflow
10
+
11
+ extend self
12
+
13
+ # Sets up the required git configurations that git-reflow depends on.
14
+ #
15
+ # @param local [Boolean] whether to configure git-reflow specific to the current project
16
+ # @param enterprise [Boolean] whether to configure git-reflow for use with Github Enterprise
17
+ command(:setup, defaults: {local: false, enterprise: false}) do |**params|
18
+ reflow_options = { project_only: params[:local], enterprise: params[:enterprise] }
19
+ existing_git_include_paths = GitReflow::Config.get('include.path', all: true).split("\n")
20
+
21
+ unless File.exist?(GitReflow::Config::CONFIG_FILE_PATH) or existing_git_include_paths.include?(GitReflow::Config::CONFIG_FILE_PATH)
22
+ GitReflow.say "We'll walk you through setting up git-reflow's defaults for all your projects.", :notice
23
+ GitReflow.say "In the future, you can run \`git-reflow setup\` from the root of any project you want to setup differently.", :notice
24
+ GitReflow.say "To adjust these settings globally, you can run \`git-reflow setup --global\`.", :notice
25
+ GitReflow.run "touch #{GitReflow::Config::CONFIG_FILE_PATH}"
26
+ GitReflow.say "Created #{GitReflow::Config::CONFIG_FILE_PATH} for git-reflow specific configurations.", :notice
27
+ GitReflow::Config.add "include.path", GitReflow::Config::CONFIG_FILE_PATH, global: true
28
+ GitReflow.say "Added #{GitReflow::Config::CONFIG_FILE_PATH} to include.path in $HOME/.gitconfig.", :notice
29
+ end
30
+
31
+ choose do |menu|
32
+ menu.header = "Available remote Git Server services"
33
+ menu.prompt = "Which service would you like to use for this project? "
34
+
35
+ menu.choice('GitHub') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'GitHub', silent: false }) }
36
+ menu.choice('BitBucket (team-owned repos only)') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'BitBucket', silent: false }) }
37
+ end
38
+
39
+ GitReflow::Config.set "constants.minimumApprovals", ask("Set the minimum number of approvals (leaving blank will require approval from all commenters): "), local: reflow_options[:project_only]
40
+ GitReflow::Config.set "constants.approvalRegex", GitReflow::GitServer::PullRequest::DEFAULT_APPROVAL_REGEX, local: reflow_options[:project_only]
41
+
42
+ if GitReflow::Config.get('core.editor').length <= 0
43
+ GitReflow::Config.set('core.editor', GitReflow.default_editor, local: reflow_options[:project_only])
44
+ GitReflow.say "Updated git's editor (via git config key 'core.editor') to: #{GitReflow.default_editor}.", :notice
45
+ end
46
+ end
47
+
48
+ # Start a new feature branch
49
+ #
50
+ # @param feature_branch [String] the name of the branch to create your feature on
51
+ # @option base [String] the name of the base branch you want to checkout your feature from
52
+ command(:start, defaults: {base: 'master'}) do |**params|
53
+ base_branch = params[:base]
54
+ feature_branch = params[:feature_branch]
55
+
56
+ if feature_branch.nil? or feature_branch.length <= 0
57
+ GitReflow.say "usage: git-reflow start [new-branch-name]", :error
58
+ else
59
+ GitReflow.run_command_with_label "git checkout #{base_branch}"
60
+ GitReflow.run_command_with_label "git pull origin #{base_branch}"
61
+ GitReflow.run_command_with_label "git push origin #{base_branch}:refs/heads/#{feature_branch}"
62
+ GitReflow.run_command_with_label "git checkout --track -b #{feature_branch} origin/#{feature_branch}"
63
+ end
64
+ end
65
+
66
+ # Submit a feature branch for review
67
+ #
68
+ # @option base [String] the name of the base branch you want to merge your feature into
69
+ # @option title [String] the title of your pull request
70
+ # @option body [String] the body of your pull request
71
+ command(:review, defaults: {base: 'master'}) do |**params|
72
+ base_branch = params[:base]
73
+ create_pull_request = true
74
+
75
+ GitReflow.fetch_destination base_branch
76
+ begin
77
+ GitReflow.push_current_branch
78
+
79
+ existing_pull_request = GitReflow.git_server.find_open_pull_request( from: GitReflow.current_branch, to: base_branch )
80
+ if existing_pull_request
81
+ say "A pull request already exists for these branches:", :notice
82
+ existing_pull_request.display_pull_request_summary
83
+ else
84
+ unless params[:title] || params[:body]
85
+ pull_request_msg_file = "#{GitReflow.git_root_dir}/.git/GIT_REFLOW_PR_MSG"
86
+
87
+ File.open(pull_request_msg_file, 'w') do |file|
88
+ file.write(params[:title] || GitReflow.pull_request_template || GitReflow.current_branch)
89
+ end
90
+
91
+ GitReflow.run("#{GitReflow.git_editor_command} #{pull_request_msg_file}", with_system: true)
92
+
93
+ pr_msg = File.read(pull_request_msg_file).split(/[\r\n]|\r\n/).map(&:strip)
94
+ title = pr_msg.shift
95
+
96
+ File.delete(pull_request_msg_file)
97
+
98
+ unless pr_msg.empty?
99
+ pr_msg.shift if pr_msg.first.empty?
100
+ end
101
+
102
+ params[:title] = title
103
+ params[:body] = "#{pr_msg.join("\n")}\n"
104
+
105
+ say "\nReview your PR:\n"
106
+ say "--------\n"
107
+ say "Title:\n#{params[:title]}\n\n"
108
+ say "Body:\n#{params[:body]}\n"
109
+ say "--------\n"
110
+
111
+ create_pull_request = ask("Submit pull request? (Y)") =~ /y/i
112
+ end
113
+
114
+ if create_pull_request
115
+ pull_request = GitReflow.git_server.create_pull_request(title: params[:title] || params[:body],
116
+ body: params[:body],
117
+ head: "#{GitReflow.remote_user}:#{GitReflow.current_branch}",
118
+ base: params[:base])
119
+
120
+ say "Successfully created pull request ##{pull_request.number}: #{pull_request.title}\nPull Request URL: #{pull_request.html_url}\n", :success
121
+ else
122
+ say "Review aborted. No pull request has been created.", :review_halted
123
+ end
124
+ end
125
+ rescue Github::Error::UnprocessableEntity => e
126
+ say "Github Error: #{e.to_s}", :error
127
+ rescue StandardError => e
128
+ say "\nError: #{e.inspect}", :error
129
+ end
130
+ end
131
+
132
+ # Checks the status of an existing pull request
133
+ #
134
+ # @option destination_branch [String] the branch you're merging your feature into ('master' is default)
135
+ command(:status, defaults: {destination_branch: 'master'}) do |**params|
136
+ pull_request = GitReflow.git_server.find_open_pull_request( :from => GitReflow.current_branch, :to => params[:destination_branch] )
137
+
138
+ if pull_request.nil?
139
+ say "No pull request exists for #{GitReflow.current_branch} -> #{params[:destination_branch]}", :notice
140
+ say "Run 'git reflow review #{params[:destination_branch]}' to start the review process", :notice
141
+ else
142
+ say "Here's the status of your review:"
143
+ pull_request.display_pull_request_summary
144
+ end
145
+ end
146
+
147
+ command(:deploy) do |**params|
148
+ destination_server = params[:destination_server] || 'default'
149
+ deploy_command = GitReflow::Config.get("reflow.deploy-to-#{destination_server}-command", local: true)
150
+
151
+ # first check is to allow for automated setup
152
+ if deploy_command.empty?
153
+ deploy_command = ask("Enter the command you use to deploy to #{destination_server} (leaving blank will skip deployment)")
154
+ end
155
+
156
+ # second check is to see if the user wants to skip
157
+ if deploy_command.empty?
158
+ say "Skipping deployment..."
159
+ false
160
+ else
161
+ GitReflow::Config.set("reflow.deploy-to-#{destination_server}-command", deploy_command, local: true)
162
+ run_command_with_label(deploy_command, with_system: true)
163
+ end
164
+ end
165
+
166
+ # Merge and deploy a feature branch to a staging branch
167
+ command(:stage) do |**params|
168
+ feature_branch_name = GitReflow.current_branch
169
+ staging_branch_name = GitReflow::Config.get('reflow.staging-branch', local: true)
170
+
171
+ if staging_branch_name.empty?
172
+ staging_branch_name = GitReflow.ask("What's the name of your staging branch? (default: 'staging') ")
173
+ staging_branch_name = 'staging' if staging_branch_name.strip == ''
174
+ GitReflow::Config.set('reflow.staging-branch', staging_branch_name, local: true)
175
+ end
176
+
177
+ GitReflow.run_command_with_label "git checkout #{staging_branch_name}"
178
+ GitReflow.run_command_with_label "git pull origin #{staging_branch_name}"
179
+
180
+ if GitReflow.run_command_with_label "git merge #{feature_branch_name}", with_system: true
181
+ GitReflow.run_command_with_label "git push origin #{staging_branch_name}"
182
+
183
+ staged = self.deploy(destination_server: :staging)
184
+
185
+ if staged
186
+ GitReflow.say "Deployed to Staging.", :success
187
+ else
188
+ GitReflow.say "There were issues deploying to staging.", :error
189
+ end
190
+ else
191
+ GitReflow.say "There were issues merging your feature branch to staging.", :error
192
+ end
193
+ end
194
+
195
+ # Deliver a feature branch to a base branch
196
+ #
197
+ # @option base [String] base branch to merge your feature branch into
198
+ # @option force [Boolean] whether to force-deliver the feature branch, ignoring any QA checks
199
+ command(:deliver, defaults: {base: 'master'}) do |**params|
200
+ begin
201
+ existing_pull_request = GitReflow.git_server.find_open_pull_request( from: GitReflow.current_branch, to: params[:base] )
202
+
203
+ if existing_pull_request.nil?
204
+ say "No pull request exists for #{GitReflow.remote_user}:#{GitReflow.current_branch}\nPlease submit your branch for review first with \`git reflow review\`", :deliver_halted
205
+ else
206
+
207
+ if existing_pull_request.good_to_merge?(force: params[:force])
208
+ # displays current status and prompts user for confirmation
209
+ self.status destination_branch: params[:base]
210
+ # TODO: change name of this in the merge! method
211
+ params[:skip_lgtm] = params[:force] if params[:force]
212
+ existing_pull_request.merge!(params)
213
+ else
214
+ say existing_pull_request.rejection_message, :deliver_halted
215
+ end
216
+
217
+ end
218
+
219
+ rescue Github::Error::UnprocessableEntity => e
220
+ say "Github Error: #{e.inspect}", :error
221
+ end
222
+ end
223
+
224
+
225
+ # Updates and synchronizes your base branch and feature branch.
226
+ #
227
+ # Performs the following:
228
+ # $ git checkout <base_branch>
229
+ # $ git pull <remote_location> <base_branch>
230
+ # $ git checkout <current_branch>
231
+ # $ git pull origin <current_branch>
232
+ # $ git merge <base_branch>
233
+ # @param remote [String] the name of the remote repository to fetch updates from (origin by default)
234
+ # @param base [String] the branch that you want to fetch updates from (master by default)
235
+ command(:refresh, defaults: {remote: 'origin', base: 'master'}) do |**params|
236
+ GitReflow.update_feature_branch(params)
237
+ end
238
+ end
239
+ end
240
+ end