gerrit 0.3.0 → 0.4.0
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/gerrit/command/push.rb +53 -13
- data/lib/gerrit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d050a0ac17abfa314ecaa5b6fd07037499f8e471
|
4
|
+
data.tar.gz: 72446d0641f5ed8ca4e4963234b126166e01f36a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dd2197c2035696ea52a8cf13595b88ecdcbaabeb2dfede9d60299f11d3097b54bf7e3ae7843d3dae75984433c0dd4b6b1f4bbc66384369c3f82af3fa62bcbb0
|
7
|
+
data.tar.gz: 6b403e7c5c7dae06f10734d94a8de8a681f484f701946634b042b8c8ca71586e33e85b90b6267c7bc472655d956642a25a4baad72b6355d986d78edf0c09ef99
|
data/lib/gerrit/command/push.rb
CHANGED
@@ -10,19 +10,34 @@ module Gerrit::Command
|
|
10
10
|
if commit_hash?(arguments[1]) || arguments[1] == 'HEAD'
|
11
11
|
ref = arguments[1]
|
12
12
|
reviewer_args = arguments[2..-1] || []
|
13
|
-
target_branch = 'master'
|
14
13
|
type = 'publish'
|
15
14
|
topic = nil
|
15
|
+
target_branch = 'master'
|
16
16
|
else
|
17
17
|
ref = 'HEAD'
|
18
18
|
reviewer_args = arguments[1..-1] || []
|
19
|
-
target_branch = ask_target_branch
|
20
19
|
type = ask_review_type
|
21
20
|
topic = ask_topic
|
21
|
+
target_branch = ask_target_branch
|
22
22
|
end
|
23
23
|
|
24
24
|
reviewers = extract_reviewers(reviewer_args)
|
25
25
|
|
26
|
+
if reviewers.size > 3
|
27
|
+
ui.newline
|
28
|
+
ui.info("You are adding #{reviewers.size} people as reviewers for this change")
|
29
|
+
|
30
|
+
reviewers.each do |username|
|
31
|
+
ui.print username
|
32
|
+
end
|
33
|
+
|
34
|
+
until %w[y n].include?(ui.ask('Is this ok? (y/n) ')
|
35
|
+
.argument(:required)
|
36
|
+
.modify(:downcase)
|
37
|
+
.read_string)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
26
41
|
push_changes(remote_url, ref, reviewers, target_branch, type, topic)
|
27
42
|
end
|
28
43
|
|
@@ -56,7 +71,7 @@ module Gerrit::Command
|
|
56
71
|
|
57
72
|
def extract_reviewers(reviewer_args)
|
58
73
|
if reviewer_args.empty?
|
59
|
-
reviewer_args = ui.ask('Enter users/groups you would like to review your changes')
|
74
|
+
reviewer_args = ui.ask('Enter users/groups you would like to review your changes: ')
|
60
75
|
.argument(:required)
|
61
76
|
.read_string
|
62
77
|
.split(/\s*,\s*/)
|
@@ -64,15 +79,21 @@ module Gerrit::Command
|
|
64
79
|
|
65
80
|
return [] if reviewer_args.empty?
|
66
81
|
|
67
|
-
|
68
|
-
extract_users(reviewer_args)
|
69
|
-
end
|
82
|
+
extract_users(reviewer_args)
|
70
83
|
end
|
71
84
|
|
72
85
|
def extract_users(reviewer_args)
|
73
86
|
usernames = []
|
74
|
-
groups =
|
75
|
-
users =
|
87
|
+
groups = nil
|
88
|
+
users = nil
|
89
|
+
|
90
|
+
# HACK: We wrap these slow calls in a spinner since other parts of this
|
91
|
+
# helper can prompt for input, which doesn't play well with the spinner
|
92
|
+
# animation.
|
93
|
+
ui.spinner('Finding matching users/groups...') do
|
94
|
+
groups = client.groups
|
95
|
+
users = client.users
|
96
|
+
end
|
76
97
|
|
77
98
|
reviewer_args.each do |arg|
|
78
99
|
users_or_groups = arg.split(/\s*,\s*|\s+/)
|
@@ -91,7 +112,27 @@ module Gerrit::Command
|
|
91
112
|
# Don't scan users since we already matched a group
|
92
113
|
return group_users if group_users.any?
|
93
114
|
|
94
|
-
users.grep(/#{pattern}/i)
|
115
|
+
matching_users = users.grep(/#{pattern}/i)
|
116
|
+
|
117
|
+
# If more than one match for an individual user, confirm which one.
|
118
|
+
if matching_users.size >= 2
|
119
|
+
ui.info("Multiple users match the pattern '#{pattern}':")
|
120
|
+
matching_users.each_with_index do |username, index|
|
121
|
+
ui.print "#{index + 1}. #{username}"
|
122
|
+
end
|
123
|
+
|
124
|
+
while matching_users.size >= 2
|
125
|
+
index = ui.ask('Enter the number of the user you meant: ')
|
126
|
+
.argument(:required)
|
127
|
+
.read_int
|
128
|
+
|
129
|
+
if index > 0 && index <= matching_users.size
|
130
|
+
matching_users = [matching_users[index - 1]]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
matching_users
|
95
136
|
end
|
96
137
|
|
97
138
|
def users_from_group(groups, group)
|
@@ -103,7 +144,7 @@ module Gerrit::Command
|
|
103
144
|
end
|
104
145
|
|
105
146
|
def ask_target_branch
|
106
|
-
target = ui.ask('Target branch
|
147
|
+
target = ui.ask('Target branch [master] ')
|
107
148
|
.modify(:trim)
|
108
149
|
.read_string
|
109
150
|
|
@@ -111,7 +152,7 @@ module Gerrit::Command
|
|
111
152
|
end
|
112
153
|
|
113
154
|
def ask_review_type
|
114
|
-
draft = ui.ask('Are you pushing this as a draft? (y/n) [n]')
|
155
|
+
draft = ui.ask('Are you pushing this as a draft? (y/n) [n] ')
|
115
156
|
.argument(:required)
|
116
157
|
.default('n')
|
117
158
|
.modify(:downcase)
|
@@ -121,13 +162,12 @@ module Gerrit::Command
|
|
121
162
|
end
|
122
163
|
|
123
164
|
def ask_topic
|
124
|
-
topic = ui.ask('
|
165
|
+
topic = ui.ask('Enter topic name (optional; enter * to use current branch name) ')
|
125
166
|
.argument(:optional)
|
126
167
|
.read_string
|
127
168
|
|
128
169
|
topic = repo.branch('HEAD') if topic == '*'
|
129
170
|
topic.strip.empty? ? nil : topic
|
130
171
|
end
|
131
|
-
|
132
172
|
end
|
133
173
|
end
|
data/lib/gerrit/version.rb
CHANGED