git-review 0.6.6 → 0.6.7
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/git-review.rb +33 -27
- metadata +3 -3
data/lib/git-review.rb
CHANGED
@@ -7,21 +7,6 @@ class GitReview
|
|
7
7
|
|
8
8
|
## COMMANDS ##
|
9
9
|
|
10
|
-
# Default command to show a quick reference of available commands.
|
11
|
-
def help
|
12
|
-
puts 'Usage: git review <command>'
|
13
|
-
puts 'Manage review workflow for projects hosted on GitHub (using pull requests).'
|
14
|
-
puts
|
15
|
-
puts 'Available commands:'
|
16
|
-
puts ' list [--reverse] List all pending requests.'
|
17
|
-
puts ' show <number> [--full] Show details of a single request.'
|
18
|
-
puts ' browse <number> Open a browser window and review a specified request.'
|
19
|
-
puts ' checkout <number> Checkout a specified request\'s changes to your local repository.'
|
20
|
-
puts ' merge <number> Accept a specified request by merging it into master.'
|
21
|
-
puts ' close <number> Close a specified request.'
|
22
|
-
puts ' create Create a new request.'
|
23
|
-
end
|
24
|
-
|
25
10
|
# List all pending requests.
|
26
11
|
def list
|
27
12
|
@pending_requests.reverse! if @args.shift == '--reverse'
|
@@ -150,20 +135,36 @@ class GitReview
|
|
150
135
|
# Setup variables and call actual commands.
|
151
136
|
def initialize(args)
|
152
137
|
command = args.shift
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
138
|
+
if command and self.respond_to?(command)
|
139
|
+
@user, @repo = repo_info
|
140
|
+
return if @user.nil? or @repo.nil?
|
141
|
+
@args = args
|
142
|
+
return unless configure_github_access
|
157
143
|
update
|
158
144
|
self.send command
|
159
145
|
else
|
160
|
-
unless command.nil? or command.empty? or %w(-h --help).include?(command)
|
146
|
+
unless command.nil? or command.empty? or %w(help -h --help).include?(command)
|
161
147
|
puts "git-review: '#{command}' is not a valid command.\n\n"
|
162
148
|
end
|
163
149
|
help
|
164
150
|
end
|
165
151
|
end
|
166
152
|
|
153
|
+
# Show a quick reference of available commands.
|
154
|
+
def help
|
155
|
+
puts 'Usage: git review <command>'
|
156
|
+
puts 'Manage review workflow for projects hosted on GitHub (using pull requests).'
|
157
|
+
puts
|
158
|
+
puts 'Available commands:'
|
159
|
+
puts ' list [--reverse] List all pending requests.'
|
160
|
+
puts ' show <number> [--full] Show details of a single request.'
|
161
|
+
puts ' browse <number> Open a browser window and review a specified request.'
|
162
|
+
puts ' checkout <number> Checkout a specified request\'s changes to your local repository.'
|
163
|
+
puts ' merge <number> Accept a specified request by merging it into master.'
|
164
|
+
puts ' close <number> Close a specified request.'
|
165
|
+
puts ' create Create a new request.'
|
166
|
+
end
|
167
|
+
|
167
168
|
# Check existence of specified request and assign @pending_request.
|
168
169
|
def request_exists?(request_id = nil)
|
169
170
|
# NOTE: If request_id is set explicitly we might need to update to get the
|
@@ -246,16 +247,17 @@ class GitReview
|
|
246
247
|
|
247
248
|
# Checks '~/.gitconfig' for credentials and
|
248
249
|
def configure_github_access
|
249
|
-
if
|
250
|
+
if github_token.empty? or github_login.empty?
|
250
251
|
puts 'Please update your git config and provide your GitHub user name and token.'
|
251
252
|
puts 'Some commands won\'t work properly without these credentials.'
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
253
|
+
return false
|
254
|
+
end
|
255
|
+
Octokit.configure do |config|
|
256
|
+
config.login = github_login
|
257
|
+
config.token = github_token
|
258
|
+
config.endpoint = github_endpoint
|
258
259
|
end
|
260
|
+
true
|
259
261
|
end
|
260
262
|
|
261
263
|
# Get GitHub user name.
|
@@ -285,6 +287,10 @@ class GitReview
|
|
285
287
|
end
|
286
288
|
# Extract user and project name from GitHub URL.
|
287
289
|
url = config_hash['remote.origin.url']
|
290
|
+
if url.nil?
|
291
|
+
puts "Error: Not a git repository."
|
292
|
+
return [nil, nil]
|
293
|
+
end
|
288
294
|
user, project = github_user_and_project(url)
|
289
295
|
# If there are no results yet, look for 'insteadof' substitutions in URL and try again.
|
290
296
|
unless (user and project)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-review
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dominik Bamberger, Cristian Messel
|