gerrit 0.2.0 → 0.3.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/cli.rb +2 -2
- data/lib/gerrit/client.rb +9 -0
- data/lib/gerrit/command/console.rb +11 -0
- data/lib/gerrit/command/list.rb +67 -0
- data/lib/gerrit/ui.rb +1 -1
- data/lib/gerrit/utils.rb +21 -0
- data/lib/gerrit/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c14a9161708725543c0375055c068e864a8e0d00
|
4
|
+
data.tar.gz: 1aab149820844fe5cebae082f3f77bd728062b65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f44d2871bc42bf4dee823f3ee878fc8c01657e0a942d10b2a12f92f521b2c81cf3e82cd127317996ff20f94e2f6b8b059a4cf4d95fd97c1b360d6d91407fff0f
|
7
|
+
data.tar.gz: 0d7d9d5fd9631a66ad805e452570ac917a8e03cb90f8062aa39e99bcbd95d4a97027147d147345ca5c0e9c0c6a0de5fad19b3275072e67eeeadcc5c71e2205c7
|
data/lib/gerrit/cli.rb
CHANGED
@@ -44,8 +44,8 @@ module Gerrit
|
|
44
44
|
# @param arguments [Array<String>]
|
45
45
|
# @raise [Gerrit::Errors::GerritError] when any exceptional circumstance occurs
|
46
46
|
def run_command(config, arguments)
|
47
|
-
# Display
|
48
|
-
arguments = ['
|
47
|
+
# Display all open changes by default
|
48
|
+
arguments = ['list'] if arguments.empty?
|
49
49
|
|
50
50
|
command_class = find_command(arguments)
|
51
51
|
command_class.new(config, @ui, arguments).run
|
data/lib/gerrit/client.rb
CHANGED
@@ -70,6 +70,15 @@ module Gerrit
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
def query_changes(query)
|
74
|
+
rows = execute(%W[query
|
75
|
+
--format=JSON
|
76
|
+
--current-patch-set
|
77
|
+
--submit-records] + [query]).split("\n")[0..-2]
|
78
|
+
|
79
|
+
rows.map { |row| JSON.parse(row) }
|
80
|
+
end
|
81
|
+
|
73
82
|
# Returns a list of all users to include in the default search scope.
|
74
83
|
#
|
75
84
|
# Gerrit doesn't actually have an endpoint to return all visible users, so
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Gerrit::Command
|
2
|
+
# Open console for playing around with helpers exposed to other commands.
|
3
|
+
#
|
4
|
+
# This is intended to be used to aid in building and debugging commands.
|
5
|
+
class Console < Base
|
6
|
+
def execute
|
7
|
+
require 'pry'
|
8
|
+
binding.pry
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Gerrit::Command
|
2
|
+
# Show a list of changes matching a specified query.
|
3
|
+
class List < Base
|
4
|
+
def execute
|
5
|
+
# Get changes ordered from newest to oldest
|
6
|
+
changes =
|
7
|
+
ui.spinner('Loading ') do
|
8
|
+
client.query_changes(query).sort_by { |change| -change['lastUpdated'] }
|
9
|
+
end
|
10
|
+
|
11
|
+
# Display changes in reverse order so that the newest are at the bottom of
|
12
|
+
# the table (i.e. the part that will be visible in a console when there is
|
13
|
+
# a long list)
|
14
|
+
ui.table(header: %w[# CR V Subject Owner Project Updated],
|
15
|
+
alignments: [:left, :center, :center, :left, :left, :left, :right],
|
16
|
+
padding: [0,1,0,1]) do |t|
|
17
|
+
changes.each_with_index.map do |change, index|
|
18
|
+
[
|
19
|
+
index + 1,
|
20
|
+
symbol_for_status('Code-Review', change),
|
21
|
+
symbol_for_status('Verified', change),
|
22
|
+
change['subject'],
|
23
|
+
change['owner']['name'],
|
24
|
+
change['project'],
|
25
|
+
human_time(Time.at(change['lastUpdated'])),
|
26
|
+
]
|
27
|
+
end.reverse.each do |row|
|
28
|
+
t << row
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def query
|
36
|
+
if arguments[1]
|
37
|
+
arguments[1]
|
38
|
+
else
|
39
|
+
'status:open' # Show all open changes by default
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def label_status(label_name, change)
|
44
|
+
status = change.fetch('submitRecords', []).first
|
45
|
+
return unless status
|
46
|
+
|
47
|
+
label_status = status['labels'].find { |label| label['label'] == label_name }
|
48
|
+
return unless label_status
|
49
|
+
|
50
|
+
label_status['status']
|
51
|
+
end
|
52
|
+
|
53
|
+
def symbol_for_status(label_name, change)
|
54
|
+
p = Pastel.new
|
55
|
+
|
56
|
+
value = label_status(label_name, change)
|
57
|
+
case value
|
58
|
+
when 'REJECT'
|
59
|
+
p.red.bold('✕')
|
60
|
+
when 'OK'
|
61
|
+
p.green.bold('✓')
|
62
|
+
else
|
63
|
+
''
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/gerrit/ui.rb
CHANGED
data/lib/gerrit/utils.rb
CHANGED
@@ -23,6 +23,27 @@ module Gerrit
|
|
23
23
|
string =~ /^\h{7,40}$/
|
24
24
|
end
|
25
25
|
|
26
|
+
# Returns the given {Time} as a human-readable string based on that time
|
27
|
+
# relative to the current time.
|
28
|
+
#
|
29
|
+
# @param time [Time]
|
30
|
+
# @return [String]
|
31
|
+
def human_time(time)
|
32
|
+
date = time.to_date
|
33
|
+
|
34
|
+
if date == Date.today
|
35
|
+
time.strftime('%l:%M %p')
|
36
|
+
elsif date == Date.today - 1
|
37
|
+
'Yesterday'
|
38
|
+
elsif date > Date.today - 7
|
39
|
+
time.strftime('%A') # Sunday
|
40
|
+
elsif date.year == Date.today.year
|
41
|
+
time.strftime('%b %e') # Jun 22
|
42
|
+
else
|
43
|
+
time.strftime('%b %e, %Y') # Jun 22, 2015
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
26
47
|
# Executing a block on each item in parallel.
|
27
48
|
#
|
28
49
|
# @param items [Enumerable]
|
data/lib/gerrit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gerrit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: childprocess
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.10'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.10'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: tty
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,8 +80,10 @@ files:
|
|
66
80
|
- lib/gerrit/client.rb
|
67
81
|
- lib/gerrit/command/base.rb
|
68
82
|
- lib/gerrit/command/checkout.rb
|
83
|
+
- lib/gerrit/command/console.rb
|
69
84
|
- lib/gerrit/command/groups.rb
|
70
85
|
- lib/gerrit/command/help.rb
|
86
|
+
- lib/gerrit/command/list.rb
|
71
87
|
- lib/gerrit/command/members.rb
|
72
88
|
- lib/gerrit/command/projects.rb
|
73
89
|
- lib/gerrit/command/push.rb
|