ghn 2.0.0.pre4 → 2.0.0.pre5
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/README.md +11 -0
- data/lib/ghn/collector.rb +8 -5
- data/lib/ghn/commands.rb +13 -1
- data/lib/ghn/notification.rb +4 -3
- data/lib/ghn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6530b32dbc20799ac48e639138fe9581eb76b1b
|
4
|
+
data.tar.gz: 1e75ba2866a8a1bbfc9696892642bf8bff2108ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c04b79a4ff9798adc6b1081164f26546c7de2fbd69546d8d5cfb62372dace75243434733d7f11d5256fa42ce3b5bcf0cb2769d26b664c2ebadf03450f13df3c
|
7
|
+
data.tar.gz: d251d40c9d795ef9cc4862f92cc9c0fb5be798c35b0aa9a65f6ac49b4eeb54de5075b068cb2fdac556afd06cef5dd5d665672846fd8128f43c1443a3a43f5db9
|
data/README.md
CHANGED
@@ -50,6 +50,17 @@ Please set **ghn.token** to your `.gitconfig`.
|
|
50
50
|
|
51
51
|
You can also set access token via `GHN_ACCESS_TOKEN` environment variable.
|
52
52
|
|
53
|
+
## Follow issuecomment anchor
|
54
|
+
|
55
|
+
If you provide `--follow-issuecomment` option, or set git config `ghn.followissuecomment` to "yes", "on" or "true",
|
56
|
+
ghn follows #issuecomment- anchor URL as like GitHub's official notification link.
|
57
|
+
|
58
|
+
$ ghn open --follow-issuecomment
|
59
|
+
|
60
|
+
$ git config --global ghn.followissuecomment true
|
61
|
+
|
62
|
+
Commandline option overrides git config setting as well.
|
63
|
+
|
53
64
|
## Contributing
|
54
65
|
|
55
66
|
1. Fork it
|
data/lib/ghn/collector.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
class Ghn
|
2
2
|
class Collector
|
3
|
-
|
3
|
+
attr_reader :client, :repo_full_name, :follow_issuecomment
|
4
|
+
|
5
|
+
def initialize(client, repo_full_name = nil, follow_issuecomment = false)
|
4
6
|
@client = client
|
5
7
|
@repo_full_name = repo_full_name
|
8
|
+
@follow_issuecomment = follow_issuecomment
|
6
9
|
end
|
7
10
|
|
8
11
|
def collect(page = 1)
|
9
|
-
notifications = if
|
10
|
-
|
12
|
+
notifications = if repo_full_name
|
13
|
+
client.repo_notifications(repo_full_name, page: page)
|
11
14
|
else
|
12
|
-
|
15
|
+
client.notifications(page: page)
|
13
16
|
end
|
14
17
|
@count = notifications.count
|
15
18
|
notifications.map { |notification|
|
16
|
-
Notification.new(notification).type_class.new(notification).url
|
19
|
+
Notification.new(notification, follow_issuecomment).type_class.new(notification, follow_issuecomment).url
|
17
20
|
}.compact
|
18
21
|
end
|
19
22
|
|
data/lib/ghn/commands.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Ghn
|
2
2
|
class Commands < Thor
|
3
3
|
class_option :all, type: :boolean, aliases: '-a', desc: 'List/Open all unread notifications'
|
4
|
+
class_option :follow_issuecomment, type: :boolean, desc: 'Follow issuecomment anchor URL'
|
4
5
|
|
5
6
|
desc 'list NAME', 'List unread notifications'
|
6
7
|
def list(name = nil)
|
@@ -20,7 +21,7 @@ class Ghn
|
|
20
21
|
|
21
22
|
def collect(repo_full_name = nil)
|
22
23
|
threads = []
|
23
|
-
collector = Collector.new(client, repo_full_name)
|
24
|
+
collector = Collector.new(client, repo_full_name, follow_issuecomment?)
|
24
25
|
# Unfortunately, GitHub v3 Notifications API doesn't accept octokit's auto_paginate option
|
25
26
|
# because this API doesn't return Link header so far.
|
26
27
|
loop.with_index(1) do |_, page|
|
@@ -40,6 +41,17 @@ class Ghn
|
|
40
41
|
@aliases ||= Aliases.new
|
41
42
|
end
|
42
43
|
|
44
|
+
def follow_issuecomment?
|
45
|
+
val = (options['follow_issuecomment'] || `git config ghn.followissuecomment`.chomp).to_s
|
46
|
+
if val.empty?
|
47
|
+
false
|
48
|
+
elsif val.match(/off|no|false/i)
|
49
|
+
false
|
50
|
+
else
|
51
|
+
true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
43
55
|
def access_token
|
44
56
|
@access_token ||=
|
45
57
|
case
|
data/lib/ghn/notification.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
class Ghn
|
2
2
|
class Notification
|
3
|
-
attr_reader :notification
|
3
|
+
attr_reader :notification, :follow_issuecomment
|
4
4
|
|
5
|
-
def initialize(notification)
|
5
|
+
def initialize(notification, follow_issuecomment)
|
6
6
|
@notification = notification
|
7
|
+
@follow_issuecomment = follow_issuecomment
|
7
8
|
end
|
8
9
|
|
9
10
|
def type_class
|
@@ -14,7 +15,7 @@ class Ghn
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def url
|
17
|
-
if comment?
|
18
|
+
if follow_issuecomment && comment?
|
18
19
|
"https://github.com/#{repo_full_name}/#{type}/#{thread_number}#issuecomment-#{comment_number}"
|
19
20
|
else
|
20
21
|
"https://github.com/#{repo_full_name}/#{type}/#{thread_number}"
|
data/lib/ghn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kensuke Nagae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|