git_reflow 0.4.2 → 0.5.0

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: 56b9d1f62f165da2fa44742c87666802d88b484d
4
- data.tar.gz: df62b69368422f3fee100b6c0d95145321cd2215
3
+ metadata.gz: cb8b35b203f33dbcaa666927680ee42b0d0c1286
4
+ data.tar.gz: 7108e41d39cc19884abfb2adac608efee27a8e45
5
5
  SHA512:
6
- metadata.gz: c64744638a2767e4a3b24877a7b5dc61506715d6cb729665b91f3460c5731a1f918f84c6258e7c14b85e1830135a3b2f87318ae36c04122fa856914d63c3a50c
7
- data.tar.gz: b1f37dd0b8db8c3e554d643d0e94e3b39942ea0e7a081f1fe4f7beea0c105cc652478543ab1ba9da0d52b73044ccefd633b034d816b37c9db00deefa35db9140
6
+ metadata.gz: 3c4c04e3b8af67d57f0b0caf72358b7a535412dd00bae16fac1dcaed55d621de07d4344affdd7ff34616c7080219ad3dadac9c4254e294494dc5e00ff7c66ab6
7
+ data.tar.gz: 7a35d001f876dd3184470d5a536e01e2a8343d43c7d0b9cd0d612bdb2df158ca2475d7a174c0a0baf27f3d9a3401e740980a6640eff4388695dc5de87b49b286
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  pkg/*
2
2
  **/.DS_Store
3
3
  .rspec
4
+ gemfiles
data/Appraisals ADDED
@@ -0,0 +1,12 @@
1
+ appraise "latest-gli-release" do
2
+ gem "gli"
3
+ end
4
+
5
+ appraise "latest-github-api-release" do
6
+ gem "github_api"
7
+ end
8
+
9
+ appraise "current-reflow-locked-versions" do
10
+ gem "gli", "2.12.2"
11
+ gem "github_api", "0.12.3"
12
+ end
data/Gemfile CHANGED
@@ -1,2 +1,3 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
data/Gemfile.lock CHANGED
@@ -1,33 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.4.2)
4
+ git_reflow (0.5.0)
5
5
  colorize (= 0.6.0)
6
6
  github_api (= 0.12.3)
7
7
  gli (= 2.12.2)
8
8
  highline
9
9
  httpclient
10
10
  json_pure
11
+ reenhanced_bitbucket_api (= 0.3.2)
11
12
 
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- addressable (2.3.5)
16
- byebug (3.5.1)
17
- columnize (~> 0.8)
18
- debugger-linecache (~> 1.2)
19
- slop (~> 3.6)
16
+ addressable (2.3.7)
17
+ appraisal (1.0.3)
18
+ bundler
19
+ rake
20
+ thor (>= 0.14.0)
21
+ byebug (4.0.1)
22
+ columnize (= 0.9.0)
23
+ rb-readline (= 0.5.2)
20
24
  coderay (1.1.0)
21
25
  colorize (0.6.0)
22
- columnize (0.8.9)
26
+ columnize (0.9.0)
23
27
  crack (0.4.2)
24
28
  safe_yaml (~> 1.0.0)
25
- debugger-linecache (1.2.0)
26
29
  descendants_tracker (0.0.4)
27
30
  thread_safe (~> 0.3, >= 0.3.1)
28
31
  diff-lcs (1.2.5)
29
32
  faraday (0.9.1)
30
33
  multipart-post (>= 1.2, < 3)
34
+ faraday_middleware (0.9.1)
35
+ faraday (>= 0.7.4, < 0.10)
31
36
  github_api (0.12.3)
32
37
  addressable (~> 2.3)
33
38
  descendants_tracker (~> 0.0.4)
@@ -38,14 +43,13 @@ GEM
38
43
  oauth2
39
44
  gli (2.12.2)
40
45
  hashie (3.4.0)
41
- highline (1.6.21)
46
+ highline (1.7.1)
42
47
  httpclient (2.6.0.1)
43
- json (1.7.5)
44
48
  json_pure (1.8.2)
45
- jwt (1.2.1)
49
+ jwt (1.4.1)
46
50
  method_source (0.8.2)
47
51
  mini_portile (0.6.2)
48
- multi_json (1.10.1)
52
+ multi_json (1.11.0)
49
53
  multi_xml (0.5.5)
50
54
  multipart-post (2.0.0)
51
55
  nokogiri (1.6.6.2)
@@ -60,36 +64,47 @@ GEM
60
64
  coderay (~> 1.1.0)
61
65
  method_source (~> 0.8.1)
62
66
  slop (~> 3.4)
63
- pry-byebug (2.0.0)
64
- byebug (~> 3.4)
67
+ pry-byebug (3.1.0)
68
+ byebug (~> 4.0)
65
69
  pry (~> 0.10)
66
70
  rack (1.6.0)
67
- rake (0.9.2.2)
68
- rdoc (3.12)
69
- json (~> 1.4)
71
+ rake (10.4.2)
72
+ rb-readline (0.5.2)
73
+ rdoc (4.2.0)
74
+ reenhanced_bitbucket_api (0.3.2)
75
+ faraday (~> 0.9.0)
76
+ faraday_middleware (~> 0.9.0)
77
+ hashie (>= 3.2)
78
+ multi_json (>= 1.7.5, < 2.0)
79
+ nokogiri (>= 1.5.2)
80
+ simple_oauth (>= 0.3.0)
70
81
  rspec (3.0.0)
71
82
  rspec-core (~> 3.0.0)
72
83
  rspec-expectations (~> 3.0.0)
73
84
  rspec-mocks (~> 3.0.0)
74
- rspec-core (3.0.3)
85
+ rspec-core (3.0.4)
75
86
  rspec-support (~> 3.0.0)
76
- rspec-expectations (3.0.3)
87
+ rspec-expectations (3.0.4)
77
88
  diff-lcs (>= 1.2.0, < 2.0)
78
89
  rspec-support (~> 3.0.0)
79
- rspec-mocks (3.0.3)
90
+ rspec-mocks (3.0.4)
80
91
  rspec-support (~> 3.0.0)
81
- rspec-support (3.0.3)
82
- safe_yaml (1.0.1)
92
+ rspec-support (3.0.4)
93
+ safe_yaml (1.0.4)
94
+ simple_oauth (0.3.1)
83
95
  slop (3.6.0)
84
- thread_safe (0.3.4)
85
- webmock (1.17.4)
86
- addressable (>= 2.2.7)
96
+ thor (0.19.1)
97
+ thread_safe (0.3.5)
98
+ webmock (1.20.4)
99
+ addressable (>= 2.3.6)
87
100
  crack (>= 0.3.2)
101
+ wwtd (0.7.0)
88
102
 
89
103
  PLATFORMS
90
104
  ruby
91
105
 
92
106
  DEPENDENCIES
107
+ appraisal (= 1.0.3)
93
108
  bundler
94
109
  git_reflow!
95
110
  pry-byebug
@@ -97,3 +112,4 @@ DEPENDENCIES
97
112
  rdoc
98
113
  rspec (~> 3.0.0)
99
114
  webmock
115
+ wwtd (= 0.7.0)
data/README.rdoc CHANGED
@@ -1,8 +1,6 @@
1
- = git-reflow
2
-
3
- http://www.reenhanced.com/images/reflow.png
4
-
1
+ = git-reflow (2015 Fukuoka Ruby Award Winner)
5
2
 
3
+ http://reenhanced.com/reflow/git-reflow-deliver.gif
6
4
 
7
5
  If your workflow looks like this:
8
6
  1. Create a feature branch
@@ -14,6 +12,8 @@ If your workflow looks like this:
14
12
 
15
13
  Reflow will make your life easier.
16
14
 
15
+ Reflow automatically creates pull requests, ensures the code review is approved, and squash merges finished branches to master with a great commit message template.
16
+
17
17
  == Quickstart
18
18
  Create and switch to new branch +nh-branchy-branch+:
19
19
  $ git reflow start nh-branchy-branch
@@ -85,6 +85,8 @@ Then for your Enterprise projects, you have to setup GitReflow for each one:
85
85
  git reflow setup --enterprise --local
86
86
 
87
87
  === Starting a feature branch
88
+ http://reenhanced.com/reflow/git-reflow-start.gif
89
+
88
90
  git reflow start
89
91
 
90
92
  This sets up a feature branch remotely and brings a local copy to your machine. Yeah, you can do this by hand pretty easily, so skip this command if you want. This is just a handy shortcut with no magic.
@@ -95,6 +97,8 @@ This sets up a feature branch remotely and brings a local copy to your machine.
95
97
  who is responsible for each. My initials are 'NH', so all of my branches start with +nh-+
96
98
 
97
99
  === Reviewing your work
100
+ http://reenhanced.com/reflow/git-reflow-review.gif
101
+
98
102
  git reflow review
99
103
 
100
104
  All of our work is reviewed by our team. This helps spread knowledge to multiple parties and keeps the quality of our code consistent.
@@ -139,6 +143,8 @@ Do we have pull request?
139
143
  If not, create it and print "Pull request created at http://pull-url/". If so, print the url for the existing request.
140
144
 
141
145
  === Checking your branch status
146
+ http://reenhanced.com/reflow/git-reflow-status.gif
147
+
142
148
  git reflow status
143
149
 
144
150
  Sometimes you start working on a branch and can't get back to it for a while. It happens. Use +status+ to check on the status of your work.
@@ -158,6 +164,8 @@ This gives you details on who's reviewed your pull request. If someone has parti
158
164
  +status+ prevents you from having to open a browser to find out where your pull request is at. But in case you want to take a look, we give you the option to open it for you.
159
165
 
160
166
  === Delivering approved code
167
+ http://reenhanced.com/reflow/git-reflow-deliver.gif
168
+
161
169
  git reflow deliver
162
170
 
163
171
  You kick butt. You've got your code reviewed and now you're ready to merge it down to +master+ and deploy. Reflow +deliver+ will take care of all of the steps for you to make this happen.
@@ -258,8 +266,10 @@ If 'n', then just stop here. The user can reset his local +master+.
258
266
 
259
267
  And we're done.
260
268
 
261
-
262
269
  == Guiding principles:
270
+ * Your workflow should resemble the following:
271
+ http://reenhanced.com/images/reflow.png
272
+
263
273
  * You should already know what you're doing.
264
274
  We assume you know how to use git.
265
275
 
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'rake'
3
3
  require 'bundler/gem_tasks'
4
+ require 'bundler/setup'
4
5
  require 'rspec/core/rake_task'
5
-
6
+
6
7
  Dir[File.join(File.dirname(__FILE__),'lib/tasks/*.rake')].each { |f| load f }
7
8
 
8
9
  RSpec::Core::RakeTask.new(:spec)
9
-
10
+
10
11
  task :default => [:spec]
data/circle.yml ADDED
@@ -0,0 +1,16 @@
1
+ dependencies:
2
+ pre:
3
+ - rvm install 2.0.0
4
+ - rvm install 2.1.5
5
+ - rvm install 2.2.1
6
+
7
+ override:
8
+ - 'rvm-exec 2.0.0-p643 bundle install'
9
+ - 'rvm-exec 2.1.5 bundle install'
10
+ - 'rvm-exec 2.2.1 bundle install'
11
+
12
+ test:
13
+ override:
14
+ - 'rvm-exec 2.0.0-p643 bundle exec rake'
15
+ - 'rvm-exec 2.1.5 bundle exec rake'
16
+ - 'rvm-exec 2.2.1 bundle exec rake'
data/git_reflow.gemspec CHANGED
@@ -19,12 +19,14 @@ spec = Gem::Specification.new do |s|
19
19
  s.require_paths << 'lib'
20
20
  s.rdoc_options << '--title' << 'git_reflow' << '--main' << 'README.rdoc' << '-ri'
21
21
 
22
+ s.add_development_dependency('appraisal', '1.0.3')
22
23
  s.add_development_dependency('bundler')
23
24
  s.add_development_dependency('pry-byebug')
24
25
  s.add_development_dependency('rake')
25
26
  s.add_development_dependency('rdoc')
26
27
  s.add_development_dependency('rspec', '~> 3.0.0')
27
28
  s.add_development_dependency('webmock')
29
+ s.add_development_dependency('wwtd', '0.7.0')
28
30
 
29
31
  s.add_dependency('colorize', '0.6.0')
30
32
  s.add_dependency('gli', '2.12.2')
@@ -32,6 +34,7 @@ spec = Gem::Specification.new do |s|
32
34
  s.add_dependency('httpclient')
33
35
  s.add_dependency('json_pure')
34
36
  s.add_dependency('github_api', '0.12.3')
37
+ s.add_dependency('reenhanced_bitbucket_api', '0.3.2')
35
38
 
36
39
  s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
37
40
  end
data/lib/git_reflow.rb CHANGED
@@ -10,6 +10,7 @@ require 'git_reflow/version.rb' unless defined?(GitReflow::VERSION)
10
10
  require 'git_reflow/config'
11
11
  require 'git_reflow/git_server'
12
12
  require 'git_reflow/git_server/git_hub'
13
+ require 'git_reflow/git_server/bit_bucket'
13
14
  require 'git_reflow/sandbox'
14
15
  require 'git_reflow/git_helpers'
15
16
 
@@ -22,7 +23,7 @@ module GitReflow
22
23
  LGTM = /lgtm|looks good to me|:\+1:|:thumbsup:|:shipit:/i
23
24
 
24
25
  def status(destination_branch)
25
- pull_request = git_server.find_pull_request( :from => current_branch, :to => destination_branch )
26
+ pull_request = git_server.find_open_pull_request( :from => current_branch, :to => destination_branch )
26
27
 
27
28
  if pull_request.nil?
28
29
  puts "\n[notice] No pull request exists for #{current_branch} -> #{destination_branch}"
@@ -41,7 +42,8 @@ module GitReflow
41
42
  begin
42
43
  push_current_branch
43
44
 
44
- if existing_pull_request = git_server.find_pull_request( from: current_branch, to: options['base'] )
45
+ existing_pull_request = git_server.find_open_pull_request( from: current_branch, to: options['base'] )
46
+ if existing_pull_request
45
47
  puts "A pull request already exists for these branches:"
46
48
  display_pull_request_summary(existing_pull_request)
47
49
  ask_to_open_in_browser(existing_pull_request.html_url)
@@ -57,7 +59,7 @@ module GitReflow
57
59
  rescue Github::Error::UnprocessableEntity => e
58
60
  puts "Github Error: #{e.to_s}"
59
61
  rescue StandardError => e
60
- puts "Error: #{e.inspect}"
62
+ puts "\nError: #{e.inspect}"
61
63
  end
62
64
  end
63
65
 
@@ -69,32 +71,34 @@ module GitReflow
69
71
  update_destination(current_branch)
70
72
 
71
73
  begin
72
- existing_pull_request = git_server.find_pull_request( :from => current_branch, :to => options['base'] )
74
+ existing_pull_request = git_server.find_open_pull_request( :from => current_branch, :to => options['base'] )
73
75
 
74
76
  if existing_pull_request.nil?
75
- puts "Error: No pull request exists for #{remote_user}:#{current_branch}\nPlease submit your branch for review first with \`git reflow review\`"
77
+ say "No pull request exists for #{remote_user}:#{current_branch}\nPlease submit your branch for review first with \`git reflow review\`", :deliver_halted
76
78
  else
77
79
 
78
- open_comment_authors = git_server.find_authors_of_open_pull_request_comments(existing_pull_request)
79
80
  has_comments = git_server.has_pull_request_comments?(existing_pull_request)
80
- status = git_server.get_build_status existing_pull_request.head.sha
81
+ open_comment_authors = git_server.reviewers_pending_response(existing_pull_request)
82
+ status = git_server.get_build_status existing_pull_request.build_status
83
+ commit_message = if "#{existing_pull_request.description}".length > 0
84
+ existing_pull_request.description
85
+ else
86
+ "#{get_first_commit_message}"
87
+ end
81
88
 
82
- # if there any comment_authors left, then they haven't given a lgtm after the last commit
83
- if ((status.nil? or status.state == "success") and has_comments and open_comment_authors.empty?) or options['skip_lgtm']
84
- lgtm_authors = git_server.comment_authors_for_pull_request(existing_pull_request, :with => LGTM)
85
- commit_message = ("#{existing_pull_request[:body]}".length > 0) ? existing_pull_request[:body] : "#{get_first_commit_message}"
86
- puts "Merging pull request ##{existing_pull_request.number}: '#{existing_pull_request.title}', from '#{existing_pull_request.head.label}' into '#{existing_pull_request.base.label}'"
89
+ if options['skip_lgtm'] or ((status.nil? or status.state == "success") and (has_comments and open_comment_authors.empty?))
90
+ puts "Merging pull request ##{existing_pull_request.number}: '#{existing_pull_request.title}', from '#{existing_pull_request.feature_branch_name}' into '#{existing_pull_request.base_branch_name}'"
87
91
 
88
92
  update_destination(options['base'])
89
93
  merge_feature_branch(feature_branch,
90
94
  :destination_branch => options['base'],
91
95
  :pull_request_number => existing_pull_request.number,
92
- :lgtm_authors => lgtm_authors,
96
+ :lgtm_authors => git_server.approvals(existing_pull_request),
93
97
  :message => commit_message)
94
98
  committed = run_command_with_label 'git commit', with_system: true
95
99
 
96
100
  if committed
97
- puts "Merge complete!"
101
+ say "Merge complete!", :success
98
102
  deploy_and_cleanup = ask "Would you like to push this branch to your remote repo and cleanup your feature branch? "
99
103
  if deploy_and_cleanup =~ /^y/i
100
104
  run_command_with_label "git push origin #{options['base']}"
@@ -102,18 +106,18 @@ module GitReflow
102
106
  run_command_with_label "git branch -D #{feature_branch}"
103
107
  puts "Nice job buddy."
104
108
  else
105
- puts "Cleanup haulted. Local changes were not pushed to remote repo.".colorize(:red)
109
+ puts "Cleanup halted. Local changes were not pushed to remote repo.".colorize(:red)
106
110
  puts "To reset and go back to your branch run \`git reset --hard origin/master && git checkout new-feature\`"
107
111
  end
108
112
  else
109
- puts "There were problems commiting your feature... please check the errors above and try again."
113
+ say "There were problems commiting your feature... please check the errors above and try again.", :error
110
114
  end
111
115
  elsif !status.nil? and status.state != "success"
112
- puts "[#{ 'deliver halted'.colorize(:red) }] #{status.description}: #{status.target_url}"
116
+ say "#{status.description}: #{status.target_url}", :deliver_halted
113
117
  elsif open_comment_authors.count > 0
114
- puts "[deliver halted] You still need a LGTM from: #{open_comment_authors.join(', ')}"
118
+ say "You still need a LGTM from: #{open_comment_authors.join(', ')}", :deliver_halted
115
119
  else
116
- puts "[deliver halted] Your code has not been reviewed yet."
120
+ say "Your code has not been reviewed yet.", :deliver_halted
117
121
  end
118
122
  end
119
123
 
@@ -125,40 +129,39 @@ module GitReflow
125
129
  end
126
130
 
127
131
  def git_server
128
- @git_server ||= GitServer.connect provider: 'GitHub', silent: true
132
+ @git_server ||= GitServer.connect provider: GitReflow::Config.get('reflow.git-server').strip, silent: true
129
133
  end
130
134
 
131
135
  def display_pull_request_summary(pull_request)
132
136
  summary_data = {
133
- "branches" => "#{pull_request.head.label} -> #{pull_request.base.label}",
137
+ "branches" => "#{pull_request.feature_branch_name} -> #{pull_request.base_branch_name}",
134
138
  "number" => pull_request.number,
135
139
  "url" => pull_request.html_url
136
140
  }
137
141
 
138
142
  notices = ""
139
- reviewed_by = git_server.comment_authors_for_pull_request(pull_request).map {|author| author.colorize(:red) }
143
+ reviewed_by = git_server.reviewers(pull_request).map {|author| author.colorize(:red) }
140
144
 
141
145
  # check for CI build status
142
- status = git_server.get_build_status pull_request.head.sha
146
+ status = git_server.get_build_status pull_request.build_status
143
147
  if status
144
148
  notices << "[notice] Your build status is not successful: #{status.target_url}.\n" unless status.state == "success"
145
149
  summary_data.merge!( "Build status" => git_server.colorized_build_description(status) )
146
150
  end
147
151
 
148
152
  # check for needed lgtm's
149
- pull_comments = git_server.pull_request_comments(pull_request)
150
- if pull_comments.reject {|comment| comment.user.login == git_server.class.user}.any?
151
- open_comment_authors = git_server.find_authors_of_open_pull_request_comments(pull_request)
152
- last_committed_at = git_server.get_commited_time(pull_request.head.sha)
153
- lgtm_authors = git_server.comment_authors_for_pull_request(pull_request, :with => LGTM, :after => last_committed_at)
153
+ if git_server.reviewers(pull_request).any?
154
+ approvals = git_server.approvals(pull_request)
155
+ pending = git_server.reviewers_pending_response(pull_request)
156
+ last_comment = git_server.last_comment_for_pull_request(pull_request)
154
157
 
155
- summary_data.merge!("Last comment" => pull_comments.last[:body].inspect)
158
+ summary_data.merge!("Last comment" => last_comment)
156
159
 
157
- if lgtm_authors.any?
158
- reviewed_by.map! { |author| lgtm_authors.include?(author.uncolorize) ? author.colorize(:green) : author }
160
+ if approvals.any?
161
+ reviewed_by.map! { |author| approvals.include?(author.uncolorize) ? author.colorize(:green) : author }
159
162
  end
160
163
 
161
- notices << "[notice] You still need a LGTM from: #{open_comment_authors.join(', ')}\n" if open_comment_authors.any?
164
+ notices << "[notice] You still need a LGTM from: #{pending.join(', ')}\n" if pending.any?
162
165
  else
163
166
  notices << "[notice] No one has reviewed your pull request.\n"
164
167
  end
@@ -10,7 +10,7 @@ command :setup do |c|
10
10
  menu.prompt = "Which service would you like to use for this project? "
11
11
 
12
12
  menu.choice('GitHub') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'GitHub', silent: false }) }
13
- menu.choice('BitBucket') { say("Coming soon...") }
13
+ menu.choice('BitBucket (team-owned repos only)') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'BitBucket', silent: false }) }
14
14
  end
15
15
  end
16
16
  end