thegarage-gitx 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -1
- data/lib/thegarage/gitx/cli/review_command.rb +11 -19
- data/lib/thegarage/gitx/version.rb +1 -1
- data/spec/spec_helper.rb +66 -6
- data/spec/support/{meet_expectations_matcher.rb → matchers/meet_expectations_matcher.rb} +1 -1
- data/spec/support/pry.rb +1 -0
- data/spec/support/timecop.rb +9 -0
- data/spec/support/webmock.rb +1 -0
- data/spec/thegarage/gitx/cli/review_command_spec.rb +35 -13
- data/thegarage-gitx.gemspec +4 -3
- metadata +30 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba83717e3ca477e8d78381ab9dd58802d78944b1
|
4
|
+
data.tar.gz: dab659256d11dcfc92ea739e89dfa89a19659779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec1f688077ea72a712997fb19238ec93ebfb0f1f69ed2690dbcee08a5105e7c3a52d0febb1b63fb4055272670dfe98644a252e2dcd75754b4adb77ea1f3ea98
|
7
|
+
data.tar.gz: 0be38d52627ff9b5f29146dfdbba90c30065a0bff09cb4034dd39414f2147f72c6127f86e20f17596623f3a12b915dd4a2d1ee9ecb3247d658716656d54bca38
|
data/.rspec
CHANGED
@@ -4,6 +4,7 @@ require 'thegarage/gitx/cli/base_command'
|
|
4
4
|
require 'thegarage/gitx/cli/update_command'
|
5
5
|
require 'json'
|
6
6
|
require 'rest_client'
|
7
|
+
require 'octokit'
|
7
8
|
|
8
9
|
module Thegarage
|
9
10
|
module Gitx
|
@@ -56,31 +57,22 @@ module Thegarage
|
|
56
57
|
|
57
58
|
fail "Github user not configured. Run: `git config --global github.user 'me@email.com'`" unless username
|
58
59
|
password = ask("Github password for #{username}: ", :echo => false)
|
60
|
+
say ''
|
61
|
+
two_factor_auth_token = ask("Github two factor authorization token (if enabled): ", :echo => false)
|
59
62
|
|
60
|
-
|
61
|
-
|
63
|
+
timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S%z')
|
64
|
+
client_name = "The Garage Git eXtensions - #{remote_origin_name} #{timestamp}"
|
65
|
+
options = {
|
62
66
|
:scopes => ['repo'],
|
63
67
|
:note => client_name,
|
64
68
|
:note_url => CLIENT_URL
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
:password => password,
|
71
|
-
:payload => payload,
|
72
|
-
:headers => {
|
73
|
-
:accept => :json,
|
74
|
-
:content_type => :json,
|
75
|
-
:user_agent => 'thegarage/gitx'
|
76
|
-
}
|
77
|
-
}).execute
|
78
|
-
data = JSON.parse response.body
|
79
|
-
token = data['token']
|
69
|
+
}
|
70
|
+
options[:headers] = {'X-GitHub-OTP' => two_factor_auth_token} if two_factor_auth_token
|
71
|
+
client = Octokit::Client.new(login: username, password: password)
|
72
|
+
response = client.create_authorization(options)
|
73
|
+
token = response.token
|
80
74
|
repo.config['thegarage.gitx.githubauthtoken'] = token
|
81
75
|
token
|
82
|
-
rescue RestClient::Exception => e
|
83
|
-
process_error e
|
84
76
|
end
|
85
77
|
|
86
78
|
# @see http://developer.github.com/v3/pulls/
|
data/spec/spec_helper.rb
CHANGED
@@ -2,22 +2,82 @@ require 'coveralls'
|
|
2
2
|
Coveralls.wear!
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler/setup'
|
5
|
-
require 'pry'
|
6
|
-
require 'webmock/rspec'
|
7
|
-
require 'timecop'
|
8
5
|
|
9
6
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
10
7
|
# in spec/support/ and its subdirectories.
|
11
8
|
Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f }
|
12
9
|
|
10
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
11
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
12
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
13
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
14
|
+
#
|
15
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
16
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
17
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
18
|
+
# individual file that may not need all of that loaded. Instead, make a
|
19
|
+
# separate helper file that requires this one and then use it only in the specs
|
20
|
+
# that actually need it.
|
21
|
+
#
|
22
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
23
|
+
# users commonly want.
|
24
|
+
#
|
25
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
13
26
|
RSpec.configure do |config|
|
14
|
-
|
15
|
-
|
27
|
+
# These two settings work together to allow you to limit a spec run
|
28
|
+
# to individual examples or groups you care about by tagging them with
|
29
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
30
|
+
# get run.
|
16
31
|
config.filter_run :focus
|
32
|
+
config.run_all_when_everything_filtered = true
|
33
|
+
|
34
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
35
|
+
# file, and it's useful to allow more verbose output when running an
|
36
|
+
# individual spec file.
|
37
|
+
if config.files_to_run.one?
|
38
|
+
# Use the documentation formatter for detailed output,
|
39
|
+
# unless a formatter has already been configured
|
40
|
+
# (e.g. via a command-line flag).
|
41
|
+
config.default_formatter = 'doc'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Print the 10 slowest examples and example groups at the
|
45
|
+
# end of the spec run, to help surface which specs are running
|
46
|
+
# particularly slow.
|
47
|
+
config.profile_examples = 10
|
17
48
|
|
18
49
|
# Run specs in random order to surface order dependencies. If you find an
|
19
50
|
# order dependency and want to debug it, you can fix the order by providing
|
20
51
|
# the seed, which is printed after each run.
|
21
52
|
# --seed 1234
|
22
|
-
config.order =
|
53
|
+
config.order = :random
|
54
|
+
|
55
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
56
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
57
|
+
# test failures related to randomization by passing the same `--seed` value
|
58
|
+
# as the one that triggered the failure.
|
59
|
+
Kernel.srand config.seed
|
60
|
+
|
61
|
+
# rspec-expectations config goes here. You can use an alternate
|
62
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
63
|
+
# assertions if you prefer.
|
64
|
+
config.expect_with :rspec do |expectations|
|
65
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
66
|
+
# For more details, see:
|
67
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
68
|
+
expectations.syntax = :expect
|
69
|
+
end
|
70
|
+
|
71
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
72
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
73
|
+
config.mock_with :rspec do |mocks|
|
74
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
75
|
+
# For more details, see:
|
76
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
77
|
+
mocks.syntax = :expect
|
78
|
+
|
79
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
80
|
+
# a real object. This is generally recommended.
|
81
|
+
mocks.verify_partial_doubles = true
|
82
|
+
end
|
23
83
|
end
|
data/spec/support/pry.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'pry'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'webmock/rspec'
|
@@ -27,6 +27,7 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
|
|
27
27
|
let(:pull_request) do
|
28
28
|
{
|
29
29
|
'html_url' => 'https://path/to/new/pull/request',
|
30
|
+
'issue_url' => 'https://api/path/to/new/pull/request',
|
30
31
|
'head' => {
|
31
32
|
'ref' => 'branch_name'
|
32
33
|
}
|
@@ -80,14 +81,17 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
|
|
80
81
|
end
|
81
82
|
let(:authorization_token) { '123123' }
|
82
83
|
before do
|
83
|
-
expect(cli).to receive(:authorization_token).and_return(authorization_token)
|
84
|
+
expect(cli).to receive(:authorization_token).and_return(authorization_token).at_least(:once)
|
84
85
|
expect(cli).to receive(:find_pull_request).and_return(pull_request)
|
85
|
-
|
86
|
+
|
87
|
+
stub_request(:patch, 'https://api/path/to/new/pull/request').to_return(:status => 200)
|
86
88
|
|
87
89
|
cli.review
|
88
90
|
end
|
89
|
-
it '
|
90
|
-
|
91
|
+
it 'updates github pull request' do
|
92
|
+
expect(WebMock).to have_requested(:patch, "https://api/path/to/new/pull/request").
|
93
|
+
with(:body => {title: 'branch_name', assignee: 'johndoe'}.to_json,
|
94
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'token 123123', 'Content-Type'=>'application/json'})
|
91
95
|
end
|
92
96
|
end
|
93
97
|
context 'when --open flag passed' do
|
@@ -126,19 +130,12 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
|
|
126
130
|
end
|
127
131
|
let(:github_password) { 'secretz' }
|
128
132
|
let(:authorization_token) { '123981239123' }
|
129
|
-
let(:expected_auth_body) do
|
130
|
-
JSON.dump({
|
131
|
-
scopes: ["repo"],
|
132
|
-
note: "The Garage Git eXtensions - thegarage/thegarage-gitx",
|
133
|
-
note_url: "https://github.com/thegarage/thegarage-gitx"
|
134
|
-
})
|
135
|
-
end
|
136
133
|
before do
|
137
134
|
stub_request(:post, "https://ryan@codecrate.com:secretz@api.github.com/authorizations").
|
138
|
-
|
139
|
-
to_return(:status => 200, :body => JSON.dump(token: authorization_token), :headers => {})
|
135
|
+
to_return(:status => 200, :body => JSON.dump(token: authorization_token), :headers => {'Content-Type' => 'application/json'})
|
140
136
|
|
141
137
|
expect(cli).to receive(:ask).with('Github password for ryan@codecrate.com: ', {:echo => false}).and_return(github_password)
|
138
|
+
expect(cli).to receive(:ask).with('Github two factor authorization token (if enabled): ', {:echo => false}).and_return(nil)
|
142
139
|
|
143
140
|
@auth_token = cli.send(:authorization_token)
|
144
141
|
end
|
@@ -161,6 +158,31 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
|
|
161
158
|
end
|
162
159
|
it { expect(@auth_token).to eq authorization_token }
|
163
160
|
end
|
161
|
+
context 'when two factor authorization token given' do
|
162
|
+
let(:repo_config) do
|
163
|
+
{
|
164
|
+
'remote.origin.url' => 'https://github.com/thegarage/thegarage-gitx',
|
165
|
+
'github.user' => 'ryan@codecrate.com'
|
166
|
+
}
|
167
|
+
end
|
168
|
+
let(:github_password) { 'secretz' }
|
169
|
+
let(:authorization_token) { '123981239123' }
|
170
|
+
let(:two_factor_auth_token) { '456456' }
|
171
|
+
before do
|
172
|
+
stub_request(:post, "https://ryan@codecrate.com:secretz@api.github.com/authorizations").
|
173
|
+
with(headers: {'X-GitHub-OTP' => two_factor_auth_token}).
|
174
|
+
to_return(:status => 200, :body => JSON.dump(token: authorization_token), :headers => {'Content-Type' => 'application/json'})
|
175
|
+
|
176
|
+
expect(cli).to receive(:ask).with('Github password for ryan@codecrate.com: ', {:echo => false}).and_return(github_password)
|
177
|
+
expect(cli).to receive(:ask).with('Github two factor authorization token (if enabled): ', {:echo => false}).and_return(two_factor_auth_token)
|
178
|
+
|
179
|
+
@auth_token = cli.send(:authorization_token)
|
180
|
+
end
|
181
|
+
it 'stores authorization_token in git config' do
|
182
|
+
expect(repo_config).to include('thegarage.gitx.githubauthtoken' => authorization_token)
|
183
|
+
end
|
184
|
+
it { expect(@auth_token).to eq authorization_token }
|
185
|
+
end
|
164
186
|
end
|
165
187
|
describe '#create_pull_request' do
|
166
188
|
context 'when there is an existing authorization_token' do
|
data/thegarage-gitx.gemspec
CHANGED
@@ -19,15 +19,16 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "rugged", '~> 0.19.0'
|
22
|
-
spec.add_runtime_dependency "rest-client", ">= 1.4.0"
|
23
22
|
spec.add_runtime_dependency "thor"
|
23
|
+
spec.add_runtime_dependency "rest-client", ">= 1.4.0"
|
24
|
+
spec.add_runtime_dependency "octokit"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
27
|
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "rspec", '
|
28
|
+
spec.add_development_dependency "rspec", '~> 3.0'
|
28
29
|
spec.add_development_dependency "pry", '>= 0'
|
29
30
|
spec.add_development_dependency "webmock", '>= 0'
|
30
|
-
spec.add_development_dependency "timecop", "~> 0.
|
31
|
+
spec.add_development_dependency "timecop", "~> 0.7.0"
|
31
32
|
spec.add_development_dependency "guard"
|
32
33
|
spec.add_development_dependency "guard-rspec"
|
33
34
|
spec.add_development_dependency "coveralls"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thegarage-gitx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.19.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rest-client
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +53,7 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: 1.4.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: octokit
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - '>='
|
@@ -84,16 +98,16 @@ dependencies:
|
|
84
98
|
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: '3.0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: '3.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: pry
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,14 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - ~>
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
145
|
+
version: 0.7.0
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - ~>
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
152
|
+
version: 0.7.0
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: guard
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,7 +249,10 @@ files:
|
|
235
249
|
- lib/thegarage/gitx/string_extensions.rb
|
236
250
|
- lib/thegarage/gitx/version.rb
|
237
251
|
- spec/spec_helper.rb
|
238
|
-
- spec/support/meet_expectations_matcher.rb
|
252
|
+
- spec/support/matchers/meet_expectations_matcher.rb
|
253
|
+
- spec/support/pry.rb
|
254
|
+
- spec/support/timecop.rb
|
255
|
+
- spec/support/webmock.rb
|
239
256
|
- spec/thegarage/gitx/cli/buildtag_command_spec.rb
|
240
257
|
- spec/thegarage/gitx/cli/cleanup_command_spec.rb
|
241
258
|
- spec/thegarage/gitx/cli/integrate_command_spec.rb
|
@@ -273,7 +290,10 @@ specification_version: 4
|
|
273
290
|
summary: Utility scripts for Git to increase productivity for common operations
|
274
291
|
test_files:
|
275
292
|
- spec/spec_helper.rb
|
276
|
-
- spec/support/meet_expectations_matcher.rb
|
293
|
+
- spec/support/matchers/meet_expectations_matcher.rb
|
294
|
+
- spec/support/pry.rb
|
295
|
+
- spec/support/timecop.rb
|
296
|
+
- spec/support/webmock.rb
|
277
297
|
- spec/thegarage/gitx/cli/buildtag_command_spec.rb
|
278
298
|
- spec/thegarage/gitx/cli/cleanup_command_spec.rb
|
279
299
|
- spec/thegarage/gitx/cli/integrate_command_spec.rb
|