hull 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hull/command.rb +18 -4
- data/lib/hull/list.rb +6 -5
- metadata +5 -5
data/lib/hull/command.rb
CHANGED
@@ -42,6 +42,16 @@ module Hull
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def validate_config
|
46
|
+
if username == '' || api_token == ''
|
47
|
+
error('github.user and github.token not found in git config')
|
48
|
+
Help.new
|
49
|
+
false
|
50
|
+
else
|
51
|
+
true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
45
55
|
def username
|
46
56
|
@username ||= repo.config['github.user']
|
47
57
|
end
|
@@ -50,10 +60,14 @@ module Hull
|
|
50
60
|
@api_token ||= repo.config['github.token']
|
51
61
|
end
|
52
62
|
|
63
|
+
def remote_name
|
64
|
+
@remote_name ||= repo.config['hull.remote'] || 'origin'
|
65
|
+
end
|
66
|
+
|
53
67
|
def github_url
|
54
68
|
@github_url ||=
|
55
69
|
begin
|
56
|
-
_, owner, project = repo.config[
|
70
|
+
_, owner, project = repo.config["remote.#{remote}.url"].match(/^git@github.com:([^\/]*)\/(.*)(\.git)?/).to_a
|
57
71
|
"https://github.com/api/v2/json/pulls/#{owner}/#{project}"
|
58
72
|
end
|
59
73
|
end
|
@@ -61,7 +75,7 @@ module Hull
|
|
61
75
|
def repo
|
62
76
|
@repo ||= Grit::Repo.new(".")
|
63
77
|
unless valid_repository?(@repo)
|
64
|
-
raise InvalidRepository.new(
|
78
|
+
raise InvalidRepository.new("#{remote} must be a GitHub repository")
|
65
79
|
end
|
66
80
|
@repo
|
67
81
|
end
|
@@ -77,8 +91,8 @@ module Hull
|
|
77
91
|
end
|
78
92
|
|
79
93
|
def valid_repository?(repository)
|
80
|
-
repository.remote_list.include?(
|
81
|
-
repository.config[
|
94
|
+
repository.remote_list.include?(remote) &&
|
95
|
+
repository.config["remote.#{remote}.url"].match(/^git@github.com:/)
|
82
96
|
end
|
83
97
|
end
|
84
98
|
|
data/lib/hull/list.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Hull
|
2
2
|
class List < Command
|
3
3
|
def initialize
|
4
|
+
validate_config
|
4
5
|
json = get_json(github_url)
|
5
6
|
if json['error'].to_s != ''
|
6
7
|
return error("Pull request ##{request_number} might not exist.")
|
@@ -11,8 +12,8 @@ module Hull
|
|
11
12
|
return if pulls.length == 0
|
12
13
|
|
13
14
|
branch_names = pulls.map { |pull| pull['head']['label'].split(/:/) }
|
14
|
-
repo_len = [ branch_names.map(&:first).map(&:length).max, 15 ].min
|
15
|
-
branch_len = [ branch_names.map(&:last).map(&:length).max, 30 ].min
|
15
|
+
@repo_len = [ branch_names.map(&:first).map(&:length).max, 15 ].min
|
16
|
+
@branch_len = [ branch_names.map(&:last).map(&:length).max, 30 ].min
|
16
17
|
|
17
18
|
pulls.each do |pull|
|
18
19
|
puts pull_info(pull)
|
@@ -38,9 +39,9 @@ module Hull
|
|
38
39
|
end
|
39
40
|
|
40
41
|
number = pad_left(number, 6)
|
41
|
-
title = pad_right(title, column_size - repo_len - branch_len - 10)
|
42
|
-
repo_name = pad_left(repo_name, repo_len)
|
43
|
-
branch_name = pad_right(branch_name, branch_len)
|
42
|
+
title = pad_right(title, column_size - @repo_len - @branch_len - 10)
|
43
|
+
repo_name = pad_left(repo_name, @repo_len)
|
44
|
+
branch_name = pad_right(branch_name, @branch_len)
|
44
45
|
|
45
46
|
[
|
46
47
|
write(number, color),
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hull
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-20 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &70268322637340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70268322637340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: grit
|
27
|
-
requirement: &
|
27
|
+
requirement: &70268322636900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70268322636900
|
36
36
|
description: Code Review helper using GitHub's Pull Requests
|
37
37
|
email: hc5duke@gmail.com
|
38
38
|
executables:
|