cob 0.0.15 → 0.1.3
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 +4 -4
- data/lib/credentials.rb +9 -6
- data/lib/paginator.rb +25 -3
- data/lib/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 578c29ed01af18576c3bab0c6b491302c072e770f41339a2a80cb46f0a080641
|
4
|
+
data.tar.gz: 4aca11e23652d44e90f34b1066adc79ec0aae8cf4d23d1ce5aca2c45ba97a97c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8414ab96ca7ba9bd22118496512df8502d94e4e94e1c5511c2ad9ce5f661372ef3bce4453c4a6afd7af9d77521c1fbed810bbdaea0db71b4d09abdf0e6d2efb2
|
7
|
+
data.tar.gz: b2d0795dea231ea62700d280f2ab92623e32b941fb949b0230809719c6d7d60e69290706d88a340f3754df8ea3c5d4595c688a27881fd882e3d4ddd1d069513b
|
data/lib/credentials.rb
CHANGED
@@ -13,21 +13,24 @@ class Credentials
|
|
13
13
|
def initialize
|
14
14
|
@config_file = ENV['GITHUB_CREDENTIALS_FILE'] ||
|
15
15
|
"#{ENV['HOME']}/.cob/github_credentials.json"
|
16
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
def config
|
19
|
+
@config ||= parse_config
|
17
20
|
end
|
18
21
|
|
19
22
|
def username
|
20
23
|
# USERNAME
|
21
|
-
|
24
|
+
config['username'] || prompt_username
|
22
25
|
end
|
23
26
|
|
24
27
|
def pa_token
|
25
28
|
# PA_TOKEN
|
26
|
-
|
29
|
+
config['paToken'] || prompt_pa_token
|
27
30
|
end
|
28
31
|
|
29
32
|
def overwrite_config
|
30
|
-
File.write(@config_file,
|
33
|
+
File.write(@config_file, config.to_json)
|
31
34
|
end
|
32
35
|
|
33
36
|
def prompt_username
|
@@ -37,7 +40,7 @@ class Credentials
|
|
37
40
|
q.modify :lowercase
|
38
41
|
end
|
39
42
|
|
40
|
-
|
43
|
+
config['username'] = username
|
41
44
|
overwrite_config
|
42
45
|
|
43
46
|
username
|
@@ -49,7 +52,7 @@ class Credentials
|
|
49
52
|
q.required true
|
50
53
|
end
|
51
54
|
|
52
|
-
|
55
|
+
config['paToken'] = token
|
53
56
|
overwrite_config
|
54
57
|
|
55
58
|
token
|
data/lib/paginator.rb
CHANGED
@@ -53,9 +53,23 @@ class Paginator
|
|
53
53
|
_header, body = http_get_issues.split("\r\n\r\n")
|
54
54
|
data = JSON.parse(body)
|
55
55
|
|
56
|
-
|
56
|
+
if data.is_a?(Hash) && data['message'] == 'Not Found'
|
57
|
+
puts "Github's API might have changed..."
|
58
|
+
puts "Following request failed:"
|
59
|
+
puts curl_command
|
60
|
+
|
61
|
+
exit 1
|
62
|
+
end
|
63
|
+
|
57
64
|
if data.is_a?(Hash) && data['message'] == 'Bad credentials'
|
58
65
|
puts 'Your github credentials are wrong.'
|
66
|
+
puts "Github made changes to it's authentication requirements.."
|
67
|
+
puts "In order to access the issues of a private repo, you need to create a"
|
68
|
+
puts "personal access token with at least the 'repo' privilages.."
|
69
|
+
puts "please try again with a new token, you can make one at the URL below"
|
70
|
+
puts ""
|
71
|
+
puts " https://github.com/settings/tokens"
|
72
|
+
puts ""
|
59
73
|
|
60
74
|
@credentials.reset_config_file
|
61
75
|
exit 1
|
@@ -65,10 +79,18 @@ class Paginator
|
|
65
79
|
end
|
66
80
|
|
67
81
|
def http_get_issues
|
82
|
+
`#{curl_command}`
|
83
|
+
end
|
84
|
+
|
85
|
+
def curl_command
|
68
86
|
uname = @credentials.username
|
69
87
|
token = @credentials.pa_token
|
70
|
-
|
88
|
+
<<~CMD
|
89
|
+
curl -sS -i "https://api.github.com/repos/#{Git.repository_owner}/#{Git.repository}/issues?page=#{@page}&state=open" \
|
71
90
|
-u "#{uname}:#{token}" \
|
72
|
-
-H "Content-Type: application/json"
|
91
|
+
-H "Content-Type: application/json" \
|
92
|
+
-H "Accept: application/vnd.github.v3+json"
|
93
|
+
|
94
|
+
CMD
|
73
95
|
end
|
74
96
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-09-03 00:00:00.000000000 Z
|
@@ -73,7 +73,7 @@ homepage: https://github.com/yanshiyason/cob
|
|
73
73
|
licenses:
|
74
74
|
- MIT
|
75
75
|
metadata: {}
|
76
|
-
post_install_message:
|
76
|
+
post_install_message:
|
77
77
|
rdoc_options: []
|
78
78
|
require_paths:
|
79
79
|
- lib
|
@@ -88,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
92
|
-
signing_key:
|
91
|
+
rubygems_version: 3.2.15
|
92
|
+
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Checkout github branches with style
|
95
95
|
test_files: []
|