thegarage-gitx 2.2.3 → 2.3.0.pre1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccffa73969aa2bc6ae79fec560b1aadec0274e61
4
- data.tar.gz: 02b8b2fd2557ad910010e3933422c28e61d6901c
3
+ metadata.gz: f40f446859a3964035cde6606580ad207ceee9c5
4
+ data.tar.gz: 56f224ffe1dd7fde762fa726ed9a3a5f166f1679
5
5
  SHA512:
6
- metadata.gz: 9f1c773b6c2c5494efb28363523c22b21651fcecc0ab78c0fd90baa0833cb67330c64b07030a437849f1c82819704d9bc6ac5e9a6d9bbf77afd068d000ece92a
7
- data.tar.gz: 59d5c07db179d13f38c774be57a1bd41a8e385c6f6724cebe270f21cab6dda639952a22e23a53ee16e4392a3e6a959461fec970e736cdc7698bc1064eb8b4586
6
+ metadata.gz: 9f77fe954ce841e57c90b0d4ff8403363e2f940c9bbb80af5205186f3924242b30195f50aa30a8710843ea035c2713b8b0e798ce09db22dda81ec0b1a975fae5
7
+ data.tar.gz: 415cb3c76b07da640e028275b07eacb857e11cbbaab02cac28ef78e9c52b63e9585012e4513a64b1d54de629335225d7368685c14ea52a27c6dcc0f39b1ed676
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --warnings
3
2
  --require spec_helper
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard :rspec, cmd: 'rspec' do
4
+ guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { "spec" }
@@ -10,8 +10,7 @@ module Thegarage
10
10
  desc 'integrate', 'integrate the current branch into one of the aggregate development branches (default = staging)'
11
11
  def integrate(target_branch = 'staging')
12
12
  branch = current_branch.name
13
- assert_not_protected_branch!(branch, 'integrate') unless aggregate_branch?(target_branch)
14
- raise "Only aggregate branches are allowed for integration: #{AGGREGATE_BRANCHES}" unless aggregate_branch?(target_branch) || target_branch == Thegarage::Gitx::BASE_BRANCH
13
+ assert_integratable_branch!(branch, target_branch)
15
14
 
16
15
  UpdateCommand.new.update
17
16
 
@@ -28,6 +27,11 @@ module Thegarage
28
27
 
29
28
  private
30
29
 
30
+ def assert_integratable_branch!(branch, target_branch)
31
+ assert_not_protected_branch!(branch, 'integrate') unless aggregate_branch?(target_branch)
32
+ raise "Only aggregate branches are allowed for integration: #{AGGREGATE_BRANCHES}" unless aggregate_branch?(target_branch) || target_branch == Thegarage::Gitx::BASE_BRANCH
33
+ end
34
+
31
35
  # nuke local branch and pull fresh version from remote repo
32
36
  def refresh_branch_from_remote(target_branch)
33
37
  run_cmd "git branch -D #{target_branch}", :allow_failure => true
@@ -22,6 +22,7 @@ module Thegarage
22
22
  method_option :description, :type => :string, :aliases => '-d', :desc => 'pull request description'
23
23
  method_option :assignee, :type => :string, :aliases => '-a', :desc => 'pull request assignee'
24
24
  method_option :open, :type => :boolean, :aliases => '-o', :desc => 'open the pull request in a web browser'
25
+ method_option :bump, :type => :boolean, :aliases => '-b', :desc => 'bump an existing review with a github comment to re-request review'
25
26
  # @see http://developer.github.com/v3/pulls/
26
27
  def review
27
28
  fail 'Github authorization token not found' unless authorization_token
@@ -37,14 +38,17 @@ module Thegarage
37
38
 
38
39
  def find_or_create_pull_request(branch)
39
40
  pull_request = find_pull_request(branch)
40
- return pull_request if pull_request
41
-
42
- UpdateCommand.new.update
43
- pull_request = create_pull_request(branch)
44
- say 'Pull request created: '
45
- say pull_request.html_url, :green
46
-
47
- pull_request
41
+ if pull_request
42
+ create_bump_comment(pull_request) if options[:bump]
43
+ pull_request
44
+ else
45
+ UpdateCommand.new.update
46
+ pull_request = create_pull_request(branch)
47
+ say 'Pull request created: '
48
+ say pull_request.html_url, :green
49
+
50
+ pull_request
51
+ end
48
52
  end
49
53
 
50
54
  # token is cached in local git config for future use
@@ -70,7 +74,7 @@ module Thegarage
70
74
 
71
75
  def authorization_request_options
72
76
  timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S%z')
73
- client_name = "The Garage Git eXtensions - #{remote_origin_name} #{timestamp}"
77
+ client_name = "The Garage Git eXtensions - #{github_slug} #{timestamp}"
74
78
  options = {
75
79
  :scopes => ['repo'],
76
80
  :note => client_name,
@@ -89,12 +93,11 @@ module Thegarage
89
93
  say "against "
90
94
  say "#{Thegarage::Gitx::BASE_BRANCH} ", :green
91
95
  say "in "
92
- say remote_origin_name, :green
96
+ say github_slug, :green
93
97
 
94
- client = Octokit::Client.new(:access_token => authorization_token)
95
98
  title = branch
96
99
  body = pull_request_body(branch)
97
- client.create_pull_request(remote_origin_name, Thegarage::Gitx::BASE_BRANCH, branch, title, body)
100
+ github_client.create_pull_request(github_slug, Thegarage::Gitx::BASE_BRANCH, branch, title, body)
98
101
  end
99
102
 
100
103
  def assign_pull_request(pull_request)
@@ -102,28 +105,41 @@ module Thegarage
102
105
  say "Assigning pull request to "
103
106
  say assignee, :green
104
107
 
105
- client = Octokit::Client.new(:access_token => authorization_token)
106
108
  title = pull_request.title
107
109
  body = pull_request.body
108
110
  options = {
109
111
  assignee: assignee
110
112
  }
111
- client.update_issue(remote_origin_name, pull_request.number, title, body, options)
113
+ github_client.update_issue(github_slug, pull_request.number, title, body, options)
112
114
  end
113
115
 
114
116
  # @return [Sawyer::Resource] data structure of pull request info if found
115
117
  # @return nil if no pull request found
116
118
  def find_pull_request(branch)
117
- head_reference = "#{repo_organization_name}:#{branch}"
119
+ head_reference = "#{github_organization}:#{branch}"
118
120
  params = {
119
121
  head: head_reference,
120
122
  state: 'open'
121
123
  }
122
- client = Octokit::Client.new(:access_token => authorization_token)
123
- pull_requests = client.pull_requests(remote_origin_name, params)
124
+ pull_requests = github_client.pull_requests(github_slug, params)
124
125
  pull_requests.first
125
126
  end
126
127
 
128
+ def create_bump_comment(pull_request)
129
+ comment_template = []
130
+ comment_template << '[gitx] review bump :tada:'
131
+ comment_template << ''
132
+ comment_template << '### Summary of Changes'
133
+
134
+ comment = ask_editor(comment_template.join("\n"), repo.config['core.editor'])
135
+ comment = comment.chomp.strip
136
+ github_client.add_comment(github_slug, pull_request.number, comment)
137
+ end
138
+
139
+ def github_client
140
+ @client ||= Octokit::Client.new(:access_token => authorization_token)
141
+ end
142
+
127
143
  # @return [String] github username (ex: 'wireframe') of the current github.user
128
144
  # @raise error if github.user is not configured
129
145
  def username
@@ -132,15 +148,18 @@ module Thegarage
132
148
  username
133
149
  end
134
150
 
135
- # lookup the current repository of the PWD
136
- # ex: git@github.com:socialcast/thegarage/gitx.git OR https://github.com/socialcast/thegarage/gitx.git
137
- def remote_origin_name
151
+ # @return the github slug for the current repository's remote origin url.
152
+ # @example
153
+ # git@github.com:socialcast/thegarage/gitx.git #=> thegarage/gitx
154
+ # @example
155
+ # https://github.com/socialcast/thegarage/gitx.git #=> thegarage/gitx
156
+ def github_slug
138
157
  remote = repo.config['remote.origin.url']
139
158
  remote.to_s.gsub(/\.git$/,'').split(/[:\/]/).last(2).join('/')
140
159
  end
141
160
 
142
- def repo_organization_name
143
- remote_origin_name.split('/').first
161
+ def github_organization
162
+ github_slug.split('/').first
144
163
  end
145
164
 
146
165
  def pull_request_body(branch)
@@ -153,7 +172,7 @@ module Thegarage
153
172
  description_template << changelog
154
173
  description_template << PULL_REQUEST_FOOTER
155
174
 
156
- body = ask_editor(description_template.join("\n"))
175
+ body = ask_editor(description_template.join("\n"), repo.config['core.editor'])
157
176
  body.gsub(PULL_REQUEST_FOOTER, '').chomp.strip
158
177
  end
159
178
  end
@@ -4,12 +4,12 @@ class Thor
4
4
  # see http://osdir.com/ml/ruby-talk/2010-06/msg01424.html
5
5
  # see https://gist.github.com/rkumar/456809
6
6
  # see http://rdoc.info/github/visionmedia/commander/master/Commander/UI.ask_editor
7
- def ask_editor(initial_text = '')
7
+ def ask_editor(initial_text = '', editor = nil)
8
+ editor ||= ENV['EDITOR'] || 'vi'
8
9
  Tempfile.open('reviewrequest.md') do |f|
9
10
  f << initial_text
10
11
  f.flush
11
12
 
12
- editor = repo.config['core.editor'] || ENV['EDITOR'] || 'vi'
13
13
  flags = case editor
14
14
  when 'mate', 'emacs', 'subl'
15
15
  '-w'
@@ -1,5 +1,5 @@
1
1
  module Thegarage
2
2
  module Gitx
3
- VERSION = '2.2.3'
3
+ VERSION = '2.3.0.pre1'
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -44,7 +44,7 @@ RSpec.configure do |config|
44
44
  # Print the 10 slowest examples and example groups at the
45
45
  # end of the spec run, to help surface which specs are running
46
46
  # particularly slow.
47
- config.profile_examples = 10
47
+ # config.profile_examples = 10
48
48
 
49
49
  # Run specs in random order to surface order dependencies. If you find an
50
50
  # order dependency and want to debug it, you can fix the order by providing
@@ -1,7 +1,20 @@
1
1
  # protip to prevent execution of shell commands during testsuite
2
2
  # see http://stackoverflow.com/questions/1628586/mock-system-call-in-ruby
3
- module Kernel
4
- def `(cmd)
5
- puts "stubbing execution within tests of command: #{cmd}"
3
+ module ShellExecutionStub
4
+ def included(base)
5
+ base.class_eval do
6
+ alias_method :execute_without_stub, :`
7
+ alias_method :`, :execute_with_stub
8
+ end
9
+ end
10
+
11
+ def execute_with_stub(cmd)
12
+ if cmd.include?('git')
13
+ puts "WARNING: stubbing command execution within tests of command: #{cmd}", :red
14
+ else
15
+ execute_without_stub(cmd)
16
+ end
6
17
  end
7
18
  end
19
+
20
+ Kernel.send(:include, ShellExecutionStub)
@@ -88,7 +88,7 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
88
88
  before do
89
89
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
90
90
 
91
- stub_request(:patch, 'https://api.github.com/repos/thegarage/thegarage-gitx/issues/10').to_return(:status => 200)
91
+ stub_request(:patch, /.*api.github.com.*/).to_return(:status => 200)
92
92
 
93
93
  VCR.use_cassette('pull_request_does_exist') do
94
94
  cli.review
@@ -116,6 +116,26 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
116
116
  should meet_expectations
117
117
  end
118
118
  end
119
+ context 'when --bump flag is passed' do
120
+ let(:options) do
121
+ {
122
+ bump: true
123
+ }
124
+ end
125
+ let(:authorization_token) { '123123' }
126
+ before do
127
+ allow(cli).to receive(:authorization_token).and_return(authorization_token)
128
+ expect(cli).to receive(:ask_editor).and_return('comment description')
129
+ stub_request(:post, /.*api.github.com.*/).to_return(:status => 201)
130
+
131
+ VCR.use_cassette('pull_request_does_exist') do
132
+ cli.review
133
+ end
134
+ end
135
+ it 'posts comment to github' do
136
+ expect(WebMock).to have_requested(:post, "https://api.github.com/repos/thegarage/thegarage-gitx/issues/10/comments")
137
+ end
138
+ end
119
139
  end
120
140
 
121
141
  describe '#authorization_token' do
@@ -32,4 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "guard"
33
33
  spec.add_development_dependency "guard-rspec"
34
34
  spec.add_development_dependency "coveralls"
35
+ spec.add_development_dependency 'terminal-notifier'
36
+ spec.add_development_dependency 'terminal-notifier-guard'
35
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thegarage-gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.3.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-05 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -192,6 +192,34 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: terminal-notifier
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: terminal-notifier-guard
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
195
223
  description: Git eXtensions for common development workflow
196
224
  email:
197
225
  - ryan.sonnek@gmail.com
@@ -281,9 +309,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
309
  version: '0'
282
310
  required_rubygems_version: !ruby/object:Gem::Requirement
283
311
  requirements:
284
- - - ">="
312
+ - - ">"
285
313
  - !ruby/object:Gem::Version
286
- version: '0'
314
+ version: 1.3.1
287
315
  requirements: []
288
316
  rubyforge_project:
289
317
  rubygems_version: 2.2.2