travis-async-listener 1.8.3
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 +7 -0
- data/LICENSE +22 -0
- data/README.md +2486 -0
- data/Rakefile +63 -0
- data/assets/cacert.pem +69 -0
- data/assets/init/c.yml +4 -0
- data/assets/init/clojure.yml +1 -0
- data/assets/init/cpp.yml +4 -0
- data/assets/init/erlang.yml +3 -0
- data/assets/init/go.yml +4 -0
- data/assets/init/groovy.yml +1 -0
- data/assets/init/haskell.yml +1 -0
- data/assets/init/java.yml +4 -0
- data/assets/init/node_js.yml +4 -0
- data/assets/init/objective-c.yml +1 -0
- data/assets/init/perl.yml +4 -0
- data/assets/init/php.yml +4 -0
- data/assets/init/python.yml +5 -0
- data/assets/init/ruby.yml +6 -0
- data/assets/init/scala.yml +4 -0
- data/assets/notifications/Travis CI.app/Contents/Info.plist +52 -0
- data/assets/notifications/Travis CI.app/Contents/MacOS/Travis CI +0 -0
- data/assets/notifications/Travis CI.app/Contents/PkgInfo +1 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/Travis CI.icns +0 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/Credits.rtf +29 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/InfoPlist.strings +0 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
- data/assets/notifications/Travis CI.app/Contents/_CodeSignature/CodeResources +173 -0
- data/assets/notifications/Travis CI.app/Contents/embedded.provisionprofile +0 -0
- data/assets/notifications/icon.png +0 -0
- data/assets/travis.sh +163 -0
- data/assets/travis.sh.erb +64 -0
- data/bin/travis +18 -0
- data/examples/org_overview.rb +3 -0
- data/examples/pro_auth.rb +23 -0
- data/examples/stream.rb +6 -0
- data/lib/travis.rb +8 -0
- data/lib/travis/auto_login.rb +3 -0
- data/lib/travis/cli.rb +126 -0
- data/lib/travis/cli/accounts.rb +31 -0
- data/lib/travis/cli/api_command.rb +180 -0
- data/lib/travis/cli/branches.rb +25 -0
- data/lib/travis/cli/cache.rb +76 -0
- data/lib/travis/cli/cancel.rb +18 -0
- data/lib/travis/cli/command.rb +422 -0
- data/lib/travis/cli/console.rb +31 -0
- data/lib/travis/cli/disable.rb +15 -0
- data/lib/travis/cli/enable.rb +31 -0
- data/lib/travis/cli/encrypt.rb +108 -0
- data/lib/travis/cli/encrypt_file.rb +140 -0
- data/lib/travis/cli/endpoint.rb +35 -0
- data/lib/travis/cli/env.rb +66 -0
- data/lib/travis/cli/help.rb +23 -0
- data/lib/travis/cli/history.rb +49 -0
- data/lib/travis/cli/init.rb +82 -0
- data/lib/travis/cli/lint.rb +49 -0
- data/lib/travis/cli/login.rb +76 -0
- data/lib/travis/cli/logout.rb +14 -0
- data/lib/travis/cli/logs.rb +65 -0
- data/lib/travis/cli/monitor.rb +110 -0
- data/lib/travis/cli/open.rb +39 -0
- data/lib/travis/cli/parser.rb +43 -0
- data/lib/travis/cli/pubkey.rb +30 -0
- data/lib/travis/cli/raw.rb +20 -0
- data/lib/travis/cli/repo_command.rb +154 -0
- data/lib/travis/cli/report.rb +101 -0
- data/lib/travis/cli/repos.rb +53 -0
- data/lib/travis/cli/requests.rb +47 -0
- data/lib/travis/cli/restart.rb +18 -0
- data/lib/travis/cli/settings.rb +77 -0
- data/lib/travis/cli/setup.rb +66 -0
- data/lib/travis/cli/setup/anynines.rb +21 -0
- data/lib/travis/cli/setup/appfog.rb +19 -0
- data/lib/travis/cli/setup/artifacts.rb +23 -0
- data/lib/travis/cli/setup/biicode.rb +19 -0
- data/lib/travis/cli/setup/cloud_66.rb +20 -0
- data/lib/travis/cli/setup/cloud_control.rb +21 -0
- data/lib/travis/cli/setup/cloud_files.rb +20 -0
- data/lib/travis/cli/setup/cloud_foundry.rb +23 -0
- data/lib/travis/cli/setup/code_deploy.rb +55 -0
- data/lib/travis/cli/setup/deis.rb +20 -0
- data/lib/travis/cli/setup/divshot.rb +18 -0
- data/lib/travis/cli/setup/elastic_beanstalk.rb +23 -0
- data/lib/travis/cli/setup/engine_yard.rb +24 -0
- data/lib/travis/cli/setup/gcs.rb +22 -0
- data/lib/travis/cli/setup/hackage.rb +18 -0
- data/lib/travis/cli/setup/heroku.rb +20 -0
- data/lib/travis/cli/setup/modulus.rb +18 -0
- data/lib/travis/cli/setup/ninefold.rb +20 -0
- data/lib/travis/cli/setup/nodejitsu.rb +27 -0
- data/lib/travis/cli/setup/npm.rb +20 -0
- data/lib/travis/cli/setup/open_shift.rb +20 -0
- data/lib/travis/cli/setup/opsworks.rb +22 -0
- data/lib/travis/cli/setup/pypi.rb +22 -0
- data/lib/travis/cli/setup/releases.rb +35 -0
- data/lib/travis/cli/setup/ruby_gems.rb +25 -0
- data/lib/travis/cli/setup/s3.rb +25 -0
- data/lib/travis/cli/setup/sauce_connect.rb +21 -0
- data/lib/travis/cli/setup/service.rb +73 -0
- data/lib/travis/cli/show.rb +69 -0
- data/lib/travis/cli/sshkey.rb +118 -0
- data/lib/travis/cli/status.rb +19 -0
- data/lib/travis/cli/sync.rb +30 -0
- data/lib/travis/cli/token.rb +14 -0
- data/lib/travis/cli/version.rb +17 -0
- data/lib/travis/cli/whatsup.rb +30 -0
- data/lib/travis/cli/whoami.rb +15 -0
- data/lib/travis/client.rb +39 -0
- data/lib/travis/client/account.rb +56 -0
- data/lib/travis/client/annotation.rb +21 -0
- data/lib/travis/client/artifact.rb +88 -0
- data/lib/travis/client/auto_login.rb +45 -0
- data/lib/travis/client/broadcast.rb +14 -0
- data/lib/travis/client/build.rb +47 -0
- data/lib/travis/client/cache.rb +25 -0
- data/lib/travis/client/commit.rb +28 -0
- data/lib/travis/client/entity.rb +238 -0
- data/lib/travis/client/env_var.rb +102 -0
- data/lib/travis/client/error.rb +38 -0
- data/lib/travis/client/has_uuid.rb +13 -0
- data/lib/travis/client/job.rb +61 -0
- data/lib/travis/client/lint_result.rb +25 -0
- data/lib/travis/client/listener.rb +184 -0
- data/lib/travis/client/methods.rb +104 -0
- data/lib/travis/client/namespace.rb +85 -0
- data/lib/travis/client/not_loadable.rb +13 -0
- data/lib/travis/client/repository.rb +224 -0
- data/lib/travis/client/request.rb +36 -0
- data/lib/travis/client/restartable.rb +23 -0
- data/lib/travis/client/session.rb +339 -0
- data/lib/travis/client/settings.rb +25 -0
- data/lib/travis/client/singleton_setting.rb +36 -0
- data/lib/travis/client/ssh_key.rb +11 -0
- data/lib/travis/client/states.rb +98 -0
- data/lib/travis/client/user.rb +67 -0
- data/lib/travis/client/weak_entity.rb +26 -0
- data/lib/travis/pro.rb +5 -0
- data/lib/travis/pro/auto_login.rb +3 -0
- data/lib/travis/tools/assets.rb +21 -0
- data/lib/travis/tools/completion.rb +54 -0
- data/lib/travis/tools/formatter.rb +50 -0
- data/lib/travis/tools/github.rb +279 -0
- data/lib/travis/tools/notification.rb +69 -0
- data/lib/travis/tools/safe_string.rb +22 -0
- data/lib/travis/tools/ssl_key.rb +48 -0
- data/lib/travis/tools/system.rb +88 -0
- data/lib/travis/version.rb +3 -0
- data/spec/cli/cancel_spec.rb +15 -0
- data/spec/cli/encrypt_spec.rb +43 -0
- data/spec/cli/endpoint_spec.rb +34 -0
- data/spec/cli/help_spec.rb +33 -0
- data/spec/cli/history_spec.rb +38 -0
- data/spec/cli/init_spec.rb +226 -0
- data/spec/cli/login_spec.rb +13 -0
- data/spec/cli/logs_spec.rb +8 -0
- data/spec/cli/open_spec.rb +33 -0
- data/spec/cli/repo_command_spec.rb +25 -0
- data/spec/cli/restart_spec.rb +15 -0
- data/spec/cli/setup_spec.rb +5 -0
- data/spec/cli/show_spec.rb +9 -0
- data/spec/cli/status_spec.rb +28 -0
- data/spec/cli/token_spec.rb +22 -0
- data/spec/cli/version_spec.rb +18 -0
- data/spec/cli/whoami_spec.rb +34 -0
- data/spec/client/account_spec.rb +32 -0
- data/spec/client/annotation_spec.rb +14 -0
- data/spec/client/broadcast_spec.rb +10 -0
- data/spec/client/build_spec.rb +31 -0
- data/spec/client/commit_spec.rb +22 -0
- data/spec/client/job_spec.rb +30 -0
- data/spec/client/methods_spec.rb +15 -0
- data/spec/client/namespace_spec.rb +19 -0
- data/spec/client/repository_spec.rb +39 -0
- data/spec/client/session_spec.rb +165 -0
- data/spec/client/user_spec.rb +16 -0
- data/spec/client_spec.rb +17 -0
- data/spec/pro_spec.rb +10 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/fake_api.rb +738 -0
- data/spec/support/fake_github.rb +24 -0
- data/spec/support/helpers.rb +45 -0
- data/spec/travis_spec.rb +10 -0
- data/travis.gemspec +323 -0
- metadata +489 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'travis/cli'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module CLI
|
|
5
|
+
class Show < RepoCommand
|
|
6
|
+
description "displays a build or job"
|
|
7
|
+
|
|
8
|
+
def run(number = last_build.number)
|
|
9
|
+
number = repository.branch(number).number if number !~ /^\d+(\.\d+)?$/ and repository.branch(number)
|
|
10
|
+
entity = job(number) || build(number)
|
|
11
|
+
|
|
12
|
+
error "could not find job or build #{repository.slug}##{number}" unless entity
|
|
13
|
+
|
|
14
|
+
say template(__FILE__) % [
|
|
15
|
+
entity.class.one.capitalize,
|
|
16
|
+
entity.number,
|
|
17
|
+
entity.commit.subject,
|
|
18
|
+
entity.state,
|
|
19
|
+
entity.color,
|
|
20
|
+
entity.pull_request? ? "pull request" : "push",
|
|
21
|
+
entity.branch_info,
|
|
22
|
+
entity.commit.compare_url,
|
|
23
|
+
formatter.duration(entity.duration),
|
|
24
|
+
formatter.time(entity.started_at),
|
|
25
|
+
formatter.time(entity.finished_at)
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
if entity.respond_to? :jobs
|
|
29
|
+
empty_line
|
|
30
|
+
entity.jobs.each do |job|
|
|
31
|
+
say [
|
|
32
|
+
color("##{job.number} #{job.state}:".ljust(16), [job.color, :bold]),
|
|
33
|
+
formatter.duration(job.duration).ljust(14),
|
|
34
|
+
formatter.job_config(job.config),
|
|
35
|
+
(color("(failure allowed)", :info) if job.allow_failures?)
|
|
36
|
+
].compact.join(" ").rstrip
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
config = formatter.job_config(entity.config)
|
|
40
|
+
say color("Allow Failure: ", :info) + entity.allow_failures?.inspect
|
|
41
|
+
say color("Config: ", :info) + config unless config.empty?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if entity.respond_to? :annotations and entity.annotations.any?
|
|
45
|
+
empty_line
|
|
46
|
+
say color("Annotations:", :bold)
|
|
47
|
+
entity.annotations.each do |annotation|
|
|
48
|
+
say [
|
|
49
|
+
color("#{annotation.provider_name} #{annotation.status}:", [annotation.color, :bold]),
|
|
50
|
+
color(annotation.description, annotation.color),
|
|
51
|
+
color("(%s)" % annotation.url, :info)
|
|
52
|
+
].compact.join(" ").rstrip
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
__END__
|
|
61
|
+
|
|
62
|
+
<[[ color("%s #%s: ", :bold) ]]> <[[ color(%p, :bold) ]]>
|
|
63
|
+
<[[ color("State: ", :info) ]]><[[ color(%p, :%s) ]]>
|
|
64
|
+
<[[ color("Type: ", :info) ]]>%s
|
|
65
|
+
<[[ color("Branch: ", :info) ]]>%s
|
|
66
|
+
<[[ color("Compare URL: ", :info) ]]>%s
|
|
67
|
+
<[[ color("Duration: ", :info) ]]>%s
|
|
68
|
+
<[[ color("Started: ", :info) ]]>%s
|
|
69
|
+
<[[ color("Finished: ", :info) ]]>%s
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require 'travis/cli'
|
|
2
|
+
require 'travis/tools/ssl_key'
|
|
3
|
+
require 'travis/tools/github'
|
|
4
|
+
|
|
5
|
+
module Travis
|
|
6
|
+
module CLI
|
|
7
|
+
class Sshkey < RepoCommand
|
|
8
|
+
description "checks, updates or deletes an SSH key"
|
|
9
|
+
on '-D', '--delete', 'remove SSH key'
|
|
10
|
+
on '-d', '--description DESCRIPTION', 'set description'
|
|
11
|
+
on '-u', '--upload FILE', 'upload key from given file'
|
|
12
|
+
on '-s', '--stdin', 'upload key read from stdin'
|
|
13
|
+
on '-c', '--check', 'set exit code depending on key existing'
|
|
14
|
+
on '-g', '--generate', 'generate SSH key and set up for given GitHub user'
|
|
15
|
+
on '-p', '--passphrase PASSPHRASE', 'pass phrase to decrypt with when using --upload'
|
|
16
|
+
|
|
17
|
+
def_delegators :repository, :ssh_key
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
error "SSH keys are not available on #{color(session.config['host'], :bold)}" if org?
|
|
21
|
+
delete_key if delete?
|
|
22
|
+
update_key File.read(upload), upload if upload?
|
|
23
|
+
update_key $stdin.read, 'stdin' if stdin?
|
|
24
|
+
generate_key if generate?
|
|
25
|
+
display_key
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def display_key
|
|
29
|
+
say "Current SSH key: #{color(ssh_key.description, :info)}"
|
|
30
|
+
say "Finger print: #{color(ssh_key.fingerprint, :info)}"
|
|
31
|
+
rescue Travis::Client::NotFound
|
|
32
|
+
say "No custom SSH key installed."
|
|
33
|
+
exit 1 if check?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def update_key(value, file)
|
|
37
|
+
error "#{file} does not look like a private key" unless value.lines.first =~ /PRIVATE KEY/
|
|
38
|
+
value = remove_passphrase(value)
|
|
39
|
+
self.description ||= ask("Key description: ") { |q| q.default = "Custom Key" } if interactive?
|
|
40
|
+
say "Updating ssh key for #{color slug, :info} with key from #{color file, :info}"
|
|
41
|
+
empty_line
|
|
42
|
+
ssh_key.update(:value => value, :description => description || file)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def delete_key
|
|
46
|
+
return if interactive? and not danger_zone? "Remove SSH key for #{color slug, :info}?"
|
|
47
|
+
say "Removing ssh key for #{color slug, :info}"
|
|
48
|
+
ssh_key.delete
|
|
49
|
+
rescue Travis::Client::NotFound
|
|
50
|
+
warn "no key found to remove"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def generate_key
|
|
54
|
+
github.with_basic_auth do |gh|
|
|
55
|
+
login = gh['user']['login']
|
|
56
|
+
check_access(gh)
|
|
57
|
+
empty_line
|
|
58
|
+
|
|
59
|
+
say "Generating RSA key."
|
|
60
|
+
private_key = Tools::SSLKey.generate_rsa
|
|
61
|
+
self.description ||= "key for fetching dependencies for #{slug} via #{login}"
|
|
62
|
+
|
|
63
|
+
say "Uploading public key to GitHub."
|
|
64
|
+
gh.post("/user/keys", :title => "#{description} (Travis CI)", :key => Tools::SSLKey.rsa_ssh(private_key.public_key))
|
|
65
|
+
|
|
66
|
+
say "Uploading private key to Travis CI."
|
|
67
|
+
ssh_key.update(:value => private_key.to_s, :description => description)
|
|
68
|
+
|
|
69
|
+
empty_line
|
|
70
|
+
say "You can store the private key to reuse it for other repositories (travis sshkey --upload FILE)."
|
|
71
|
+
if agree("Store private key? ") { |q| q.default = "no" }
|
|
72
|
+
path = ask("Path: ") { |q| q.default = "id_travis_rsa" }
|
|
73
|
+
File.write(path, private_key.to_s)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def remove_passphrase(value)
|
|
79
|
+
return value unless Tools::SSLKey.has_passphrase? value
|
|
80
|
+
return Tools::SSLKey.remove_passphrase(value, passphrase) || error("wrong pass phrase") if passphrase
|
|
81
|
+
error "Key is encrypted, but missing --passphrase option" unless interactive?
|
|
82
|
+
say "The private key is protected by a pass phrase."
|
|
83
|
+
result = Tools::SSLKey.remove_passphrase(value, ask("Enter pass phrase: ") { |q| q.echo = "*" }) until result
|
|
84
|
+
empty_line
|
|
85
|
+
result
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def check_access(gh)
|
|
89
|
+
gh["repos/#{slug}"]
|
|
90
|
+
rescue GH::Error
|
|
91
|
+
error "GitHub account has no read access to #{color slug, :bold}"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def github
|
|
95
|
+
@github ||= begin
|
|
96
|
+
load_gh
|
|
97
|
+
Tools::Github.new(session.config['github']) do |g|
|
|
98
|
+
g.note = "token for fetching dependencies for #{slug} (Travis CI)"
|
|
99
|
+
g.explode = explode?
|
|
100
|
+
g.ask_login = proc { ask("Username: ") }
|
|
101
|
+
g.ask_password = proc { |user| ask("Password for #{user}: ") { |q| q.echo = "*" } }
|
|
102
|
+
g.ask_otp = proc { |user| ask("Two-factor authentication code for #{user}: ") }
|
|
103
|
+
g.login_header = proc { login_header }
|
|
104
|
+
g.debug = proc { |log| debug(log) }
|
|
105
|
+
g.after_tokens = proc { g.explode = true and error("no suitable github token found") }
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def login_header
|
|
111
|
+
say "We need the #{color("GitHub login", :important)} for the account you want to add the key to."
|
|
112
|
+
say "This information will #{color("not be sent to Travis CI", :important)}, only to #{color(github_endpoint.host, :info)}."
|
|
113
|
+
say "The password will not be displayed."
|
|
114
|
+
empty_line
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'travis/cli'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module CLI
|
|
5
|
+
class Status < RepoCommand
|
|
6
|
+
description "checks status of the latest build"
|
|
7
|
+
|
|
8
|
+
on '-x', '--[no-]exit-code', 'sets the exit code to 1 if the build failed'
|
|
9
|
+
on '-q', '--[no-]quiet', 'does not print anything'
|
|
10
|
+
on '-p', '--[no-]fail-pending', 'sets the status code to 1 if the build is pending'
|
|
11
|
+
|
|
12
|
+
def run
|
|
13
|
+
say color(last_build.state, last_build.color), "build ##{last_build.number} %s" unless quiet?
|
|
14
|
+
exit 1 if exit_code? and last_build.unsuccessful?
|
|
15
|
+
exit 1 if fail_pending? and last_build.pending?
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'travis/cli'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module CLI
|
|
5
|
+
class Sync < ApiCommand
|
|
6
|
+
description "triggers a new sync with GitHub"
|
|
7
|
+
|
|
8
|
+
on '-c', '--check', 'only check the sync status'
|
|
9
|
+
on '-b', '--background', 'will trigger sync but not block until sync is done'
|
|
10
|
+
on '-f', '--force', 'will force sync, even if one is already running'
|
|
11
|
+
|
|
12
|
+
def run
|
|
13
|
+
authenticate
|
|
14
|
+
|
|
15
|
+
if check?
|
|
16
|
+
say "#{"not " unless user.syncing?}syncing", "#{user.login} is currently %s"
|
|
17
|
+
elsif user.syncing? and not force?
|
|
18
|
+
error "user is already syncing"
|
|
19
|
+
elsif background?
|
|
20
|
+
say "starting synchronization"
|
|
21
|
+
sync(false)
|
|
22
|
+
else
|
|
23
|
+
say "synchronizing: "
|
|
24
|
+
sync
|
|
25
|
+
say color(" done", :success)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'travis/cli'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module CLI
|
|
5
|
+
class Whatsup < ApiCommand
|
|
6
|
+
description "lists most recent builds"
|
|
7
|
+
on('-m', '--my-repos', 'Only display my own repositories')
|
|
8
|
+
|
|
9
|
+
def run
|
|
10
|
+
say "nothing to show" if recent.empty?
|
|
11
|
+
|
|
12
|
+
recent.each do |repo|
|
|
13
|
+
say [
|
|
14
|
+
color(repo.slug, [:bold, repo.color]),
|
|
15
|
+
color("#{repo.last_build.state}: ##{repo.last_build.number}", repo.color)
|
|
16
|
+
].join(" ")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def recent
|
|
23
|
+
@recent ||= begin
|
|
24
|
+
recent = my_repos ? repos : repos(:member => user.login)
|
|
25
|
+
recent.select { |repo| repo.last_build }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'travis/cli'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module CLI
|
|
5
|
+
class Whoami < ApiCommand
|
|
6
|
+
description "outputs the current user"
|
|
7
|
+
|
|
8
|
+
def run
|
|
9
|
+
authenticate
|
|
10
|
+
name = " (#{user.name})" unless user.name.to_s.empty?
|
|
11
|
+
say user.login, "You are %s" << name.to_s
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'backports/2.0.0' if RUBY_VERSION < '2.0.0'
|
|
2
|
+
require 'travis/client/error'
|
|
3
|
+
require 'travis/client/states'
|
|
4
|
+
require 'travis/client/restartable'
|
|
5
|
+
require 'travis/client/not_loadable'
|
|
6
|
+
require 'travis/client/has_uuid'
|
|
7
|
+
require 'travis/client/methods'
|
|
8
|
+
require 'travis/client/session'
|
|
9
|
+
require 'travis/client/entity'
|
|
10
|
+
require 'travis/client/user'
|
|
11
|
+
require 'travis/client/repository'
|
|
12
|
+
require 'travis/client/env_var'
|
|
13
|
+
require 'travis/client/annotation'
|
|
14
|
+
require 'travis/client/build'
|
|
15
|
+
require 'travis/client/artifact'
|
|
16
|
+
require 'travis/client/cache'
|
|
17
|
+
require 'travis/client/commit'
|
|
18
|
+
require 'travis/client/job'
|
|
19
|
+
require 'travis/client/namespace'
|
|
20
|
+
require 'travis/client/account'
|
|
21
|
+
require 'travis/client/broadcast'
|
|
22
|
+
require 'travis/client/settings'
|
|
23
|
+
require 'travis/client/singleton_setting'
|
|
24
|
+
require 'travis/client/ssh_key'
|
|
25
|
+
require 'travis/client/request'
|
|
26
|
+
require 'travis/client/listener'
|
|
27
|
+
require 'travis/client/lint_result'
|
|
28
|
+
|
|
29
|
+
module Travis
|
|
30
|
+
module Client
|
|
31
|
+
ORG_URI = 'https://api.travis-ci.org/'
|
|
32
|
+
PRO_URI = 'https://api.travis-ci.com/'
|
|
33
|
+
|
|
34
|
+
def self.new(options = {})
|
|
35
|
+
options[:uri] ||= ORG_URI if options.is_a? Hash and not options['uri']
|
|
36
|
+
Session.new(options)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'travis/client'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module Client
|
|
5
|
+
class Account < Entity
|
|
6
|
+
attributes :name, :login, :type, :repos_count, :subscribed, :education
|
|
7
|
+
|
|
8
|
+
one :account
|
|
9
|
+
many :accounts
|
|
10
|
+
|
|
11
|
+
inspect_info :login
|
|
12
|
+
id_field :login
|
|
13
|
+
|
|
14
|
+
def self.cast_id(id)
|
|
15
|
+
String(id)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.id?(object)
|
|
19
|
+
object.is_a? String
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def subscribed
|
|
23
|
+
load_attribute('subscribed') { true } if member?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def education
|
|
27
|
+
load_attribute('education') { false } if member?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def on_trial?
|
|
31
|
+
!subscribed? and !education?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def repos_count
|
|
35
|
+
load_attribute("repos_count") { repositories.count }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def repositories
|
|
39
|
+
attributes['repositories'] ||= session.repos(:owner_name => login)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def member?
|
|
43
|
+
session.accounts.include? self
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
alias educational? education?
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def load_attribute(name, &block)
|
|
51
|
+
session.accounts if missing? name
|
|
52
|
+
block ? attributes.fetch(name.to_s, &block) : attributes[name.to_s]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'travis/client'
|
|
2
|
+
|
|
3
|
+
module Travis
|
|
4
|
+
module Client
|
|
5
|
+
class Annotation < Entity
|
|
6
|
+
include NotLoadable, States
|
|
7
|
+
attributes :job_id, :provider_name, :status, :url, :description
|
|
8
|
+
alias state status
|
|
9
|
+
|
|
10
|
+
# @!parse attr_reader :job
|
|
11
|
+
has :job
|
|
12
|
+
|
|
13
|
+
one :annotation
|
|
14
|
+
many :annotations
|
|
15
|
+
|
|
16
|
+
def inspect_info
|
|
17
|
+
"#{provider_name}: #{status}"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'travis/client'
|
|
3
|
+
require 'travis/tools/safe_string'
|
|
4
|
+
|
|
5
|
+
module Travis
|
|
6
|
+
module Client
|
|
7
|
+
class Artifact < Entity
|
|
8
|
+
CHUNKED = "application/json; chunked=true; version=2, application/json; version=2"
|
|
9
|
+
TEXT = "#{CHUNKED}, text/plain"
|
|
10
|
+
|
|
11
|
+
# @!parse attr_reader :job_id, :type, :body
|
|
12
|
+
attributes :job_id, :type, :body
|
|
13
|
+
|
|
14
|
+
# @!parse attr_reader :job
|
|
15
|
+
has :job
|
|
16
|
+
|
|
17
|
+
def delete_body(reason = {})
|
|
18
|
+
reason = { :reason => reason } unless reason.is_a? Hash
|
|
19
|
+
session.patch_raw("jobs/#{job_id}/log", reason)
|
|
20
|
+
reload
|
|
21
|
+
rescue Travis::Client::Error => error
|
|
22
|
+
raise unless error.message == '409'
|
|
23
|
+
self
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def encoded_body
|
|
27
|
+
Tools::SafeString.encoded(body)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def colorized_body
|
|
31
|
+
attributes['colorized_body'] ||= Tools::SafeString.colorized(body)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def clean_body
|
|
35
|
+
attributes['clean_body'] ||= Tools::SafeString.clean(body)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def current_body
|
|
39
|
+
attributes['current_body'] ||= begin
|
|
40
|
+
body = load_attribute('body')
|
|
41
|
+
if body.to_s.empty?
|
|
42
|
+
log = session.get_raw("jobs/#{job_id}/log", nil, "Accept" => TEXT)
|
|
43
|
+
body = String === log ? log : log['log']['body']
|
|
44
|
+
end
|
|
45
|
+
body
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def body(stream = block_given?)
|
|
50
|
+
return current_body unless block_given? or stream
|
|
51
|
+
return yield(current_body) unless stream and job.pending?
|
|
52
|
+
number = 0
|
|
53
|
+
|
|
54
|
+
session.listen(self) do |listener|
|
|
55
|
+
listener.on 'job:log' do |event|
|
|
56
|
+
next unless event.payload['number'] > number
|
|
57
|
+
number = event.payload['number']
|
|
58
|
+
yield event.payload['_log']
|
|
59
|
+
listener.disconnect if event.payload['final']
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
listener.on 'job:finished' do |event|
|
|
63
|
+
listener.disconnect
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
listener.on_connect do
|
|
67
|
+
data = session.get_raw("/logs/#{id}", nil, "Accept" => CHUNKED)['log']
|
|
68
|
+
if data['parts']
|
|
69
|
+
data['parts'].each { |p| yield p['content'] }
|
|
70
|
+
number = data['parts'].last['number'] if data['parts'].any?
|
|
71
|
+
else
|
|
72
|
+
yield data['body']
|
|
73
|
+
listener.disconnect
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def pusher_entity
|
|
80
|
+
job
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
one :log
|
|
84
|
+
many :logs
|
|
85
|
+
aka :artifact
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|