ghi 0.9.0.20120731 → 0.9.0.20121114
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.
- data/lib/ghi.rb +3 -3
- data/lib/ghi/client.rb +11 -1
- data/lib/ghi/commands/assign.rb +1 -0
- data/lib/ghi/commands/config.rb +1 -1
- data/lib/ghi/commands/list.rb +6 -1
- data/lib/ghi/commands/show.rb +20 -10
- data/lib/ghi/commands/version.rb +1 -1
- data/lib/ghi/formatting.rb +4 -4
- data/lib/ghi/web.rb +12 -7
- metadata +2 -2
data/lib/ghi.rb
CHANGED
@@ -105,9 +105,9 @@ EOF
|
|
105
105
|
exit 1
|
106
106
|
end
|
107
107
|
|
108
|
-
def config key
|
109
|
-
var = key.gsub('core', 'git').gsub
|
110
|
-
value = ENV[var] || `git config #{key}`.chomp
|
108
|
+
def config key, upcase = true
|
109
|
+
var = key.gsub('core', 'git').gsub '.', '_'
|
110
|
+
value = ENV[upcase ? var.upcase : var] || `git config #{key}`.chomp
|
111
111
|
value unless value.empty?
|
112
112
|
end
|
113
113
|
|
data/lib/ghi/client.rb
CHANGED
@@ -54,6 +54,8 @@ module GHI
|
|
54
54
|
:patch => Net::HTTP::Patch,
|
55
55
|
:delete => Net::HTTP::Delete
|
56
56
|
}
|
57
|
+
HOST = 'api.github.com'
|
58
|
+
PORT = 443
|
57
59
|
|
58
60
|
attr_reader :username, :password
|
59
61
|
def initialize username = nil, password = nil
|
@@ -102,7 +104,15 @@ module GHI
|
|
102
104
|
end
|
103
105
|
req.basic_auth username, password if username && password
|
104
106
|
|
105
|
-
|
107
|
+
proxy = GHI.config 'https.proxy', false
|
108
|
+
proxy ||= GHI.config 'http.proxy', false
|
109
|
+
if proxy
|
110
|
+
proxy = URI.parse proxy
|
111
|
+
http = Net::HTTP::Proxy(proxy.host, proxy.port).new HOST, PORT
|
112
|
+
else
|
113
|
+
http = Net::HTTP.new HOST, PORT
|
114
|
+
end
|
115
|
+
|
106
116
|
http.use_ssl = true
|
107
117
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # FIXME 1.8.7
|
108
118
|
|
data/lib/ghi/commands/assign.rb
CHANGED
data/lib/ghi/commands/config.rb
CHANGED
@@ -22,7 +22,7 @@ EOF
|
|
22
22
|
global = true
|
23
23
|
options.parse! args.empty? ? %w(-h) : args
|
24
24
|
|
25
|
-
if
|
25
|
+
if action == 'auth'
|
26
26
|
assigns[:password] = Authorization.password || get_password
|
27
27
|
Authorization.authorize!(
|
28
28
|
assigns[:username], assigns[:password], assigns[:local]
|
data/lib/ghi/commands/list.rb
CHANGED
@@ -6,6 +6,7 @@ module GHI
|
|
6
6
|
attr_accessor :web
|
7
7
|
attr_accessor :reverse
|
8
8
|
attr_accessor :quiet
|
9
|
+
attr_accessor :exclude_pull_requests
|
9
10
|
|
10
11
|
def options
|
11
12
|
OptionParser.new do |opts|
|
@@ -35,6 +36,7 @@ module GHI
|
|
35
36
|
opts.on '--reverse', 'reverse (ascending) sort order' do
|
36
37
|
self.reverse = !reverse
|
37
38
|
end
|
39
|
+
opts.on('-p', '--no-pulls','exclude pull requests') { self.exclude_pull_requests = true }
|
38
40
|
opts.on(
|
39
41
|
'--since <date>', 'issues more recent than',
|
40
42
|
"e.g., '2011-04-30'"
|
@@ -68,7 +70,7 @@ module GHI
|
|
68
70
|
opts.on(
|
69
71
|
'-u', '--[no-]assignee [<user>]', 'assigned to specified user'
|
70
72
|
) do |assignee|
|
71
|
-
assignee = assignee.sub /^@/, ''
|
73
|
+
assignee = assignee.sub /^@/, '' if assignee
|
72
74
|
assigns[:assignee] = any_or_none_or assignee
|
73
75
|
end
|
74
76
|
opts.on '--mine', 'assigned to you' do
|
@@ -113,6 +115,9 @@ module GHI
|
|
113
115
|
print "\r#{CURSOR[:up][1]}" if header && paginate?
|
114
116
|
page header do
|
115
117
|
issues = res.body
|
118
|
+
if exclude_pull_requests
|
119
|
+
issues = issues.reject {|i| i["pull_request"].any? {|k,v| !v.nil? } }
|
120
|
+
end
|
116
121
|
if verbose
|
117
122
|
puts issues.map { |i| format_issue i }
|
118
123
|
else
|
data/lib/ghi/commands/show.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module GHI
|
2
2
|
module Commands
|
3
3
|
class Show < Command
|
4
|
-
attr_accessor :web
|
4
|
+
attr_accessor :patch, :web
|
5
5
|
|
6
6
|
def options
|
7
7
|
OptionParser.new do |opts|
|
8
8
|
opts.banner = 'usage: ghi show <issueno>'
|
9
9
|
opts.separator ''
|
10
|
+
opts.on('-p', '--patch') { self.patch = true }
|
10
11
|
opts.on('-w', '--web') { self.web = true }
|
11
12
|
end
|
12
13
|
end
|
@@ -15,18 +16,27 @@ module GHI
|
|
15
16
|
require_issue
|
16
17
|
require_repo
|
17
18
|
options.parse! args
|
19
|
+
patch_path = "pull/#{issue}.patch" if patch # URI also in API...
|
18
20
|
if web
|
19
|
-
Web.new(repo).open "issues/#{issue}"
|
21
|
+
Web.new(repo).open patch_path || "issues/#{issue}"
|
20
22
|
else
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
if patch_path
|
24
|
+
i = throb { Web.new(repo).curl patch_path }
|
25
|
+
page do
|
26
|
+
puts i
|
27
|
+
break
|
28
|
+
end
|
29
|
+
else
|
30
|
+
i = throb { api.get "/repos/#{repo}/issues/#{issue}" }.body
|
31
|
+
page do
|
32
|
+
puts format_issue(i)
|
33
|
+
n = i['comments']
|
34
|
+
if n > 0
|
35
|
+
puts "#{n} comment#{'s' unless n == 1}:\n\n"
|
36
|
+
Comment.execute %W(-l #{issue} -- #{repo})
|
37
|
+
end
|
38
|
+
break
|
28
39
|
end
|
29
|
-
break
|
30
40
|
end
|
31
41
|
end
|
32
42
|
end
|
data/lib/ghi/commands/version.rb
CHANGED
data/lib/ghi/formatting.rb
CHANGED
@@ -31,11 +31,11 @@ module GHI
|
|
31
31
|
|
32
32
|
def puts *strings
|
33
33
|
strings = strings.flatten.map { |s|
|
34
|
-
s.gsub(
|
35
|
-
if $
|
36
|
-
bright { fg(:yellow) { "@#$
|
34
|
+
s.gsub(/(^| )*@([^@\s]+)/) {
|
35
|
+
if $2 == Authorization.username
|
36
|
+
bright { fg(:yellow) { "#$1@#$2" } }
|
37
37
|
else
|
38
|
-
bright { "@#$
|
38
|
+
bright { "#$1@#$2" }
|
39
39
|
end
|
40
40
|
}
|
41
41
|
}
|
data/lib/ghi/web.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'open-uri'
|
1
2
|
require 'uri'
|
2
3
|
|
3
4
|
module GHI
|
@@ -10,17 +11,21 @@ module GHI
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def open path = '', params = {}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
system "open '#{uri_for path, params}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def curl path = '', params = {}
|
18
|
+
uri_for(path, params).open.read
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
21
22
|
|
22
|
-
def
|
23
|
-
|
23
|
+
def uri_for path, params
|
24
|
+
unless params.empty?
|
25
|
+
q = params.map { |k, v| "#{CGI.escape k.to_s}=#{CGI.escape v.to_s}" }
|
26
|
+
path += "?#{q.join '&'}"
|
27
|
+
end
|
28
|
+
URI(BASE_URI) + "#{base}/" + path
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0.
|
4
|
+
version: 0.9.0.20121114
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|