travis 1.11.1 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/Rakefile +22 -20
- data/bin/travis +5 -3
- data/examples/org_overview.rb +2 -0
- data/examples/pro_auth.rb +3 -1
- data/examples/stream.rb +5 -3
- data/lib/travis/auto_login.rb +2 -0
- data/lib/travis/cli/accounts.rb +12 -9
- data/lib/travis/cli/api_command.rb +85 -81
- data/lib/travis/cli/branches.rb +8 -6
- data/lib/travis/cli/cache.rb +48 -44
- data/lib/travis/cli/cancel.rb +4 -2
- data/lib/travis/cli/command.rb +170 -142
- data/lib/travis/cli/console.rb +5 -5
- data/lib/travis/cli/disable.rb +4 -2
- data/lib/travis/cli/enable.rb +14 -12
- data/lib/travis/cli/encrypt.rb +57 -57
- data/lib/travis/cli/encrypt_file.rb +29 -18
- data/lib/travis/cli/endpoint.rb +9 -7
- data/lib/travis/cli/env.rb +13 -8
- data/lib/travis/cli/help.rb +10 -8
- data/lib/travis/cli/history.rb +19 -15
- data/lib/travis/cli/init.rb +27 -24
- data/lib/travis/cli/lint.rb +10 -8
- data/lib/travis/cli/login.rb +17 -11
- data/lib/travis/cli/logout.rb +4 -2
- data/lib/travis/cli/logs.rb +28 -19
- data/lib/travis/cli/monitor.rb +11 -8
- data/lib/travis/cli/open.rb +17 -14
- data/lib/travis/cli/parser.rb +2 -0
- data/lib/travis/cli/pubkey.rb +13 -11
- data/lib/travis/cli/raw.rb +4 -3
- data/lib/travis/cli/repo_command.rb +123 -112
- data/lib/travis/cli/report.rb +40 -33
- data/lib/travis/cli/repos.rb +14 -9
- data/lib/travis/cli/requests.rb +13 -12
- data/lib/travis/cli/restart.rb +4 -2
- data/lib/travis/cli/settings.rb +41 -35
- data/lib/travis/cli/setup/anynines.rb +7 -6
- data/lib/travis/cli/setup/appfog.rb +6 -4
- data/lib/travis/cli/setup/artifacts.rb +7 -5
- data/lib/travis/cli/setup/biicode.rb +6 -4
- data/lib/travis/cli/setup/cloud_66.rb +6 -4
- data/lib/travis/cli/setup/cloud_control.rb +8 -6
- data/lib/travis/cli/setup/cloud_files.rb +7 -5
- data/lib/travis/cli/setup/cloud_foundry.rb +9 -7
- data/lib/travis/cli/setup/code_deploy.rb +33 -29
- data/lib/travis/cli/setup/deis.rb +8 -6
- data/lib/travis/cli/setup/divshot.rb +20 -18
- data/lib/travis/cli/setup/elastic_beanstalk.rb +10 -8
- data/lib/travis/cli/setup/engine_yard.rb +9 -7
- data/lib/travis/cli/setup/gcs.rb +9 -7
- data/lib/travis/cli/setup/hackage.rb +6 -4
- data/lib/travis/cli/setup/heroku.rb +10 -4
- data/lib/travis/cli/setup/modulus.rb +5 -3
- data/lib/travis/cli/setup/ninefold.rb +7 -5
- data/lib/travis/cli/setup/nodejitsu.rb +6 -4
- data/lib/travis/cli/setup/npm.rb +6 -4
- data/lib/travis/cli/setup/open_shift.rb +8 -6
- data/lib/travis/cli/setup/opsworks.rb +24 -22
- data/lib/travis/cli/setup/pypi.rb +7 -5
- data/lib/travis/cli/setup/releases.rb +6 -6
- data/lib/travis/cli/setup/ruby_gems.rb +7 -5
- data/lib/travis/cli/setup/s3.rb +12 -8
- data/lib/travis/cli/setup/sauce_connect.rb +7 -5
- data/lib/travis/cli/setup/service.rb +36 -25
- data/lib/travis/cli/setup.rb +7 -3
- data/lib/travis/cli/show.rb +10 -8
- data/lib/travis/cli/sshkey.rb +31 -27
- data/lib/travis/cli/status.rb +5 -3
- data/lib/travis/cli/sync.rb +9 -7
- data/lib/travis/cli/token.rb +4 -2
- data/lib/travis/cli/version.rb +4 -3
- data/lib/travis/cli/whatsup.rb +10 -8
- data/lib/travis/cli/whoami.rb +2 -2
- data/lib/travis/cli.rb +39 -36
- data/lib/travis/client/account.rb +8 -6
- data/lib/travis/client/artifact.rb +16 -12
- data/lib/travis/client/auto_login.rb +7 -4
- data/lib/travis/client/broadcast.rb +2 -0
- data/lib/travis/client/build.rb +7 -3
- data/lib/travis/client/cache.rb +4 -2
- data/lib/travis/client/commit.rb +5 -2
- data/lib/travis/client/entity.rb +50 -46
- data/lib/travis/client/env_var.rb +13 -8
- data/lib/travis/client/error.rb +5 -3
- data/lib/travis/client/has_uuid.rb +3 -1
- data/lib/travis/client/job.rb +8 -3
- data/lib/travis/client/lint_result.rb +2 -0
- data/lib/travis/client/listener.rb +70 -55
- data/lib/travis/client/methods.rb +10 -5
- data/lib/travis/client/namespace.rb +20 -16
- data/lib/travis/client/not_loadable.rb +3 -1
- data/lib/travis/client/repository.rb +34 -22
- data/lib/travis/client/request.rb +5 -2
- data/lib/travis/client/restartable.rb +2 -0
- data/lib/travis/client/session.rb +118 -88
- data/lib/travis/client/settings.rb +8 -3
- data/lib/travis/client/singleton_setting.rb +2 -0
- data/lib/travis/client/ssh_key.rb +2 -0
- data/lib/travis/client/states.rb +8 -6
- data/lib/travis/client/user.rb +2 -0
- data/lib/travis/client/weak_entity.rb +6 -3
- data/lib/travis/client.rb +4 -1
- data/lib/travis/pro/auto_login.rb +2 -0
- data/lib/travis/pro.rb +2 -0
- data/lib/travis/tools/assets.rb +6 -3
- data/lib/travis/tools/completion.rb +10 -6
- data/lib/travis/tools/formatter.rb +20 -14
- data/lib/travis/tools/github.rb +59 -49
- data/lib/travis/tools/notification.rb +18 -13
- data/lib/travis/tools/safe_string.rb +4 -1
- data/lib/travis/tools/ssl_key.rb +5 -2
- data/lib/travis/tools/system.rb +11 -6
- data/lib/travis/version.rb +3 -1
- data/lib/travis.rb +3 -1
- data/spec/cli/api_command_spec.rb +11 -8
- data/spec/cli/cancel_spec.rb +2 -4
- data/spec/cli/encrypt_file_spec.rb +9 -7
- data/spec/cli/encrypt_spec.rb +19 -17
- data/spec/cli/endpoint_spec.rb +12 -10
- data/spec/cli/help_spec.rb +14 -12
- data/spec/cli/history_spec.rb +2 -0
- data/spec/cli/init_spec.rb +35 -33
- data/spec/cli/logs_spec.rb +2 -0
- data/spec/cli/open_spec.rb +6 -4
- data/spec/cli/repo_command_spec.rb +8 -4
- data/spec/cli/restart_spec.rb +2 -4
- data/spec/cli/setup/service_spec.rb +17 -18
- data/spec/cli/setup_spec.rb +2 -4
- data/spec/cli/show_spec.rb +4 -2
- data/spec/cli/status_spec.rb +7 -5
- data/spec/cli/token_spec.rb +7 -5
- data/spec/cli/version_spec.rb +2 -0
- data/spec/cli/whoami_spec.rb +9 -7
- data/spec/client/account_spec.rb +28 -20
- data/spec/client/auto_login_spec.rb +12 -9
- data/spec/client/broadcast_spec.rb +5 -3
- data/spec/client/build_spec.rb +28 -24
- data/spec/client/commit_spec.rb +17 -14
- data/spec/client/job_spec.rb +27 -23
- data/spec/client/methods_spec.rb +8 -4
- data/spec/client/namespace_spec.rb +8 -4
- data/spec/client/repository_spec.rb +33 -30
- data/spec/client/session_spec.rb +71 -67
- data/spec/client/user_spec.rb +13 -10
- data/spec/client_spec.rb +6 -4
- data/spec/pro_spec.rb +5 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/support/fake_api.rb +662 -662
- data/spec/support/fake_github.rb +6 -3
- data/spec/support/helpers.rb +13 -8
- data/spec/travis_spec.rb +5 -3
- data/travis.gemspec +400 -399
- metadata +30 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b5c4a5f4cbdfb25775698bedbd1cd824829126ef517f1f5b46dfe87269eb55
|
4
|
+
data.tar.gz: 49ef3fdf23e50443114305980b451502613322ae67b118cc21512a755b55aae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d2c85a4a706274f514e593bb56adf3a25f95ba732030c9a47c49c2c0fdc1fbef46bbea4006d2efe555d48c70a80d057fe03d4536da5f713f443c9d5a770d3f
|
7
|
+
data.tar.gz: 28f140f38fbfa6f479ff816c4174480d408c90ed4b4f79229c3a4449bdba3abd492acea894d951f679a91be1583b192650109fb36c6efd1f7978a4be1f551d75
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# The Travis Client [![Build Status](https://travis-ci.com/travis-ci/travis.rb.svg?branch=master)](https://travis-ci.com/travis-ci/travis.rb)
|
1
|
+
# The Travis Client [![Build Status](https://app.travis-ci.com/travis-ci/travis.rb.svg?branch=master)](https://app.travis-ci.com/github/travis-ci/travis.rb)
|
2
2
|
|
3
3
|
![The Travis Mascot](https://about.travis-ci.org/images/travis-mascot-200px.png)
|
4
4
|
|
5
|
-
The [travis gem](https://rubygems.org/gems/travis) includes both a [command line client](#command-line-client) and a [Ruby library](#ruby-library) to interface with a Travis CI service. Both work with [travis-ci.
|
5
|
+
The [travis gem](https://rubygems.org/gems/travis) includes both a [command line client](#command-line-client) and a [Ruby library](#ruby-library) to interface with a Travis CI service using GitHub account. Both work with [travis-ci.com](https://travis-ci.com) or any custom Travis CI setup you might have. Check out the [installation instructions](#installation) to get it running in no time.
|
6
6
|
|
7
7
|
## Table of Contents
|
8
8
|
|
@@ -81,7 +81,7 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a [command line
|
|
81
81
|
|
82
82
|
## Command Line Client
|
83
83
|
|
84
|
-
![](
|
84
|
+
![](https://docs.travis-ci.com/images/new-tricks.png)
|
85
85
|
|
86
86
|
There are three types of commands: [Non-API Commands](#non-api-commands), [General API Commands](#general-api-commands) and [Repository Commands](#repository-commands). All commands take the form of `travis COMMAND [ARGUMENTS] [OPTIONS]`. You can get a list of commands by running [`help`](#help).
|
87
87
|
|
@@ -2066,6 +2066,12 @@ See https://github.com/travis-ci/travis.rb/issues/768#issuecomment-700220351 for
|
|
2066
2066
|
|
2067
2067
|
## Version History
|
2068
2068
|
|
2069
|
+
### 1.12.0
|
2070
|
+
|
2071
|
+
* Upgraded ruby version to 3.2 https://github.com/travis-ci/travis.rb/pull/848
|
2072
|
+
* Added API Key Reset Capabilities https://github.com/travis-ci/travis.rb/pull/842
|
2073
|
+
* Fix travis lint issues https://github.com/travis-ci/travis.rb/pull/840
|
2074
|
+
|
2069
2075
|
### 1.11.1
|
2070
2076
|
|
2071
2077
|
* Fix `travis sshkey --generate` https://github.com/travis-ci/travis.rb/pull/820
|
data/Rakefile
CHANGED
@@ -1,26 +1,27 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
3
4
|
windows = RUBY_PLATFORM =~ /mswin|mingw/
|
4
5
|
|
5
6
|
require 'bundler/gem_tasks'
|
6
7
|
|
7
|
-
desc
|
8
|
-
task(:spec) { ruby "-S rspec spec#{
|
8
|
+
desc 'run specs'
|
9
|
+
task(:spec) { ruby "-S rspec spec#{' -c' unless windows}" }
|
9
10
|
|
10
|
-
desc
|
11
|
-
task :
|
11
|
+
desc 'generate gemspec, update readme'
|
12
|
+
task update: :completion do
|
12
13
|
require 'travis/version'
|
13
14
|
content = File.read('travis.gemspec')
|
14
15
|
|
15
16
|
# fetch data
|
16
17
|
fields = {
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
18
|
+
authors: sort_by_commits_alpha(`git shortlog -sn`.b, /[^\d\s].*/).uniq,
|
19
|
+
email: sort_by_commits_alpha(`git shortlog -sne`.b, /[^<]+@[^>]+/).uniq,
|
20
|
+
files: `git ls-files`.b.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
|
20
21
|
}
|
21
22
|
|
22
23
|
# :(
|
23
|
-
fields[:email].delete(
|
24
|
+
fields[:email].delete('konstantin.haase@gmail.com')
|
24
25
|
|
25
26
|
# insert data
|
26
27
|
fields.each do |field, values|
|
@@ -31,7 +32,7 @@ task :update => :completion do
|
|
31
32
|
end
|
32
33
|
|
33
34
|
# set version
|
34
|
-
content.sub!
|
35
|
+
content.sub!(/(s\.version.*=\s+).*/, "\\1\"#{Travis::VERSION}\"")
|
35
36
|
|
36
37
|
# escape unicode
|
37
38
|
content.gsub!(/./) { |c| c.bytesize > 1 ? "\\u{#{c.codepoints.first.to_s(16)}}" : c }
|
@@ -39,12 +40,13 @@ task :update => :completion do
|
|
39
40
|
File.open('travis.gemspec', 'w') { |f| f << content }
|
40
41
|
|
41
42
|
readme = File.read('README.md').b
|
42
|
-
readme.gsub!
|
43
|
-
readme.gsub!
|
44
|
-
readme.gsub!
|
43
|
+
readme.gsub!(/^(\s+\$ travis version\n\s+).*$/, "\\1#{Travis::VERSION}")
|
44
|
+
readme.gsub!(/(gem install travis -v )\S+/, "\\1#{Travis::VERSION}")
|
45
|
+
readme.gsub!(/^\*\*#{Regexp.escape(Travis::VERSION)}\*\* \(not yet released?\)\n/i,
|
46
|
+
"**#{Travis::VERSION}** (#{Time.now.strftime('%B %-d, %Y')})\n")
|
45
47
|
|
46
48
|
Travis::CLI.commands.each do |c|
|
47
|
-
readme.sub!
|
49
|
+
readme.sub!(/^( \* \[`#{c.command_name}`\]\(##{c.command_name}\)).*$/, "\\1 - #{c.description}")
|
48
50
|
end
|
49
51
|
|
50
52
|
File.write('README.md', readme)
|
@@ -58,13 +60,13 @@ end
|
|
58
60
|
task 'travis.gemspec' => :update
|
59
61
|
task 'README.md' => :update
|
60
62
|
|
61
|
-
task :
|
62
|
-
task :
|
63
|
-
task :
|
64
|
-
task :
|
63
|
+
task gemspec: :update
|
64
|
+
task default: :spec
|
65
|
+
task default: :gemspec unless windows || (RUBY_VERSION < '2.0')
|
66
|
+
task test: :spec
|
65
67
|
|
66
68
|
def sort_by_commits_alpha(shortlog_output, patt)
|
67
|
-
shortlog_output.split("\n").sort do |a,b|
|
69
|
+
shortlog_output.split("\n").sort do |a, b|
|
68
70
|
a_comm, a_name = a.strip.split(/\t/)
|
69
71
|
b_comm, b_name = b.strip.split(/\t/)
|
70
72
|
|
data/bin/travis
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
# :(
|
3
5
|
Encoding.default_external = Encoding::UTF_8 if defined? Encoding
|
4
6
|
|
5
7
|
# load travis library
|
6
|
-
require 'bundler/setup' if File.exist? File.expand_path('
|
8
|
+
require 'bundler/setup' if File.exist? File.expand_path('../Gemfile', __dir__)
|
7
9
|
require 'travis/cli'
|
8
10
|
|
9
11
|
# load plugins
|
10
|
-
TRAVIS_PLUGINS = []
|
12
|
+
TRAVIS_PLUGINS = [].freeze
|
11
13
|
config_path = ENV.fetch('TRAVIS_CONFIG_PATH') { File.expand_path('.travis', Dir.home) }
|
12
14
|
Dir.glob(File.expand_path('*/init.rb', config_path)) do |file|
|
13
|
-
TRAVIS_PLUGINS << file.sub(config_path
|
15
|
+
TRAVIS_PLUGINS << file.sub("#{config_path}/", '').sub(%r{/init\.rb$}, '')
|
14
16
|
load(file)
|
15
17
|
end
|
16
18
|
|
data/examples/org_overview.rb
CHANGED
data/examples/pro_auth.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/pro'
|
2
4
|
require 'travis/tools/github'
|
3
5
|
require 'highline/import' # so we can hide the password
|
4
6
|
|
5
|
-
github_token = ask(
|
7
|
+
github_token = ask('GitHub token: ')
|
6
8
|
|
7
9
|
# Set up GitHub tool for doing the login handshake.
|
8
10
|
github = Travis::Tools::Github.new(drop_token: true) do |g|
|
data/examples/stream.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis'
|
2
4
|
|
3
5
|
Travis.listen do |listener|
|
4
|
-
listener.on(
|
5
|
-
listener.on(
|
6
|
-
end
|
6
|
+
listener.on('job:started') { |e| puts "job started for #{e.repository.slug}" }
|
7
|
+
listener.on('job:finished') { |e| puts "job finished for #{e.repository.slug}" }
|
8
|
+
end
|
data/lib/travis/auto_login.rb
CHANGED
data/lib/travis/cli/accounts.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
4
6
|
module CLI
|
5
7
|
class Accounts < ApiCommand
|
6
|
-
description
|
8
|
+
description 'displays accounts and their subscription status'
|
7
9
|
|
8
10
|
def run
|
9
11
|
authenticate
|
@@ -13,18 +15,19 @@ module Travis
|
|
13
15
|
color(account.login, [color, :bold]),
|
14
16
|
color("(#{account.name || account.login.capitalize}):", color),
|
15
17
|
"#{description(account)},",
|
16
|
-
account.repos_count == 1 ?
|
17
|
-
].join(
|
18
|
-
end
|
19
|
-
unless accounts.none?(&:on_trial?) or session.config['host'].nil?
|
20
|
-
say session.config['host'], "To set up a subscription, please visit %s."
|
18
|
+
account.repos_count == 1 ? '1 repository' : "#{account.repos_count} repositories"
|
19
|
+
].join(' ')
|
21
20
|
end
|
21
|
+
return if accounts.none?(&:on_trial?) || session.config['host'].nil?
|
22
|
+
|
23
|
+
say session.config['host'], 'To set up a subscription, please visit %s.'
|
22
24
|
end
|
23
25
|
|
24
26
|
def description(account)
|
25
|
-
return
|
26
|
-
return
|
27
|
-
|
27
|
+
return 'subscribed' if account.subscribed?
|
28
|
+
return 'educational account' if account.educational?
|
29
|
+
|
30
|
+
'not subscribed'
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
require 'travis/tools/github'
|
3
5
|
|
@@ -7,24 +9,25 @@ module Travis
|
|
7
9
|
include Travis::Client::Methods
|
8
10
|
attr_accessor :enterprise_name
|
9
11
|
attr_reader :session
|
12
|
+
|
10
13
|
abstract
|
11
14
|
|
12
15
|
on('-e', '--api-endpoint URL', 'Travis API server to talk to')
|
13
16
|
on('-I', '--[no-]insecure', 'do not verify SSL certificate of API endpoint')
|
14
|
-
on('--pro', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c,_| c.api_endpoint = Travis::Client::COM_URI }
|
15
|
-
on('--com', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c,_| c.api_endpoint = Travis::Client::COM_URI }
|
16
|
-
on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c,_| c.api_endpoint = Travis::Client::ORG_URI }
|
17
|
-
on('--staging', 'talks to staging system') { |c,_| c.api_endpoint = c.api_endpoint.gsub(/api/, 'api-staging') }
|
17
|
+
on('--pro', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
|
18
|
+
on('--com', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
|
19
|
+
on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c, _| c.api_endpoint = Travis::Client::ORG_URI }
|
20
|
+
on('--staging', 'talks to staging system') { |c, _| c.api_endpoint = c.api_endpoint.gsub(/api/, 'api-staging') }
|
18
21
|
on('-t', '--token [ACCESS_TOKEN]', 'access token to use') { |c, t| c.access_token = t }
|
19
22
|
|
20
|
-
on('--debug', 'show API requests') do |c,_|
|
23
|
+
on('--debug', 'show API requests') do |c, _|
|
21
24
|
c.debug = true
|
22
25
|
c.session.instrument do |info, request|
|
23
26
|
c.time(info, request)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
on('--debug-http', 'show HTTP(S) exchange') do |c,_|
|
30
|
+
on('--debug-http', 'show HTTP(S) exchange') do |c, _|
|
28
31
|
c.session.debug_http = true
|
29
32
|
end
|
30
33
|
|
@@ -34,19 +37,17 @@ module Travis
|
|
34
37
|
|
35
38
|
on('--adapter ADAPTER', 'Faraday adapter to use for HTTP requests. If omitted, use Typhoeus if it is installed, ' \
|
36
39
|
'and Net::HTTP otherwise. See https://lostisland.github.io/faraday/adapters/ for more info') do |c, adapter|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
exit 1
|
45
|
-
end
|
40
|
+
adapter.gsub! '-', '_'
|
41
|
+
require "faraday/adapter/#{adapter}"
|
42
|
+
require 'typhoeus/adapters/faraday' if adapter == 'typhoeus'
|
43
|
+
c.session.faraday_adapter = adapter.to_sym
|
44
|
+
rescue LoadError
|
45
|
+
warn "\`--adapter #{adapter}\` is given, but it is not installed. Run \`gem install #{adapter}\` and try again"
|
46
|
+
exit 1
|
46
47
|
end
|
47
48
|
|
48
49
|
def initialize(*)
|
49
|
-
@session = Travis::Client.new(:
|
50
|
+
@session = Travis::Client.new(agent_info: "command #{command_name}")
|
50
51
|
super
|
51
52
|
end
|
52
53
|
|
@@ -62,8 +63,8 @@ module Travis
|
|
62
63
|
endpoint_config['access_token'] ||= access_token
|
63
64
|
endpoint_config['insecure'] = insecure unless insecure.nil?
|
64
65
|
self.insecure = endpoint_config['insecure']
|
65
|
-
session.ssl = { :
|
66
|
-
authenticate if pro?
|
66
|
+
session.ssl = { verify: false } if insecure?
|
67
|
+
authenticate if pro? || enterprise?
|
67
68
|
end
|
68
69
|
|
69
70
|
def enterprise?
|
@@ -90,12 +91,12 @@ module Travis
|
|
90
91
|
user.sync
|
91
92
|
|
92
93
|
steps = count = 1
|
93
|
-
while block
|
94
|
+
while block && user.reload.syncing?
|
94
95
|
count += 1
|
95
96
|
sleep(1)
|
96
97
|
|
97
|
-
if count % steps
|
98
|
-
steps = count/10 + 1
|
98
|
+
if (count % steps).zero?
|
99
|
+
steps = count / 10 + 1
|
99
100
|
output.print dot
|
100
101
|
end
|
101
102
|
end
|
@@ -103,84 +104,87 @@ module Travis
|
|
103
104
|
|
104
105
|
private
|
105
106
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
self.api_endpoint = c[enterprise_name]
|
119
|
-
self.insecure = insecure unless insecure.nil?
|
120
|
-
self.session.ssl.delete :ca_file
|
121
|
-
endpoint_config['enterprise'] = true
|
122
|
-
@setup_ennterpise = true
|
123
|
-
end
|
124
|
-
|
125
|
-
def setup_enterprise?
|
126
|
-
@setup_ennterpise ||= false
|
127
|
-
!!enterprise_name and not @setup_ennterpise
|
107
|
+
def setup_enterprise
|
108
|
+
return unless setup_enterprise?
|
109
|
+
|
110
|
+
c = config['enterprise'] ||= {}
|
111
|
+
c[enterprise_name] = api_endpoint if explicit_api_endpoint?
|
112
|
+
c[enterprise_name] ||= write_to($stderr) do
|
113
|
+
error 'enterprise setup not configured' unless interactive?
|
114
|
+
user_input = ask(color('Enterprise domain: ', :bold)).to_s
|
115
|
+
domain = user_input[%r{^(?:https?://)?(.*?)/?(?:/api/?)?$}, 1]
|
116
|
+
endpoint = "https://#{domain}/api"
|
117
|
+
config['default_endpoint'] = endpoint if agree("Use #{color domain, :bold} as default endpoint? ") { |q| q.default = 'yes' }
|
118
|
+
endpoint
|
128
119
|
end
|
120
|
+
self.api_endpoint = c[enterprise_name]
|
121
|
+
self.insecure = insecure unless insecure.nil?
|
122
|
+
session.ssl.delete :ca_file
|
123
|
+
endpoint_config['enterprise'] = true
|
124
|
+
@setup_ennterpise = true
|
125
|
+
end
|
129
126
|
|
130
|
-
|
127
|
+
def setup_enterprise?
|
128
|
+
@setup_ennterpise ||= false
|
129
|
+
!!enterprise_name and not @setup_ennterpise
|
130
|
+
end
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
132
|
+
def load_gh
|
133
|
+
gh_config = session.config['github']
|
134
|
+
gh_config &&= gh_config.inject({}) { |h, (k, v)| h.update(k.to_sym => v) }
|
135
|
+
gh_config ||= {}
|
136
|
+
gh_config[:ssl] = Travis::Client::Session::SSL_OPTIONS
|
137
|
+
gh_config[:ssl] = { verify: false } if gh_config[:api_url] && gh_config[:api_url] != 'https://api.github.com'
|
138
|
+
gh_config.delete :scopes
|
138
139
|
|
140
|
+
if debug?
|
139
141
|
gh_config[:instrumenter] = proc do |type, payload, &block|
|
140
142
|
next block.call unless type == 'http.gh'
|
141
|
-
time("GitHub API: #{payload[:verb].to_s.upcase} #{payload[:url]}", block)
|
142
|
-
end if debug?
|
143
143
|
|
144
|
-
|
144
|
+
time("GitHub API: #{payload[:verb].to_s.upcase} #{payload[:url]}", block)
|
145
|
+
end
|
145
146
|
end
|
146
147
|
|
147
|
-
|
148
|
-
|
149
|
-
GH.with({}).api_host
|
150
|
-
end
|
148
|
+
GH.set(gh_config)
|
149
|
+
end
|
151
150
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
157
|
-
end
|
151
|
+
def github_endpoint
|
152
|
+
load_gh
|
153
|
+
GH.with({}).api_host
|
154
|
+
end
|
158
155
|
|
159
|
-
|
160
|
-
|
156
|
+
def listen(*args)
|
157
|
+
super(*args) do |listener|
|
158
|
+
on_signal { listener.disconnect }
|
159
|
+
yield listener
|
161
160
|
end
|
161
|
+
end
|
162
162
|
|
163
|
-
|
164
|
-
|
165
|
-
|
163
|
+
def default_endpoint
|
164
|
+
ENV['TRAVIS_ENDPOINT'] || config['default_endpoint']
|
165
|
+
end
|
166
166
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
return " --pro" if pro?
|
167
|
+
def detected_endpoint
|
168
|
+
default_endpoint || Travis::Client::COM_URI
|
169
|
+
end
|
171
170
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
171
|
+
def endpoint_option
|
172
|
+
return "" if pro? and detected_endpoint?
|
173
|
+
return " --org" if org?
|
174
|
+
return " --pro" if pro?
|
177
175
|
|
178
|
-
|
176
|
+
if config['enterprise']
|
177
|
+
key, _ = config['enterprise'].detect { |k,v| v.start_with? api_endpoint }
|
178
|
+
return " -X" if key == "default"
|
179
|
+
return " -X #{key}" if key
|
179
180
|
end
|
180
181
|
|
181
|
-
|
182
|
-
|
183
|
-
|
182
|
+
" -e %p" % api_endpoint
|
183
|
+
end
|
184
|
+
|
185
|
+
def fetch_token
|
186
|
+
ENV['TRAVIS_TOKEN'] || endpoint_config['access_token']
|
187
|
+
end
|
184
188
|
end
|
185
189
|
end
|
186
190
|
end
|
data/lib/travis/cli/branches.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
4
6
|
module CLI
|
5
7
|
class Branches < RepoCommand
|
6
|
-
description
|
8
|
+
description 'displays the most recent build for each branch'
|
7
9
|
|
8
10
|
def run
|
9
11
|
repository.last_on_branch.each do |build|
|
10
12
|
say [
|
11
|
-
color("#{build.branch_info}:".ljust(longest + 2), [
|
13
|
+
color("#{build.branch_info}:".ljust(longest + 2), %i[info bold]),
|
12
14
|
color("##{build.number.to_s.ljust(4)} #{build.state}".ljust(16), build.color),
|
13
15
|
build.commit.subject
|
14
|
-
].join(
|
16
|
+
].join(' ').strip + "\n"
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def longest
|
23
|
+
repository.branches.keys.map { |b| b.size }.max
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/travis/cli/cache.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
@@ -16,61 +18,63 @@ module Travis
|
|
16
18
|
|
17
19
|
warn "Deleted the following caches:\n" if delete?
|
18
20
|
branches.each { |name, list| display_branch(name, list) }
|
19
|
-
size = caches.inject(0) { |s,c| s + c.size }
|
20
|
-
say
|
21
|
+
size = caches.inject(0) { |s, c| s + c.size }
|
22
|
+
say 'Overall size of above caches: ' << formatter.file_size(size)
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
say "no caches found"
|
28
|
-
exit
|
29
|
-
end
|
27
|
+
def check_caches
|
28
|
+
return if caches.any?
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
puts
|
35
|
-
end
|
30
|
+
say 'no caches found'
|
31
|
+
exit
|
32
|
+
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
].join(" ") << "\n"
|
43
|
-
end
|
34
|
+
def display_branch(name, list)
|
35
|
+
say color(name ? "On branch #{name}:" : 'Global:', :important)
|
36
|
+
list.each { |c| display_cache(c) }
|
37
|
+
puts
|
38
|
+
end
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
40
|
+
def display_cache(cache)
|
41
|
+
say [
|
42
|
+
color(cache.slug.ljust(space), :bold),
|
43
|
+
'last modified: ' << formatter.time(cache.last_modified),
|
44
|
+
'size: ' << formatter.file_size(cache.size)
|
45
|
+
].join(' ') << "\n"
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
def params
|
49
|
+
params = {}
|
50
|
+
params[:branch] = branch if branch?
|
51
|
+
params[:match] = match if match?
|
52
|
+
params
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
def caches
|
56
|
+
@caches ||= drop? ? repository.delete_caches(params) : repository.caches(params)
|
57
|
+
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
def space
|
60
|
+
@space ||= caches.map(&:slug).map(&:size).max
|
61
|
+
end
|
62
|
+
|
63
|
+
def drop?
|
64
|
+
return false unless delete?
|
65
|
+
return true if force?
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
error 'not deleting caches without --force' unless interactive?
|
68
|
+
error 'aborted' unless danger_zone? "Do you really want to delete #{description}?"
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def description
|
73
|
+
description = color('all caches', :important)
|
74
|
+
description << " on branch #{color(branch, :important)}" if branch?
|
75
|
+
description << " that match #{color(match, :important)}" if match?
|
76
|
+
description
|
77
|
+
end
|
74
78
|
end
|
75
79
|
end
|
76
80
|
end
|
data/lib/travis/cli/cancel.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
4
6
|
module CLI
|
5
7
|
class Cancel < RepoCommand
|
6
|
-
description
|
8
|
+
description 'cancels a job or build'
|
7
9
|
|
8
10
|
def run(number = last_build.number)
|
9
11
|
authenticate
|
@@ -11,7 +13,7 @@ module Travis
|
|
11
13
|
error "could not find job or build #{repository.slug}##{number}" unless entity
|
12
14
|
entity.cancel
|
13
15
|
|
14
|
-
say
|
16
|
+
say 'canceled', "#{entity.class.one} ##{entity.number} has been %s"
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|