gub 0.1.3 → 0.1.4
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/gub/cli.rb +41 -13
- data/lib/gub/clients/github.rb +3 -0
- data/lib/gub/exceptions.rb +3 -0
- data/lib/gub/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c34013ffa3a6dd074cc20b2c444daa3d098ddd5
|
4
|
+
data.tar.gz: 2d9571b41254e697ba4a39580acd2f39c78b558b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a876cee97d4f8af56f9435949ca16e0ed689a59e3adef6c1515c81047693d291de4e56bd8bef15278e6ee66a7f7638e694830abbc61cdff4676c0075eeb2cc53
|
7
|
+
data.tar.gz: aff50cfb351cd7c96ac0fa226161daf7e60862355817c5840edeca5512c04389208b5f198458e218b28e81837f3bdf297df30f9cf01b122653b23ffe0076fd26
|
data/lib/gub/cli.rb
CHANGED
@@ -7,6 +7,8 @@ module Gub
|
|
7
7
|
class CLI < Thor
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
|
+
trap(:INT) { exit 1 }
|
11
|
+
|
10
12
|
default_task :help
|
11
13
|
|
12
14
|
desc 'repos', 'List Github repositories'
|
@@ -27,6 +29,8 @@ module Gub
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
puts table
|
32
|
+
rescue Gub::Unauthorized
|
33
|
+
reauthorize
|
30
34
|
end
|
31
35
|
|
32
36
|
desc 'issue [id]', 'Show a Github issue'
|
@@ -41,6 +45,8 @@ module Gub
|
|
41
45
|
rows << ['Description:', word_wrap(issue.body, line_width: 70)]
|
42
46
|
Gub.log.info "Hint: use 'gub start #{id}' to start working on this issue."
|
43
47
|
say table rows, ["Issue ##{id}:", issue.title]
|
48
|
+
rescue Gub::Unauthorized
|
49
|
+
reauthorize
|
44
50
|
end
|
45
51
|
|
46
52
|
desc 'issues', 'List Github issues'
|
@@ -49,18 +55,18 @@ module Gub
|
|
49
55
|
def issues
|
50
56
|
args = {}
|
51
57
|
repository = Gub::Repository.new
|
52
|
-
if options.mine
|
53
|
-
args[:assignee] = Gub.github.user.login
|
54
|
-
end
|
55
58
|
if options.all || repository.full_name.nil?
|
56
|
-
|
59
|
+
say "Listing all issues:"
|
57
60
|
issues = Gub.github.user_issues
|
58
61
|
else
|
62
|
+
if options.mine
|
63
|
+
args[:assignee] = Gub.github.user.login
|
64
|
+
end
|
59
65
|
if repository.has_issues?
|
60
|
-
|
66
|
+
say "Listing issues for #{repository.full_name}:"
|
61
67
|
else
|
62
|
-
|
63
|
-
|
68
|
+
say "Issues disabled #{repository.full_name}.", :yellow
|
69
|
+
say "Listing issues for #{repository.parent}:"
|
64
70
|
end
|
65
71
|
issues = repository.issues(args)
|
66
72
|
end
|
@@ -76,30 +82,32 @@ module Gub
|
|
76
82
|
rows << row
|
77
83
|
end
|
78
84
|
say table rows, ['ID', 'Title', 'Author', 'Assignee', 'Status']
|
79
|
-
|
80
|
-
|
85
|
+
say "Found #{issues.count} issue(s)."
|
86
|
+
say 'Hint: use "gub start" to start working on an issue.', :green
|
81
87
|
end
|
88
|
+
rescue Gub::Unauthorized
|
89
|
+
reauthorize
|
82
90
|
end
|
83
91
|
|
84
92
|
desc 'start [id]', 'Start working on a Github issue'
|
85
93
|
def start id
|
86
94
|
if id.nil?
|
87
|
-
|
88
|
-
exit 1
|
95
|
+
panic 'Issue ID required.'
|
89
96
|
else
|
90
97
|
repository = Repository.new
|
91
98
|
Gub.git.sync
|
92
99
|
repository.assign_issue id
|
93
100
|
Gub.git.checkout('-b', "issue-#{id}")
|
94
101
|
end
|
102
|
+
rescue Gub::Unauthorized
|
103
|
+
reauthorize
|
95
104
|
end
|
96
105
|
|
97
106
|
desc 'finish [id]', 'Finish working on a Github issue'
|
98
107
|
def finish id = nil
|
99
108
|
id ||= `git rev-parse --abbrev-ref HEAD`.split('-').last.to_s.chop
|
100
109
|
if id.nil?
|
101
|
-
|
102
|
-
exit 1
|
110
|
+
panic "Unable to guess issue ID from branch name. You might want to specify it explicitly."
|
103
111
|
else
|
104
112
|
repository = Repository.new
|
105
113
|
Gub.log.info 'Pushing branch...'
|
@@ -108,6 +116,8 @@ module Gub
|
|
108
116
|
repository.issue_pull_request(id)
|
109
117
|
Gub.git.checkout('master')
|
110
118
|
end
|
119
|
+
rescue Gub::Unauthorized
|
120
|
+
reauthorize
|
111
121
|
end
|
112
122
|
|
113
123
|
desc 'clone [repo]', 'Clone a Github repository'
|
@@ -123,18 +133,24 @@ module Gub
|
|
123
133
|
`cd #{repo.split('/').last}`
|
124
134
|
repository = Repository.new
|
125
135
|
repository.add_upstream
|
136
|
+
rescue Gub::Unauthorized
|
137
|
+
reauthorize
|
126
138
|
end
|
127
139
|
|
128
140
|
desc 'add_upstream', 'Add repo upstream'
|
129
141
|
def add_upstream
|
130
142
|
repository = Repository.new
|
131
143
|
repository.add_upstream
|
144
|
+
rescue Gub::Unauthorized
|
145
|
+
reauthorize
|
132
146
|
end
|
133
147
|
|
134
148
|
desc 'sync', 'Synchronize fork with upstream repository'
|
135
149
|
def sync
|
136
150
|
Gub.log.info 'Synchroizing with upstream...'
|
137
151
|
Gub.git.sync
|
152
|
+
rescue Gub::Unauthorized
|
153
|
+
reauthorize
|
138
154
|
end
|
139
155
|
|
140
156
|
desc 'info', 'Show current respository information'
|
@@ -142,6 +158,8 @@ module Gub
|
|
142
158
|
repo = Gub::Repository.new
|
143
159
|
say "Github repository: #{repo.full_name}"
|
144
160
|
say "Forked from: #{repo.parent}" if repo.parent
|
161
|
+
rescue Gub::Unauthorized
|
162
|
+
reauthorize
|
145
163
|
end
|
146
164
|
|
147
165
|
desc 'setup', 'Setup Gub for the first time'
|
@@ -161,6 +179,16 @@ module Gub
|
|
161
179
|
say Gub::VERSION
|
162
180
|
end
|
163
181
|
|
182
|
+
no_commands do
|
183
|
+
def reauthorize
|
184
|
+
say "Unable to find token. You might need to run 'gub setup'.", :red
|
185
|
+
end
|
186
|
+
|
187
|
+
def panic message
|
188
|
+
say message, :red
|
189
|
+
exit 1
|
190
|
+
end
|
191
|
+
end
|
164
192
|
|
165
193
|
private
|
166
194
|
def table rows, header = []
|
data/lib/gub/clients/github.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'octokit'
|
2
|
+
require 'gub/exceptions'
|
2
3
|
|
3
4
|
module Gub
|
4
5
|
class Github
|
@@ -14,6 +15,8 @@ module Gub
|
|
14
15
|
|
15
16
|
def method_missing meth, *args, &block
|
16
17
|
@connection.send(meth, *args, &block)
|
18
|
+
rescue Octokit::Unauthorized, Octokit::NotFound
|
19
|
+
raise Gub::Unauthorized
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
data/lib/gub/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Abdel-Wahab
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/gub/clients/git.rb
|
130
130
|
- lib/gub/clients/github.rb
|
131
131
|
- lib/gub/config.rb
|
132
|
+
- lib/gub/exceptions.rb
|
132
133
|
- lib/gub/extensions.rb
|
133
134
|
- lib/gub/logger.rb
|
134
135
|
- lib/gub/repository.rb
|