drone-builds 0.3.0 → 0.3.1
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/drone/builds/cli.rb +18 -10
- data/lib/drone/builds/version.rb +1 -1
- data/lib/drone/builds.rb +2 -2
- 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: 7669c5cd94aadf34b8c0ffc3abdec4bd96667a98
|
4
|
+
data.tar.gz: e19d1a73b9d8f02372816aabb9db20843b1ffb17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23bb8201340113d18b5f85948bcd3951ee83a65763403e538701c86a4fe51a9a0117e34f8097b33282d38de4426ec70b70e9b2853d7162d6de3d3ea0cd24e9d7
|
7
|
+
data.tar.gz: c7173aab373a38ded30d8a9ec9064ca1e5f5671ae5350ae3fd84de3ca9c0f813fb3c40886a9573188981d473218d699236ccb0ba24419c4e95f0609e331bf494
|
data/lib/drone/builds/cli.rb
CHANGED
@@ -15,31 +15,31 @@ class Drone::Builds::Cli < Thor
|
|
15
15
|
desc 'list', 'list last builds'
|
16
16
|
method_option :limit, type: :numeric, default: LIMIT, aliases: '-l', desc: 'number of builds shown'
|
17
17
|
method_option :pull, type: :numeric, aliases: '-p', desc: 'pull request ID on GitHub'
|
18
|
+
method_option :branch, type: :string, aliases: '-b', desc: 'builds on that branch'
|
18
19
|
def list
|
19
|
-
|
20
|
+
ref = self.class.options_to_ref(options)
|
20
21
|
|
21
|
-
builds = self.class.parser.parse_builds(self.class.client.list(limit: limit))
|
22
|
+
builds = self.class.parser.parse_builds(self.class.client.list(limit: options[:limit], ref: ref))
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
puts self.class.parser.table(builds.last(options[:limit]], %i[id status ref message])
|
24
|
+
puts self.class.parser.table(builds, %i[id status ref message])
|
26
25
|
end
|
27
26
|
|
28
27
|
desc 'show', 'show a build'
|
29
28
|
method_option :filter, type: :string, aliases: '-f', desc: 'filter builds output lines'
|
30
29
|
method_option :context, type: :numeric, aliases: '-c', desc: 'number of lines after filter match'
|
31
30
|
method_option :last, type: :numeric, default: 1, aliases: '-l', desc: 'show nth last build'
|
31
|
+
method_option :pull, type: :numeric, aliases: '-p', desc: 'show last build from pull request ID'
|
32
|
+
method_option :branch, type: :string, aliases: '-b', desc: 'builds on that branch'
|
32
33
|
def show(id = nil)
|
33
|
-
|
34
|
-
last = self.class.client.list(limit: options[:last].abs)[0]
|
35
|
-
id = last['id'] if last
|
36
|
-
end
|
34
|
+
ref = self.class.options_to_ref(options)
|
37
35
|
|
38
|
-
|
36
|
+
id = self.class.client.list(limit: options[:last].abs, ref: ref)[0]['id'] if id.to_i.to_s != id
|
39
37
|
|
40
38
|
self.class.client.show(id, filter: options[:filter], context: options[:context]) do |line|
|
41
39
|
puts line
|
42
40
|
end
|
41
|
+
rescue
|
42
|
+
abort "No build found for options: #{options}"
|
43
43
|
end
|
44
44
|
|
45
45
|
desc 'version', 'version used'
|
@@ -63,4 +63,12 @@ class Drone::Builds::Cli < Thor
|
|
63
63
|
job_id: HOME_ENV[:DRONECI_JOB_ID]
|
64
64
|
)
|
65
65
|
end
|
66
|
+
|
67
|
+
|
68
|
+
def self.options_to_ref(options)
|
69
|
+
ref = nil
|
70
|
+
ref = "refs/heads/#{options[:branch]}" if options[:branch]
|
71
|
+
ref = "refs/pull/#{options[:pull]}/head" if options[:pull]
|
72
|
+
ref
|
73
|
+
end
|
66
74
|
end
|
data/lib/drone/builds/version.rb
CHANGED
data/lib/drone/builds.rb
CHANGED
@@ -20,8 +20,8 @@ module Drone
|
|
20
20
|
@protocol = protocol || 'http'
|
21
21
|
end
|
22
22
|
|
23
|
-
def list(limit: nil)
|
24
|
-
json_api(builds_url).first(limit || DEFAULT_LIMIT).reverse
|
23
|
+
def list(limit: nil, ref: nil)
|
24
|
+
json_api(builds_url).select { |b| !ref || b["ref"] == ref }.first(limit || DEFAULT_LIMIT).reverse
|
25
25
|
end
|
26
26
|
|
27
27
|
def show(id, filter: nil, context: nil)
|