ghi 0.9.3 → 1.0.2
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/ghi/authorization.rb +4 -2
- data/lib/ghi/client.rb +3 -1
- data/lib/ghi/commands.rb +3 -0
- data/lib/ghi/commands/command.rb +11 -0
- data/lib/ghi/commands/disable.rb +35 -0
- data/lib/ghi/commands/enable.rb +36 -0
- data/lib/ghi/commands/help.rb +3 -0
- data/lib/ghi/commands/list.rb +15 -2
- data/lib/ghi/commands/milestone.rb +1 -1
- data/lib/ghi/commands/open.rb +1 -1
- data/lib/ghi/commands/status.rb +32 -0
- data/lib/ghi/commands/version.rb +3 -3
- data/lib/ghi/formatting.rb +19 -9
- data/lib/ghi/formatting/colors.rb +5 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696fce57a7e89cb7685529b9e6bbabcefde0ee2d
|
4
|
+
data.tar.gz: 19a171ad807242aabe60dc72142a6fdf877f2685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f9a475b4713a41828414f000d4e6da666dc75c0e43df5430041e776f73ff81d2b6f0383aeec8e38cabff04a03e0aeffe2bf2f4b11f58b1b4684af0e7854f828
|
7
|
+
data.tar.gz: dc0a1c4930f0a4445bcefac59501d58a2930462e06fe2c88b594699b85003d6e67545db7cc187c1c9477cf7bccdb7d32fa6820466eda3be96aec6917743d261e
|
data/lib/ghi/authorization.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'socket'
|
2
3
|
|
3
4
|
module GHI
|
4
5
|
module Authorization
|
@@ -39,7 +40,7 @@ module GHI
|
|
39
40
|
system "git config#{' --global' unless local} github.user #{user}"
|
40
41
|
end
|
41
42
|
|
42
|
-
store_token!
|
43
|
+
store_token! user, token, local
|
43
44
|
rescue Client::Error => e
|
44
45
|
if e.response['X-GitHub-OTP'] =~ /required/
|
45
46
|
puts "Bad code." if code
|
@@ -51,12 +52,13 @@ module GHI
|
|
51
52
|
end
|
52
53
|
|
53
54
|
if e.errors.any? { |err| err['code'] == 'already_exists' }
|
55
|
+
host = GHI.config('github.host') || 'github.com'
|
54
56
|
message = <<EOF.chomp
|
55
57
|
A ghi token already exists!
|
56
58
|
|
57
59
|
Please revoke all previously-generated ghi personal access tokens here:
|
58
60
|
|
59
|
-
https
|
61
|
+
https://#{host}/settings/applications
|
60
62
|
EOF
|
61
63
|
else
|
62
64
|
message = e.message
|
data/lib/ghi/client.rb
CHANGED
data/lib/ghi/commands.rb
CHANGED
@@ -8,12 +8,15 @@ module GHI
|
|
8
8
|
autoload :Close, 'ghi/commands/close'
|
9
9
|
autoload :Comment, 'ghi/commands/comment'
|
10
10
|
autoload :Config, 'ghi/commands/config'
|
11
|
+
autoload :Disable, 'ghi/commands/disable'
|
11
12
|
autoload :Edit, 'ghi/commands/edit'
|
13
|
+
autoload :Enable, 'ghi/commands/enable'
|
12
14
|
autoload :Help, 'ghi/commands/help'
|
13
15
|
autoload :Label, 'ghi/commands/label'
|
14
16
|
autoload :Milestone, 'ghi/commands/milestone'
|
15
17
|
autoload :Reopen, 'ghi/commands/reopen'
|
16
18
|
autoload :Show, 'ghi/commands/show'
|
19
|
+
autoload :Status, 'ghi/commands/status'
|
17
20
|
autoload :Unassign, 'ghi/commands/unassign'
|
18
21
|
autoload :Version, 'ghi/commands/version'
|
19
22
|
end
|
data/lib/ghi/commands/command.rb
CHANGED
@@ -62,6 +62,17 @@ module GHI
|
|
62
62
|
abort options.to_s
|
63
63
|
end
|
64
64
|
|
65
|
+
def require_repo_name
|
66
|
+
require_repo
|
67
|
+
repo_array = repo.partition "/"
|
68
|
+
if repo_array.length >= 2
|
69
|
+
repo_name = repo_array[2]
|
70
|
+
else
|
71
|
+
repo_name = nil
|
72
|
+
end
|
73
|
+
return repo_name
|
74
|
+
end
|
75
|
+
|
65
76
|
def detect_repo
|
66
77
|
remote = remotes.find { |r| r[:remote] == 'upstream' }
|
67
78
|
remote ||= remotes.find { |r| r[:remote] == 'origin' }
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module GHI
|
2
|
+
module Commands
|
3
|
+
class Disable < Command
|
4
|
+
|
5
|
+
def options
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = 'usage: ghi disable'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
begin
|
13
|
+
options.parse! args
|
14
|
+
@repo ||= ARGV[0] if ARGV.one?
|
15
|
+
rescue OptionParser::InvalidOption => e
|
16
|
+
fallback.parse! e.args
|
17
|
+
retry
|
18
|
+
end
|
19
|
+
repo_name = require_repo_name
|
20
|
+
unless repo_name.nil?
|
21
|
+
patch_data = {}
|
22
|
+
patch_data[:name] = repo_name
|
23
|
+
patch_data[:has_issues] = false
|
24
|
+
res = throb { api.patch "/repos/#{repo}", patch_data }.body
|
25
|
+
if !res['has_issues']
|
26
|
+
puts "Issues are now disabled for this repo"
|
27
|
+
else
|
28
|
+
puts "Something went wrong disabling issues for this repo"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module GHI
|
2
|
+
module Commands
|
3
|
+
class Enable < Command
|
4
|
+
|
5
|
+
def options
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = 'usage: ghi enable'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
begin
|
13
|
+
options.parse! args
|
14
|
+
@repo ||= ARGV[0] if ARGV.one?
|
15
|
+
rescue OptionParser::InvalidOption => e
|
16
|
+
fallback.parse! e.args
|
17
|
+
retry
|
18
|
+
end
|
19
|
+
repo_name = require_repo_name
|
20
|
+
unless repo_name.nil?
|
21
|
+
patch_data = {}
|
22
|
+
patch_data[:name] = repo_name
|
23
|
+
patch_data[:has_issues] = true
|
24
|
+
res = throb { api.patch "/repos/#{repo}", patch_data }.body
|
25
|
+
if res['has_issues']
|
26
|
+
puts "Issues are now enabled for this repo"
|
27
|
+
else
|
28
|
+
puts "Something went wrong enabling issues for this repo"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/ghi/commands/help.rb
CHANGED
@@ -35,6 +35,9 @@ The most commonly used ghi commands are:
|
|
35
35
|
label Create, list, modify, or delete labels
|
36
36
|
assign Assign an issue to yourself (or someone else)
|
37
37
|
milestone Manage project milestones
|
38
|
+
status Determine whether or not issues are enabled for this repo
|
39
|
+
enable Enable issues for the current repo
|
40
|
+
disable Disable issues for the current repo
|
38
41
|
|
39
42
|
See 'ghi help <command>' for more information on a specific command.
|
40
43
|
EOF
|
data/lib/ghi/commands/list.rb
CHANGED
@@ -13,7 +13,7 @@ module GHI
|
|
13
13
|
OptionParser.new do |opts|
|
14
14
|
opts.banner = 'usage: ghi list [options]'
|
15
15
|
opts.separator ''
|
16
|
-
opts.on '-
|
16
|
+
opts.on '-g', '--global', 'all of your issues on GitHub' do
|
17
17
|
assigns[:filter] = 'all'
|
18
18
|
@repo = nil
|
19
19
|
end
|
@@ -100,6 +100,12 @@ module GHI
|
|
100
100
|
) do |mentioned|
|
101
101
|
assigns[:mentioned] = mentioned || Authorization.username
|
102
102
|
end
|
103
|
+
opts.on(
|
104
|
+
'-O', '--org <organization>', 'in repos within an organization you belong to'
|
105
|
+
) do |org|
|
106
|
+
assigns[:org] = org
|
107
|
+
@repo = nil
|
108
|
+
end
|
103
109
|
opts.separator ''
|
104
110
|
end
|
105
111
|
end
|
@@ -172,7 +178,14 @@ module GHI
|
|
172
178
|
private
|
173
179
|
|
174
180
|
def uri
|
175
|
-
|
181
|
+
url = ''
|
182
|
+
if repo
|
183
|
+
url = "/repos/#{repo}"
|
184
|
+
end
|
185
|
+
if assigns[:org]
|
186
|
+
url = "/orgs/#{assigns[:org]}"
|
187
|
+
end
|
188
|
+
return url << '/issues'
|
176
189
|
end
|
177
190
|
|
178
191
|
def fallback
|
data/lib/ghi/commands/open.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module GHI
|
2
|
+
module Commands
|
3
|
+
class Status < Command
|
4
|
+
|
5
|
+
def options
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = 'usage: ghi status'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
begin
|
13
|
+
options.parse! args
|
14
|
+
@repo ||= ARGV[0] if ARGV.one?
|
15
|
+
rescue OptionParser::InvalidOption => e
|
16
|
+
fallback.parse! e.args
|
17
|
+
retry
|
18
|
+
end
|
19
|
+
|
20
|
+
require_repo
|
21
|
+
res = throb { api.get "/repos/#{repo}" }.body
|
22
|
+
|
23
|
+
if res['has_issues']
|
24
|
+
puts "Issues are enabled for this repo"
|
25
|
+
else
|
26
|
+
puts "Issues are not enabled for this repo"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ghi/commands/version.rb
CHANGED
data/lib/ghi/formatting.rb
CHANGED
@@ -84,7 +84,9 @@ module GHI
|
|
84
84
|
|
85
85
|
def truncate string, reserved
|
86
86
|
return string unless paginate?
|
87
|
-
|
87
|
+
space=columns - reserved
|
88
|
+
space=5 if space < 5
|
89
|
+
result = string.scan(/.{0,#{space}}(?:\s|\Z)/).first.strip
|
88
90
|
result << "..." if result != string
|
89
91
|
result
|
90
92
|
end
|
@@ -105,7 +107,7 @@ module GHI
|
|
105
107
|
end
|
106
108
|
|
107
109
|
def dimensions
|
108
|
-
`stty size`.chomp.split(' ').map { |n| n.to_i }
|
110
|
+
`stty size 2>/dev/null`.chomp.split(' ').map { |n| n.to_i }
|
109
111
|
end
|
110
112
|
|
111
113
|
#--
|
@@ -118,7 +120,8 @@ module GHI
|
|
118
120
|
|
119
121
|
def format_issues_header
|
120
122
|
state = assigns[:state] ||= 'open'
|
121
|
-
|
123
|
+
org = assigns[:org] ||= nil
|
124
|
+
header = "# #{repo || org || 'Global,'} #{state} issues"
|
122
125
|
if repo
|
123
126
|
if milestone = assigns[:milestone]
|
124
127
|
case milestone
|
@@ -164,7 +167,6 @@ module GHI
|
|
164
167
|
format_state assigns[:state], header
|
165
168
|
end
|
166
169
|
|
167
|
-
# TODO: Show milestones.
|
168
170
|
def format_issues issues, include_repo
|
169
171
|
return 'None.' if issues.empty?
|
170
172
|
|
@@ -184,15 +186,18 @@ module GHI
|
|
184
186
|
p = i['pull_request']['html_url'] and l += 2
|
185
187
|
c = i['comments']
|
186
188
|
l += c.to_s.length + 1 unless c == 0
|
189
|
+
m = i['milestone']
|
187
190
|
[
|
188
191
|
" ",
|
189
192
|
(i['repo'].to_s.rjust(rmax) if i['repo']),
|
190
193
|
format_number(n.to_s.rjust(nmax)),
|
191
194
|
truncate(title, l),
|
192
195
|
format_labels(labels),
|
196
|
+
(fg(:green) { m['title'] } if m),
|
193
197
|
(fg('aaaaaa') { c } unless c == 0),
|
194
198
|
(fg('aaaaaa') { '↑' } if p),
|
195
|
-
(fg(:yellow) { '@' } if a)
|
199
|
+
(fg(:yellow) { '@' } if a),
|
200
|
+
(fg('aaaaaa') { '‡' } if m)
|
196
201
|
].compact.join ' '
|
197
202
|
}
|
198
203
|
end
|
@@ -361,6 +366,7 @@ EOF
|
|
361
366
|
def format_editor issue = nil
|
362
367
|
message = ERB.new(<<EOF).result binding
|
363
368
|
|
369
|
+
|
364
370
|
Please explain the issue. The first line will become the title. Trailing
|
365
371
|
lines starting with '#' (like these) will be ignored, and empty messages will
|
366
372
|
not be submitted. Issues are formatted with GitHub Flavored Markdown (GFM):
|
@@ -372,7 +378,11 @@ On <%= repo %>
|
|
372
378
|
<%= no_color { format_issue issue, columns - 2 if issue } %>
|
373
379
|
EOF
|
374
380
|
message.rstrip!
|
375
|
-
message.gsub!(/(?!\A)^.*$/) { |line|
|
381
|
+
message.gsub!(/(?!\A)^.*$/) { |line|
|
382
|
+
# unless line.empty?
|
383
|
+
"# #{line}".rstrip
|
384
|
+
# end
|
385
|
+
}
|
376
386
|
message.insert 0, [
|
377
387
|
issue['title'] || issue[:title], issue['body'] || issue[:body]
|
378
388
|
].compact.join("\n\n") if issue
|
@@ -403,9 +413,9 @@ EOF
|
|
403
413
|
def format_comment_editor issue, comment = nil
|
404
414
|
message = ERB.new(<<EOF).result binding
|
405
415
|
|
406
|
-
Leave a comment.
|
407
|
-
|
408
|
-
|
416
|
+
Leave a comment. Trailing lines starting with '#' (like these) will be ignored,
|
417
|
+
and empty messages will not be submitted. Comments are formatted with GitHub
|
418
|
+
Flavored Markdown (GFM):
|
409
419
|
|
410
420
|
http://github.github.com/github-flavored-markdown
|
411
421
|
|
@@ -331,7 +331,11 @@ module GHI
|
|
331
331
|
lang = code_block['lang']
|
332
332
|
code = code_block['code']
|
333
333
|
|
334
|
-
|
334
|
+
if lang != ""
|
335
|
+
output = pygmentize(lang, code)
|
336
|
+
else
|
337
|
+
output = code
|
338
|
+
end
|
335
339
|
with_indentation(output, indent)
|
336
340
|
rescue
|
337
341
|
code_block
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -56,13 +56,16 @@ files:
|
|
56
56
|
- lib/ghi/commands/command.rb
|
57
57
|
- lib/ghi/commands/comment.rb
|
58
58
|
- lib/ghi/commands/config.rb
|
59
|
+
- lib/ghi/commands/disable.rb
|
59
60
|
- lib/ghi/commands/edit.rb
|
61
|
+
- lib/ghi/commands/enable.rb
|
60
62
|
- lib/ghi/commands/help.rb
|
61
63
|
- lib/ghi/commands/label.rb
|
62
64
|
- lib/ghi/commands/list.rb
|
63
65
|
- lib/ghi/commands/milestone.rb
|
64
66
|
- lib/ghi/commands/open.rb
|
65
67
|
- lib/ghi/commands/show.rb
|
68
|
+
- lib/ghi/commands/status.rb
|
66
69
|
- lib/ghi/commands/version.rb
|
67
70
|
- lib/ghi/editor.rb
|
68
71
|
- lib/ghi/formatting.rb
|
@@ -88,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
91
|
version: '0'
|
89
92
|
requirements: []
|
90
93
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.4.6
|
92
95
|
signing_key:
|
93
96
|
specification_version: 4
|
94
97
|
summary: GitHub Issues command line interface
|