git_reflow 0.4.1 → 0.4.2

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: 387fb2f3483c3e18b0bf7ba9073ae491b95c760a
4
- data.tar.gz: 2390815525f3338aba546b0c7f54d5e5827c5d13
3
+ metadata.gz: 56b9d1f62f165da2fa44742c87666802d88b484d
4
+ data.tar.gz: df62b69368422f3fee100b6c0d95145321cd2215
5
5
  SHA512:
6
- metadata.gz: eae7a39aec6c92600d8438e3d33d956a3212a1598c769e55d58b99f738e5f7567240e90f8887052f46408fe82237938e34ffc0ddff1697db554c669d616de07b
7
- data.tar.gz: 29de749587d60ddcbf05fd7dbe4adaa89b7e05d8753860d130edc3fc859b8985e6104712fbc895fc4e2c146c6494bc4d389fd021742000d8e569293ae87e047f
6
+ metadata.gz: c64744638a2767e4a3b24877a7b5dc61506715d6cb729665b91f3460c5731a1f918f84c6258e7c14b85e1830135a3b2f87318ae36c04122fa856914d63c3a50c
7
+ data.tar.gz: b1f37dd0b8db8c3e554d643d0e94e3b39942ea0e7a081f1fe4f7beea0c105cc652478543ab1ba9da0d52b73044ccefd633b034d816b37c9db00deefa35db9140
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.4.1)
4
+ git_reflow (0.4.2)
5
5
  colorize (= 0.6.0)
6
- github_api (= 0.12.2)
6
+ github_api (= 0.12.3)
7
7
  gli (= 2.12.2)
8
8
  highline
9
9
  httpclient
@@ -26,9 +26,9 @@ GEM
26
26
  descendants_tracker (0.0.4)
27
27
  thread_safe (~> 0.3, >= 0.3.1)
28
28
  diff-lcs (1.2.5)
29
- faraday (0.9.0)
29
+ faraday (0.9.1)
30
30
  multipart-post (>= 1.2, < 3)
31
- github_api (0.12.2)
31
+ github_api (0.12.3)
32
32
  addressable (~> 2.3)
33
33
  descendants_tracker (~> 0.0.4)
34
34
  faraday (~> 0.8, < 0.10)
@@ -37,19 +37,19 @@ GEM
37
37
  nokogiri (~> 1.6.3)
38
38
  oauth2
39
39
  gli (2.12.2)
40
- hashie (3.3.1)
40
+ hashie (3.4.0)
41
41
  highline (1.6.21)
42
- httpclient (2.5.1)
42
+ httpclient (2.6.0.1)
43
43
  json (1.7.5)
44
- json_pure (1.8.1)
45
- jwt (1.0.0)
44
+ json_pure (1.8.2)
45
+ jwt (1.2.1)
46
46
  method_source (0.8.2)
47
- mini_portile (0.6.0)
47
+ mini_portile (0.6.2)
48
48
  multi_json (1.10.1)
49
49
  multi_xml (0.5.5)
50
50
  multipart-post (2.0.0)
51
- nokogiri (1.6.3.1)
52
- mini_portile (= 0.6.0)
51
+ nokogiri (1.6.6.2)
52
+ mini_portile (~> 0.6.0)
53
53
  oauth2 (1.0.0)
54
54
  faraday (>= 0.8, < 0.10)
55
55
  jwt (~> 1.0)
@@ -63,7 +63,7 @@ GEM
63
63
  pry-byebug (2.0.0)
64
64
  byebug (~> 3.4)
65
65
  pry (~> 0.10)
66
- rack (1.5.2)
66
+ rack (1.6.0)
67
67
  rake (0.9.2.2)
68
68
  rdoc (3.12)
69
69
  json (~> 1.4)
data/README.rdoc CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  http://www.reenhanced.com/images/reflow.png
4
4
 
5
+
6
+
5
7
  If your workflow looks like this:
6
8
  1. Create a feature branch
7
9
  2. Write great code
data/git_reflow.gemspec CHANGED
@@ -31,7 +31,7 @@ spec = Gem::Specification.new do |s|
31
31
  s.add_dependency('highline')
32
32
  s.add_dependency('httpclient')
33
33
  s.add_dependency('json_pure')
34
- s.add_dependency('github_api', '0.12.2')
34
+ s.add_dependency('github_api', '0.12.3')
35
35
 
36
36
  s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
37
37
  end
@@ -7,12 +7,12 @@ module GitReflow
7
7
 
8
8
  def remote_user
9
9
  return "" unless "#{GitReflow::Config.get('remote.origin.url')}".length > 0
10
- GitReflow::Config.get('remote.origin.url')[/[\/:](\w|-|\.)+/i][1..-1]
10
+ extract_remote_user_and_repo_from_remote_url(GitReflow::Config.get('remote.origin.url'))[:user]
11
11
  end
12
12
 
13
13
  def remote_repo_name
14
14
  return "" unless "#{GitReflow::Config.get('remote.origin.url')}".length > 0
15
- GitReflow::Config.get('remote.origin.url')[/\/(\w|-|\.)+$/i][1..-5]
15
+ extract_remote_user_and_repo_from_remote_url(GitReflow::Config.get('remote.origin.url'))[:repo]
16
16
  end
17
17
 
18
18
  def current_branch
@@ -61,5 +61,22 @@ module GitReflow
61
61
  run "echo \"#{message}\" | cat - .git/SQUASH_MSG > ./tmp_squash_msg"
62
62
  run 'mv ./tmp_squash_msg .git/SQUASH_MSG'
63
63
  end
64
+
65
+ private
66
+
67
+ def extract_remote_user_and_repo_from_remote_url(remote_url)
68
+ result = { user: '', repo: '' }
69
+ return result unless "#{remote_url}".length > 0
70
+
71
+ if remote_url =~ /\Agit@/i
72
+ result[:user] = remote_url[/[\/:](\w|-|\.)+/i][1..-1]
73
+ result[:repo] = remote_url[/\/(\w|-|\.)+$/i][1..-5]
74
+ elsif remote_url =~ /\Ahttps?/i
75
+ result[:user] = remote_url.split('/')[-2]
76
+ result[:repo] = remote_url.split('/')[-1].gsub(/.git\Z/i, '')
77
+ end
78
+
79
+ result
80
+ end
64
81
  end
65
82
  end
@@ -53,6 +53,8 @@ module GitReflow
53
53
  config.ssl = {:verify => false}
54
54
  end
55
55
 
56
+ @connection.connection_options = {headers: {"X-GitHub-OTP" => options[:two_factor_auth_code]}} if options[:two_factor_auth_code]
57
+
56
58
  previous_authorizations = @connection.oauth.all.select {|auth| auth.note == "git-reflow (#{run('hostname', loud: false).strip})" }
57
59
  if previous_authorizations.any?
58
60
  authorization = previous_authorizations.last
@@ -61,33 +63,11 @@ module GitReflow
61
63
  end
62
64
 
63
65
  self.class.oauth_token = authorization.token
64
- puts "\nYour GitHub account was successfully setup!"
65
66
 
66
67
  rescue ::Github::Error::Unauthorized => e
67
68
  if e.inspect.to_s.include?('two-factor')
68
- two_factor_code = ask("Please enter your two-factor authentication code: ")
69
- github_authorizations = @connection.oauth.class.new(
70
- basic_auth: "#{gh_user}:#{gh_password}",
71
- endpoint: GitServer::GitHub.api_endpoint,
72
- site: GitServer::GitHub.site_url,
73
- ssl: {:verify => false},
74
- headers: { "X-GitHub-OTP" => two_factor_code }
75
- )
76
-
77
- previous_authorizations = github_authorizations.all.select {|auth|
78
- auth.note == "git-reflow (#{run('hostname', loud: false).strip})"
79
- }
80
-
81
- self.class.user = gh_user
82
-
83
- if previous_authorizations.any?
84
- authorization = previous_authorizations.last
85
- else
86
- authorization = github_authorizations.create scopes: ['repo'], note: "git-reflow (#{run('hostname', loud: false).strip})"
87
- end
88
-
89
- self.class.oauth_token = authorization.token
90
- puts "\nYour GitHub account was successfully setup!"
69
+ two_factor_code = ask("Please enter your two-factor authentication code: ")
70
+ self.authenticate options.merge({user: gh_user, password: gh_password, two_factor_auth_code: two_factor_code})
91
71
  else
92
72
  puts "\nGithub Authentication Error: #{e.inspect}"
93
73
  end
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -23,6 +23,11 @@ describe GitReflow::GitHelpers do
23
23
  let(:origin_url) { nil }
24
24
  it { should == '' }
25
25
  end
26
+
27
+ context "remote origin uses HTTP" do
28
+ let(:origin_url) { 'https://github.com/reenhanced.spectacular/this-is-the.shit.git' }
29
+ it { should == 'reenhanced.spectacular' }
30
+ end
26
31
  end
27
32
 
28
33
  describe ".remote_repo_name" do
@@ -34,6 +39,11 @@ describe GitReflow::GitHelpers do
34
39
  let(:origin_url) { nil }
35
40
  it { should == '' }
36
41
  end
42
+
43
+ context "remote origin uses HTTP" do
44
+ let(:origin_url) { 'https://github.com/reenhanced.spectacular/this-is-the.shit.git' }
45
+ it { should == 'this-is-the.shit' }
46
+ end
37
47
  end
38
48
 
39
49
  describe ".current_branch" do
@@ -148,7 +148,7 @@ describe GitReflow::GitServer::GitHub do
148
148
  end
149
149
 
150
150
  it "notifies user of invalid login details" do
151
- expect { subject }.to have_output "\nInvalid username or password: #{Github::Error::Unauthorized.new(unauthorized_error_response).inspect}"
151
+ expect { subject }.to have_output "\nGithub Authentication Error: #{Github::Error::Unauthorized.new(unauthorized_error_response).inspect}"
152
152
  end
153
153
  end
154
154
  end
@@ -71,15 +71,15 @@ module GithubHelpers
71
71
  to_return(:body => pull.to_s, :status => 201, :headers => {:content_type => "application/json\; charset=utf-8"})
72
72
 
73
73
  # Stubbing pull request finder
74
- stub_get("/repos/#{user}/pulls").with(:query => {'base' => 'master', 'head' => "#{user}:#{branch}", 'state' => 'open'}).
74
+ stub_get("/repos/#{user}/pulls").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0', 'base' => 'master', 'head' => "#{user}:#{branch}", 'state' => 'open'}).
75
75
  to_return(:body => fixture('pull_requests/pull_requests.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
76
- stub_get("/repos/#{user}/#{repo}/pulls").with(:query => {'base' => 'master', 'head' => "#{user}:#{branch}", 'state' => 'open'}).
76
+ stub_get("/repos/#{user}/#{repo}/pulls").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0', 'base' => 'master', 'head' => "#{user}:#{branch}", 'state' => 'open'}).
77
77
  to_return(:body => fixture('pull_requests/pull_requests.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
78
78
  # Stubbing pull request comments
79
- stub_get("/repos/#{user}/pulls/#{pull[:number]}/comments?").
79
+ stub_get("/repos/#{user}/pulls/#{pull[:number]}/comments?").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0'}).
80
80
  to_return(:body => fixture('pull_requests/comments.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
81
81
  # Stubbing issue comments
82
- stub_get("/repos/#{user}/issues/#{pull[:number]}/comments?").
82
+ stub_get("/repos/#{user}/issues/#{pull[:number]}/comments?").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0'}).
83
83
  to_return(:body => fixture('issues/comments.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
84
84
  end
85
85
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_reflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentino Stoll
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-28 00:00:00.000000000 Z
13
+ date: 2015-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -172,14 +172,14 @@ dependencies:
172
172
  requirements:
173
173
  - - '='
174
174
  - !ruby/object:Gem::Version
175
- version: 0.12.2
175
+ version: 0.12.3
176
176
  type: :runtime
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
180
  - - '='
181
181
  - !ruby/object:Gem::Version
182
- version: 0.12.2
182
+ version: 0.12.3
183
183
  description: Git Reflow manages your git workflow.
184
184
  email:
185
185
  - dev@reenhanced.com
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  version: '0'
260
260
  requirements: []
261
261
  rubyforge_project:
262
- rubygems_version: 2.2.2
262
+ rubygems_version: 2.4.3
263
263
  signing_key:
264
264
  specification_version: 4
265
265
  summary: A better git process