travis 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +786 -86
- data/Rakefile +3 -0
- data/lib/travis/cli/api_command.rb +22 -0
- data/lib/travis/cli/command.rb +36 -15
- data/lib/travis/cli/console.rb +13 -0
- data/lib/travis/cli/disable.rb +13 -0
- data/lib/travis/cli/enable.rb +29 -0
- data/lib/travis/cli/encrypt.rb +17 -4
- data/lib/travis/cli/history.rb +43 -0
- data/lib/travis/cli/logs.rb +18 -0
- data/lib/travis/cli/open.rb +36 -0
- data/lib/travis/cli/parser.rb +3 -3
- data/lib/travis/cli/repo_command.rb +16 -1
- data/lib/travis/cli/restart.rb +14 -0
- data/lib/travis/cli/show.rb +50 -0
- data/lib/travis/cli/status.rb +17 -0
- data/lib/travis/cli/sync.rb +28 -0
- data/lib/travis/cli/whatsup.rb +16 -0
- data/lib/travis/cli.rb +11 -0
- data/lib/travis/client/artifact.rb +25 -0
- data/lib/travis/client/build.rb +41 -0
- data/lib/travis/client/commit.rb +26 -0
- data/lib/travis/client/entity.rb +47 -3
- data/lib/travis/client/job.rb +52 -0
- data/lib/travis/client/methods.rb +22 -1
- data/lib/travis/client/repository.rb +70 -5
- data/lib/travis/client/session.rb +40 -8
- data/lib/travis/client/states.rb +85 -0
- data/lib/travis/client/user.rb +6 -0
- data/lib/travis/client.rb +5 -0
- data/lib/travis/tools/formatter.rb +38 -0
- data/lib/travis/version.rb +1 -1
- data/spec/cli/encrypt_spec.rb +16 -1
- data/spec/cli/history_spec.rb +28 -0
- data/spec/cli/logs_spec.rb +8 -0
- data/spec/cli/open_spec.rb +33 -0
- data/spec/cli/restart_spec.rb +15 -0
- data/spec/cli/show_spec.rb +9 -0
- data/spec/cli/status_spec.rb +28 -0
- data/spec/client/build_spec.rb +31 -0
- data/spec/client/commit_spec.rb +18 -0
- data/spec/client/job_spec.rb +30 -0
- data/spec/client/repository_spec.rb +15 -0
- data/spec/client/session_spec.rb +4 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/support/fake_api.rb +616 -1
- data/travis.gemspec +37 -3
- metadata +66 -2
data/Rakefile
CHANGED
@@ -12,6 +12,13 @@ module Travis
|
|
12
12
|
on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c,_| c.api_endpoint = Travis::Client::ORG_URI }
|
13
13
|
on('-t', '--token [ACCESS_TOKEN]', 'access token to use') { |c, t| c.access_token = t }
|
14
14
|
|
15
|
+
on('--debug', 'show API requests') do |c,_|
|
16
|
+
c.session.instrument do |info, request|
|
17
|
+
c.debug(info)
|
18
|
+
request.call
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
15
22
|
def initialize(*)
|
16
23
|
@session = Travis::Client.new
|
17
24
|
super
|
@@ -44,6 +51,21 @@ module Travis
|
|
44
51
|
error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil?
|
45
52
|
end
|
46
53
|
|
54
|
+
def sync(block = true, dot = '.')
|
55
|
+
user.sync
|
56
|
+
|
57
|
+
steps = count = 1
|
58
|
+
while block and user.reload.syncing?
|
59
|
+
count += 1
|
60
|
+
sleep(1)
|
61
|
+
|
62
|
+
if count % steps == 0
|
63
|
+
steps = count/10 + 1
|
64
|
+
output.print dot
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
47
69
|
private
|
48
70
|
|
49
71
|
def detected_endpoint
|
data/lib/travis/cli/command.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'travis/cli'
|
2
|
+
require 'travis/tools/formatter'
|
3
|
+
|
2
4
|
require 'highline'
|
3
5
|
require 'forwardable'
|
4
6
|
require 'delegate'
|
@@ -11,13 +13,14 @@ module Travis
|
|
11
13
|
extend Forwardable
|
12
14
|
def_delegators :terminal, :agree, :ask, :choose
|
13
15
|
|
14
|
-
HighLine.use_color = !CLI.windows?
|
16
|
+
HighLine.use_color = !CLI.windows? && $stdin.tty?
|
15
17
|
HighLine.color_scheme = HighLine::ColorScheme.new do |cs|
|
16
18
|
cs[:command] = [ :bold ]
|
17
19
|
cs[:error] = [ :red ]
|
18
20
|
cs[:important] = [ :bold, :underline ]
|
19
21
|
cs[:success] = [ :green ]
|
20
22
|
cs[:info] = [ :yellow ]
|
23
|
+
cs[:debug] = [ :magenta ]
|
21
24
|
end
|
22
25
|
|
23
26
|
on('-h', '--help', 'Display help') do |c, _|
|
@@ -26,6 +29,7 @@ module Travis
|
|
26
29
|
end
|
27
30
|
|
28
31
|
on('-i', '--[no-]interactive', "be interactive and colorful") do |c, v|
|
32
|
+
HighLine.use_color = v unless CLI.windows?
|
29
33
|
c.force_interactive = v
|
30
34
|
end
|
31
35
|
|
@@ -48,12 +52,13 @@ module Travis
|
|
48
52
|
define_method(name) {}
|
49
53
|
end
|
50
54
|
|
51
|
-
attr_accessor :arguments, :config, :terminal, :force_interactive
|
55
|
+
attr_accessor :arguments, :config, :terminal, :force_interactive, :formatter
|
52
56
|
|
53
57
|
def initialize(options = {})
|
54
|
-
@
|
55
|
-
@
|
56
|
-
@
|
58
|
+
@formatter = Travis::Tools::Formatter.new
|
59
|
+
@output = SimpleDelegator.new($stdout)
|
60
|
+
@input = SimpleDelegator.new($stdin)
|
61
|
+
@terminal = HighLine.new(@input, @output)
|
57
62
|
options.each do |key, value|
|
58
63
|
public_send("#{key}=", value) if respond_to? "#{key}="
|
59
64
|
end
|
@@ -109,7 +114,7 @@ module Travis
|
|
109
114
|
end
|
110
115
|
|
111
116
|
def usage
|
112
|
-
usage = "#$0 #{command_name}
|
117
|
+
usage = "#$0 #{command_name}"
|
113
118
|
method = method(:run)
|
114
119
|
if method.respond_to? :parameters
|
115
120
|
method.parameters.each do |type, name|
|
@@ -117,9 +122,10 @@ module Travis
|
|
117
122
|
name = "[#{name}..]" if type == :rest
|
118
123
|
usage << " #{name}"
|
119
124
|
end
|
120
|
-
|
125
|
+
elsif method.arity != 0
|
121
126
|
usage << " ..."
|
122
127
|
end
|
128
|
+
usage << " [options]"
|
123
129
|
"Usage: " << color(usage, :command)
|
124
130
|
end
|
125
131
|
|
@@ -128,20 +134,31 @@ module Travis
|
|
128
134
|
parser.to_s
|
129
135
|
end
|
130
136
|
|
131
|
-
def say(data, format = nil)
|
132
|
-
|
133
|
-
|
137
|
+
def say(data, format = nil, style = nil)
|
138
|
+
terminal.say format(data, format, style)
|
139
|
+
end
|
140
|
+
|
141
|
+
def debug(line)
|
142
|
+
write_to($stderr) do
|
143
|
+
say color("** #{line}", :debug)
|
144
|
+
end
|
134
145
|
end
|
135
146
|
|
136
147
|
private
|
137
148
|
|
149
|
+
def format(data, format = nil, style = nil)
|
150
|
+
style ||= :important
|
151
|
+
data = format % color(data, style) if format and interactive?
|
152
|
+
data = data.gsub(/<\[\[/, '<%=').gsub(/\]\]>/, '%>')
|
153
|
+
end
|
154
|
+
|
138
155
|
def template(file)
|
139
156
|
File.read(file).split('__END__', 2)[1].strip
|
140
157
|
end
|
141
158
|
|
142
|
-
def color(line,
|
159
|
+
def color(line, style)
|
143
160
|
return line unless interactive?
|
144
|
-
terminal.color(line,
|
161
|
+
terminal.color(line, Array(style).map(&:to_sym))
|
145
162
|
end
|
146
163
|
|
147
164
|
def interactive?(io = output)
|
@@ -153,14 +170,18 @@ module Travis
|
|
153
170
|
say "\n"
|
154
171
|
end
|
155
172
|
|
156
|
-
def
|
173
|
+
def warn(message)
|
157
174
|
write_to($stderr) do
|
158
175
|
say color(message, :error)
|
159
176
|
yield if block_given?
|
160
|
-
exit 1
|
161
177
|
end
|
162
178
|
end
|
163
179
|
|
180
|
+
def error(message, &block)
|
181
|
+
warn(message, &block)
|
182
|
+
exit 1
|
183
|
+
end
|
184
|
+
|
164
185
|
def command(name)
|
165
186
|
color("#$0 #{name}", :command)
|
166
187
|
end
|
@@ -197,7 +218,7 @@ module Travis
|
|
197
218
|
return unless method.respond_to? :parameters
|
198
219
|
method.parameters.each do |type, name|
|
199
220
|
return if type == :rest
|
200
|
-
wrong_args("few") unless args.shift or type == :opt
|
221
|
+
wrong_args("few") unless args.shift or type == :opt or type == :block
|
201
222
|
end
|
202
223
|
wrong_args("many") if args.any?
|
203
224
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Enable < RepoCommand
|
6
|
+
on('-s', '--skip-sync', "don't trigger a sync if the repo is unknown")
|
7
|
+
|
8
|
+
def run
|
9
|
+
authenticate
|
10
|
+
repository.enable
|
11
|
+
say "enabled", color("#{slug}: %s :)", :success)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def repository
|
17
|
+
repo(slug)
|
18
|
+
rescue Travis::Client::NotFound
|
19
|
+
unless skip_sync?
|
20
|
+
say "repository not known to Travis CI (or no access?)"
|
21
|
+
say "triggering sync: "
|
22
|
+
sync
|
23
|
+
say " done"
|
24
|
+
end
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/travis/cli/encrypt.rb
CHANGED
@@ -11,7 +11,16 @@ module Travis
|
|
11
11
|
c.config_key = value || 'env.global'
|
12
12
|
end
|
13
13
|
|
14
|
+
on('-s', '--[no-]split', 'treat each line as a separate input')
|
15
|
+
|
14
16
|
def run(*args)
|
17
|
+
if args.first =~ %r{\w+/\w+}
|
18
|
+
warn "WARNING: The name of the repository is now passed to the command with the -r option:"
|
19
|
+
warn " #{command("encrypt [...] -r #{args.first}")}"
|
20
|
+
warn " If you tried to pass the name of the repository as the first argument, you"
|
21
|
+
warn " probably won't get the results you wanted.\n"
|
22
|
+
end
|
23
|
+
|
15
24
|
data = args.join(" ")
|
16
25
|
|
17
26
|
if data.empty?
|
@@ -19,17 +28,21 @@ module Travis
|
|
19
28
|
data = $stdin.read
|
20
29
|
end
|
21
30
|
|
22
|
-
|
31
|
+
data = split? ? data.split("\n") : [data]
|
32
|
+
encrypted = data.map { |data| repository.encrypt(data) }
|
23
33
|
|
24
34
|
if config_key
|
25
35
|
travis_config = YAML.load_file(travis_yaml)
|
26
36
|
keys = config_key.split('.')
|
27
37
|
last_key = keys.pop
|
28
38
|
nested_config = keys.inject(travis_config) { |c,k| c[k] ||= {}}
|
29
|
-
|
39
|
+
encrypted.each do |encrypted|
|
40
|
+
nested_config[last_key] ||= [] << { 'secure' => encrypted }
|
41
|
+
end
|
30
42
|
File.write(travis_yaml, travis_config.to_yaml)
|
31
43
|
else
|
32
|
-
|
44
|
+
list = encrypted.map { |data| format(data.inspect, " secure: %s") }
|
45
|
+
say(list.join("\n"), template(__FILE__), :none)
|
33
46
|
end
|
34
47
|
end
|
35
48
|
|
@@ -51,7 +64,7 @@ end
|
|
51
64
|
__END__
|
52
65
|
Please add the following to your <[[ color('.travis.yml', :info) ]]> file:
|
53
66
|
|
54
|
-
|
67
|
+
%s
|
55
68
|
|
56
69
|
Pro Tip<[[ "™" unless Travis::CLI.windows? ]]>: You can add it automatically by running with <[[ color('--add', :info) ]]>.
|
57
70
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class History < RepoCommand
|
6
|
+
on('-a', '--after BUILD', 'Only show history after a given build number')
|
7
|
+
on('-p', '--pull-request NUMBER', 'Only show history for the given Pull Request')
|
8
|
+
on('-b', '--branch BRANCH', 'Only show history for the given branch')
|
9
|
+
on('-l', '--limit LIMIT', 'Maximum number of history items')
|
10
|
+
on('--[no-]all', 'Display all history items')
|
11
|
+
|
12
|
+
def run
|
13
|
+
countdown = Integer(limit || 10) unless all?
|
14
|
+
params = { :after_number => after } if after
|
15
|
+
repository.each_build(params) do |build|
|
16
|
+
next unless display? build
|
17
|
+
display(build)
|
18
|
+
|
19
|
+
if countdown
|
20
|
+
countdown -= 1
|
21
|
+
break if countdown < 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def display?(build)
|
29
|
+
return build.pr_number == pull_request if pull_request
|
30
|
+
return build.branch_info == branch if branch
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def display(build)
|
35
|
+
say [
|
36
|
+
color("##{build.number} #{build.state}:".ljust(14), [build.color, :bold]),
|
37
|
+
color("#{build.branch_info} ", :info),
|
38
|
+
build.commit.subject
|
39
|
+
].join
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Logs < RepoCommand
|
6
|
+
def run(number = last_build.number)
|
7
|
+
error "##{number} is not a job" unless job = job(number)
|
8
|
+
say log(job)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def log(job)
|
14
|
+
interactive? ? job.log.colorized_body : job.log.clean_body
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
require 'launchy'
|
3
|
+
|
4
|
+
module Travis
|
5
|
+
module CLI
|
6
|
+
class Open < RepoCommand
|
7
|
+
on('-g', '--github', 'Open the corresponding project, compare view or pull request on GitHub')
|
8
|
+
on('-p', '--print', 'Print out the URL instead of opening it in a browser')
|
9
|
+
|
10
|
+
def run(number = nil)
|
11
|
+
url = url_for(number)
|
12
|
+
if print?
|
13
|
+
say url, "web view: %s"
|
14
|
+
else
|
15
|
+
Launchy.open(url)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def url_for(number)
|
22
|
+
return repo_url unless number
|
23
|
+
entity = job(number) || build(number)
|
24
|
+
github ? entity.commit.compare_url : "#{repo_url}/#{entity.class.many}/#{entity.id}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def repo_url
|
28
|
+
"https://#{host}/#{slug}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def host
|
32
|
+
github ? "github.com" : session.config['host']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/travis/cli/parser.rb
CHANGED
@@ -18,9 +18,9 @@ module Travis
|
|
18
18
|
block ||= begin
|
19
19
|
full_arg = args.detect { |a| a.start_with? '--' }
|
20
20
|
name = full_arg.gsub(/^--(\[no-\])?(\S+).*$/, '\2').gsub('-', '_')
|
21
|
-
attr_reader(name)
|
22
|
-
attr_writer(name)
|
23
|
-
alias_method("#{name}?", name)
|
21
|
+
attr_reader(name) unless method_defined? name
|
22
|
+
attr_writer(name) unless method_defined? "#{name}="
|
23
|
+
alias_method("#{name}?", name) unless method_defined? "#{name}?"
|
24
24
|
proc { |instance, value| instance.public_send("#{name}=", value) }
|
25
25
|
end
|
26
26
|
|
@@ -13,16 +13,31 @@ module Travis
|
|
13
13
|
error "Can't figure out GitHub repo name. Are you in the right directory?" unless self.slug ||= find_slug
|
14
14
|
self.api_endpoint = detect_api_endpoint
|
15
15
|
super
|
16
|
+
repository.load # makes sure we actually have access to the repo
|
16
17
|
end
|
17
18
|
|
18
19
|
def repository
|
19
20
|
repo(slug)
|
20
21
|
rescue Travis::Client::NotFound
|
21
|
-
error "repository not known to
|
22
|
+
error "repository not known to #{api_endpoint}: #{color(slug, :important)}"
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
25
26
|
|
27
|
+
def build(number_or_id)
|
28
|
+
return super if number_or_id.is_a? Integer
|
29
|
+
repository.build(number_or_id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def job(number_or_id)
|
33
|
+
return super if number_or_id.is_a? Integer
|
34
|
+
repository.job(number_or_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
def last_build
|
38
|
+
repository.last_build or error("no build yet for #{slug}")
|
39
|
+
end
|
40
|
+
|
26
41
|
def detected_endpoint?
|
27
42
|
!explicit_api_endpoint?
|
28
43
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Restart < RepoCommand
|
6
|
+
def run(number = last_build.number)
|
7
|
+
entity = job(number) || build(number)
|
8
|
+
entity.restart
|
9
|
+
|
10
|
+
say "restarted", "#{entity.class.one} ##{entity.number} has been %s"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Show < RepoCommand
|
6
|
+
def run(number = last_build.number)
|
7
|
+
entity = job(number) || build(number)
|
8
|
+
|
9
|
+
say template(__FILE__) % [
|
10
|
+
entity.class.one.capitalize,
|
11
|
+
entity.number,
|
12
|
+
entity.commit.subject,
|
13
|
+
entity.state,
|
14
|
+
entity.color,
|
15
|
+
entity.pull_request? ? "pull request" : "push",
|
16
|
+
entity.commit.compare_url,
|
17
|
+
formatter.duration(entity.duration),
|
18
|
+
formatter.time(entity.started_at),
|
19
|
+
formatter.time(entity.finished_at)
|
20
|
+
]
|
21
|
+
|
22
|
+
if entity.respond_to? :jobs
|
23
|
+
empty_line
|
24
|
+
entity.jobs.each do |job|
|
25
|
+
say [
|
26
|
+
color("##{job.number} #{job.state}:".ljust(16), [job.color, :bold]),
|
27
|
+
formatter.duration(job.duration).ljust(14),
|
28
|
+
formatter.job_config(job.config),
|
29
|
+
(color("(failure allowed)", :info) if job.allow_failures?)
|
30
|
+
].compact.join(" ").rstrip
|
31
|
+
end
|
32
|
+
else
|
33
|
+
config = formatter.job_config(entity.config)
|
34
|
+
say color("Allow Failure: ", :info) + entity.allow_failures?.inspect
|
35
|
+
say color("Config: ", :info) + config unless config.empty?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
__END__
|
43
|
+
|
44
|
+
<[[ color("%s #%s: %s", :bold) ]]>
|
45
|
+
<[[ color("State: ", :info) ]]><[[ color(%p, :%s) ]]>
|
46
|
+
<[[ color("Type: ", :info) ]]>%s
|
47
|
+
<[[ color("Compare URL: ", :info) ]]>%s
|
48
|
+
<[[ color("Duration: ", :info) ]]>%s
|
49
|
+
<[[ color("Started: ", :info) ]]>%s
|
50
|
+
<[[ color("Finished: ", :info) ]]>%s
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Status < RepoCommand
|
6
|
+
on '-x', '--[no-]exit-code', 'sets the exit code to 1 if the build failed'
|
7
|
+
on '-q', '--[no-]quiet', 'does not print anything'
|
8
|
+
on '-p', '--[no-]fail-pending', 'sets the status code to 1 if the build is pending'
|
9
|
+
|
10
|
+
def run
|
11
|
+
say color(last_build.state, last_build.color), "build ##{last_build.number} %s" unless quiet?
|
12
|
+
exit 1 if exit_code? and last_build.unsuccessful?
|
13
|
+
exit 1 if fail_pending? and last_build.pending?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Sync < ApiCommand
|
6
|
+
on '-c', '--check', 'only check the sync status'
|
7
|
+
on '-b', '--background', 'will trigger sync but not block until sync is done'
|
8
|
+
on '-f', '--force', 'will force sync, even if one is already running'
|
9
|
+
|
10
|
+
def run
|
11
|
+
authenticate
|
12
|
+
|
13
|
+
if check?
|
14
|
+
say "#{"not " unless user.syncing?}syncing", "#{user.login} is currently %s"
|
15
|
+
elsif user.syncing? and not force?
|
16
|
+
error "user is already syncing"
|
17
|
+
elsif background?
|
18
|
+
say "starting synchronization"
|
19
|
+
sync(false)
|
20
|
+
else
|
21
|
+
say "synchronizing: "
|
22
|
+
sync
|
23
|
+
say color(" done", :success)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'travis/cli'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module CLI
|
5
|
+
class Whatsup < ApiCommand
|
6
|
+
def run
|
7
|
+
repos.each do |repo|
|
8
|
+
say [
|
9
|
+
color(repo.slug, [:bold, repo.color]),
|
10
|
+
color("#{repo.last_build.state}: ##{repo.last_build.number}", repo.color)
|
11
|
+
].join(" ")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/travis/cli.rb
CHANGED
@@ -16,14 +16,25 @@ module Travis
|
|
16
16
|
module CLI
|
17
17
|
autoload :ApiCommand, 'travis/cli/api_command'
|
18
18
|
autoload :Command, 'travis/cli/command'
|
19
|
+
autoload :Console, 'travis/cli/console'
|
20
|
+
autoload :Disable, 'travis/cli/disable'
|
21
|
+
autoload :Enable, 'travis/cli/enable'
|
19
22
|
autoload :Encrypt, 'travis/cli/encrypt'
|
20
23
|
autoload :Endpoint, 'travis/cli/endpoint'
|
21
24
|
autoload :Help, 'travis/cli/help'
|
25
|
+
autoload :History, 'travis/cli/history'
|
22
26
|
autoload :Login, 'travis/cli/login'
|
27
|
+
autoload :Logs, 'travis/cli/logs'
|
28
|
+
autoload :Open, 'travis/cli/open'
|
23
29
|
autoload :Parser, 'travis/cli/parser'
|
24
30
|
autoload :Raw, 'travis/cli/raw'
|
25
31
|
autoload :RepoCommand, 'travis/cli/repo_command'
|
32
|
+
autoload :Restart, 'travis/cli/restart'
|
33
|
+
autoload :Show, 'travis/cli/show'
|
34
|
+
autoload :Status, 'travis/cli/status'
|
35
|
+
autoload :Sync, 'travis/cli/sync'
|
26
36
|
autoload :Version, 'travis/cli/version'
|
37
|
+
autoload :Whatsup, 'travis/cli/whatsup'
|
27
38
|
autoload :Whoami, 'travis/cli/whoami'
|
28
39
|
|
29
40
|
extend self
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'travis/client'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module Client
|
5
|
+
class Artifact < Entity
|
6
|
+
# @!parse attr_reader :job_id, :type, :body
|
7
|
+
attributes :job_id, :type, :body
|
8
|
+
|
9
|
+
# @!parse attr_reader :job
|
10
|
+
has :job
|
11
|
+
|
12
|
+
def colorized_body
|
13
|
+
attributes['colorized_body'] ||= body.gsub(/[^[:print:]\e\n]/, '')
|
14
|
+
end
|
15
|
+
|
16
|
+
def clean_body
|
17
|
+
attributes['clean_body'] ||= colorized_body.gsub(/\e[^m]+m/, '')
|
18
|
+
end
|
19
|
+
|
20
|
+
one :artifact
|
21
|
+
many :artifacts
|
22
|
+
aka :log
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'travis/client'
|
2
|
+
|
3
|
+
module Travis
|
4
|
+
module Client
|
5
|
+
class Build < Entity
|
6
|
+
include States
|
7
|
+
|
8
|
+
# @!parse attr_reader :repository_id, :commit_id, :number, :pull_request, :config, :state, :started_at, :finished_at, :duration, :job_ids
|
9
|
+
attributes :repository_id, :commit_id, :number, :pull_request, :config, :state, :started_at, :finished_at, :duration, :job_ids
|
10
|
+
time :started_at, :finished_at
|
11
|
+
|
12
|
+
alias pull_request? pull_request
|
13
|
+
|
14
|
+
# @!parse attr_reader :repository, :commit, :jobs
|
15
|
+
has :repository, :commit, :jobs
|
16
|
+
|
17
|
+
one :build
|
18
|
+
many :builds
|
19
|
+
|
20
|
+
def restart
|
21
|
+
session.restart(self)
|
22
|
+
end
|
23
|
+
|
24
|
+
def push?
|
25
|
+
not pull_request?
|
26
|
+
end
|
27
|
+
|
28
|
+
def pr_number
|
29
|
+
commit.compare_url[/\d+$/] if pull_request?
|
30
|
+
end
|
31
|
+
|
32
|
+
def branch_info
|
33
|
+
pull_request? ? "Pull Request ##{pr_number}" : commit.branch
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect_info
|
37
|
+
"#{repository.slug}##{number}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|