git_reflow 0.4.0 → 0.4.1

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: 6033d9ac0481348f75d715588d5ae35f451b53e8
4
- data.tar.gz: 6865bb6dfdad09ada836eb0e5cb08a2f8bc7b29f
3
+ metadata.gz: 387fb2f3483c3e18b0bf7ba9073ae491b95c760a
4
+ data.tar.gz: 2390815525f3338aba546b0c7f54d5e5827c5d13
5
5
  SHA512:
6
- metadata.gz: 1054c1140b333a61c70030757b5a713b2d23a876c2912d6d18887c4d946e7e8b8e92f4277529bf8075ed9112e6b701ed79a2102fe51759d7a415229b5414d189
7
- data.tar.gz: 9720ebbd2a3ee378cc830940de30170b58ed1fe970264f45807fad418f03413d40faf8099ff947bfd9bf7e2f77d436eaa0b6dc554c6d83cc4d0be58e331231bb
6
+ metadata.gz: eae7a39aec6c92600d8438e3d33d956a3212a1598c769e55d58b99f738e5f7567240e90f8887052f46408fe82237938e34ffc0ddff1697db554c669d616de07b
7
+ data.tar.gz: 29de749587d60ddcbf05fd7dbe4adaa89b7e05d8753860d130edc3fc859b8985e6104712fbc895fc4e2c146c6494bc4d389fd021742000d8e569293ae87e047f
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.4.0)
4
+ git_reflow (0.4.1)
5
5
  colorize (= 0.6.0)
6
- github_api (= 0.12.1)
6
+ github_api (= 0.12.2)
7
7
  gli (= 2.12.2)
8
8
  highline
9
9
  httpclient
@@ -28,18 +28,18 @@ GEM
28
28
  diff-lcs (1.2.5)
29
29
  faraday (0.9.0)
30
30
  multipart-post (>= 1.2, < 3)
31
- github_api (0.12.1)
31
+ github_api (0.12.2)
32
32
  addressable (~> 2.3)
33
33
  descendants_tracker (~> 0.0.4)
34
34
  faraday (~> 0.8, < 0.10)
35
- hashie (>= 3.2)
35
+ hashie (>= 3.3)
36
36
  multi_json (>= 1.7.5, < 2.0)
37
37
  nokogiri (~> 1.6.3)
38
38
  oauth2
39
39
  gli (2.12.2)
40
40
  hashie (3.3.1)
41
41
  highline (1.6.21)
42
- httpclient (2.4.0)
42
+ httpclient (2.5.1)
43
43
  json (1.7.5)
44
44
  json_pure (1.8.1)
45
45
  jwt (1.0.0)
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) {{year}} {{fullname}}
3
+ Copyright (c) 2014 Reenhanced L.L.C.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
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.1')
34
+ s.add_dependency('github_api', '0.12.2')
35
35
 
36
36
  s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
37
37
  end
@@ -34,7 +34,7 @@ module GitReflow
34
34
  end
35
35
 
36
36
  def authenticate(options = {silent: false})
37
- if connection
37
+ if connection and self.class.oauth_token.length > 0
38
38
  unless options[:silent]
39
39
  puts "Your GitHub account was already setup with: "
40
40
  puts "\tUser Name: #{self.class.user}"
@@ -42,8 +42,8 @@ module GitReflow
42
42
  end
43
43
  else
44
44
  begin
45
- gh_user = ask("Please enter your GitHub username: ")
46
- gh_password = ask("Please enter your GitHub password (we do NOT store this): ") { |q| q.echo = false }
45
+ gh_user = options[:user] || ask("Please enter your GitHub username: ")
46
+ gh_password = options[:password] || ask("Please enter your GitHub password (we do NOT store this): ") { |q| q.echo = false }
47
47
 
48
48
  @connection = ::Github.new do |config|
49
49
  config.basic_auth = "#{gh_user}:#{gh_password}"
@@ -60,13 +60,39 @@ module GitReflow
60
60
  authorization = @connection.oauth.create scopes: ['repo'], note: "git-reflow (#{run('hostname', loud: false).strip})"
61
61
  end
62
62
 
63
- oauth_token = authorization.token
64
-
65
- self.class.oauth_token = oauth_token
63
+ self.class.oauth_token = authorization.token
66
64
  puts "\nYour GitHub account was successfully setup!"
67
65
 
66
+ rescue ::Github::Error::Unauthorized => e
67
+ 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!"
91
+ else
92
+ puts "\nGithub Authentication Error: #{e.inspect}"
93
+ end
68
94
  rescue StandardError => e
69
- puts "\nInvalid username or password: #{e.inspect}"
95
+ puts "\nInvalid username or password: #{e.body}"
70
96
  else
71
97
  puts "\nYour GitHub account was successfully setup!"
72
98
  end
@@ -101,18 +127,22 @@ module GitReflow
101
127
  GitReflow::Config.get('github.user')
102
128
  end
103
129
 
130
+ def self.user=(github_user)
131
+ GitReflow::Config.set('github.user', github_user, local: @@project_only)
132
+ end
133
+
104
134
  def self.oauth_token
105
135
  GitReflow::Config.get('github.oauth-token')
106
136
  end
107
137
 
108
- def self.oauth_token=(oauth_token, options = {})
138
+ def self.oauth_token=(oauth_token)
109
139
  GitReflow::Config.set('github.oauth-token', oauth_token, local: @@project_only)
110
140
  oauth_token
111
141
  end
112
142
 
113
143
  def self.api_endpoint
114
144
  endpoint = GitReflow::Config.get('github.endpoint')
115
- (endpoint.length > 0) ? endpoint : ::Github::Configuration.new.endpoint
145
+ (endpoint.length > 0) ? endpoint : ::Github.endpoint
116
146
  end
117
147
 
118
148
  def self.api_endpoint=(api_endpoint)
@@ -122,7 +152,7 @@ module GitReflow
122
152
 
123
153
  def self.site_url
124
154
  site_url = GitReflow::Config.get('github.site')
125
- (site_url.length > 0) ? site_url : ::Github::Configuration.new.site
155
+ (site_url.length > 0) ? site_url : ::Github.site
126
156
  end
127
157
 
128
158
  def self.site_url=(site_url)
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
4
+ version: 0.4.1
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-16 00:00:00.000000000 Z
13
+ date: 2014-10-28 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.1
175
+ version: 0.12.2
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.1
182
+ version: 0.12.2
183
183
  description: Git Reflow manages your git workflow.
184
184
  email:
185
185
  - dev@reenhanced.com