Skip to content

Commit

Permalink
remove org references (#861)
Browse files Browse the repository at this point in the history
* org endpoint removed

* rake/test and completion issue fix

* completion
  • Loading branch information
gbarc-dt authored May 29, 2024
1 parent 5022c24 commit 39dd021
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 135 deletions.
213 changes: 111 additions & 102 deletions assets/travis.sh

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/travis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ module Travis
autoload :Pro, 'travis/pro'
autoload :Version, 'travis/version'

include Client::Namespace.new(Client::COM_URI)
include Client::Namespace.new
end
14 changes: 3 additions & 11 deletions lib/travis/cli/api_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ class ApiCommand < Command

on('-e', '--api-endpoint URL', 'Travis API server to talk to')
on('-I', '--[no-]insecure', 'do not verify SSL certificate of API endpoint')
on('--pro', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
on('--com', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}'") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c, _| c.api_endpoint = Travis::Client::ORG_URI }
on('--staging', 'talks to staging system') { |c, _| c.api_endpoint = c.api_endpoint.gsub(/api/, 'api-staging') }
on('--pro', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}' [deprecated]") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
on('--com', "short-cut for --api-endpoint '#{Travis::Client::COM_URI}' [deprecated]") { |c, _| c.api_endpoint = Travis::Client::COM_URI }
on('-t', '--token [ACCESS_TOKEN]', 'access token to use') { |c, t| c.access_token = t }

on('--debug', 'show API requests') do |c, _|
Expand Down Expand Up @@ -64,7 +62,7 @@ def setup
endpoint_config['insecure'] = insecure unless insecure.nil?
self.insecure = endpoint_config['insecure']
session.ssl = { verify: false } if insecure?
authenticate if pro? || enterprise?
authenticate
end

def enterprise?
Expand All @@ -75,10 +73,6 @@ def pro?
api_endpoint == Travis::Client::COM_URI
end

def org?
api_endpoint == Travis::Client::ORG_URI
end

def detected_endpoint?
api_endpoint == detected_endpoint
end
Expand Down Expand Up @@ -170,8 +164,6 @@ def detected_endpoint

def endpoint_option
return "" if pro? and detected_endpoint?
return " --org" if org?
return " --pro" if pro?

if config['enterprise']
key, _ = config['enterprise'].detect { |k,v| v.start_with? api_endpoint }
Expand Down
6 changes: 1 addition & 5 deletions lib/travis/cli/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setup
super
repos.map! { |r| repo(r) }
repos.concat(user.repositories) if my_repos?
setup_notification(!firehose? || :dummy) unless notification
setup_notification(true) unless notification
debug "Using notifications: #{notification.class.name[/[^:]+$/]}"
end

Expand Down Expand Up @@ -67,10 +67,6 @@ def events
events
end

def firehose?
org? and repos.empty?
end

def all?
!pull? and !push?
end
Expand Down
4 changes: 2 additions & 2 deletions lib/travis/cli/repo_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Travis
module CLI
class RepoCommand < ApiCommand
GIT_REGEX = %r{/?(.*/.+?)(\.git)?$}
TRAVIS = %r{^https://(staging-)?api\.travis-ci\.(org|com)}
TRAVIS = %r{^https://(staging-)?api\.travis-ci\.com}
on('-g', '--github-token TOKEN', 'identify by GitHub token')
on('-r', '--repo SLUG', 'repository to use (will try to detect from current git clone)') do |c, slug|
c.slug = slug
Expand Down Expand Up @@ -133,7 +133,7 @@ def detect_api_endpoint
repo_config['endpoint'] ||= begin
load_gh
GH.head("/repos/#{slug}")
Travis::Client::ORG_URI
Travis::Client::COM_URI
rescue GH::Error
Travis::Client::COM_URI
end
Expand Down
1 change: 0 additions & 1 deletion lib/travis/cli/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def endpoints

def endpoint_name(url, prefix = '')
case url
when Travis::Client::ORG_URI then "#{prefix}org"
when Travis::Client::COM_URI then "#{prefix}com"
when /api-staging\.travis-ci/ then endpoint_name(url.sub('api-staging.', 'api.'), 'staging-')
else
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/cli/setup/releases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def github
g.github_token = github_token
g.debug = proc { |log| debug(log) }
g.after_tokens = proc { g.explode = true and error('no suitable github token found') }
g.scopes = org? ? ['public_repo'] : ['repo']
g.scopes = ['repo']
g.note = "automatic releases for #{repository.slug}"
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/travis/cli/sshkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Sshkey < RepoCommand
def_delegators :repository, :ssh_key

def run
error "SSH keys are not available on #{color(session.config['host'], :bold)}" if org?
delete_key if delete?
update_key File.read(upload), upload if upload?
update_key $stdin.read, 'stdin' if stdin?
Expand Down
1 change: 0 additions & 1 deletion lib/travis/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
module Travis
module Client

ORG_URI = 'https://api.travis-ci.org/'
COM_URI = 'https://api.travis-ci.com/'

def self.new(options = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/pro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require 'travis/client'

module Travis
Pro = Client::Namespace.new(Client::COM_URI)
Pro = Client::Namespace.new
end
2 changes: 1 addition & 1 deletion lib/travis/tools/completion.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
# frozen_string_literal: false

require 'travis/tools/assets'
require 'travis/cli'
Expand Down
1 change: 1 addition & 0 deletions lib/travis/tools/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Github
:hub_path, :oauth_paths, :composer_path, :git_config_keys, :debug, :no_token, :check_token

def initialize(options = nil)

@check_token = true
@ask_login = proc { raise 'ask_login callback not set' }
@after_tokens = proc {}
Expand Down
2 changes: 2 additions & 0 deletions spec/cli/encrypt_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
CMD_TARGET = 'README.md'

before do

ENV['TRAVIS_TOKEN'] = 'token'
Digest.stub(:hexencode).and_return 'randomhex' # to avoid relying on Dir.pwd value for hex
end

Expand Down
3 changes: 3 additions & 0 deletions spec/cli/encrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
require 'spec_helper'

describe Travis::CLI::Encrypt do

before { ENV['TRAVIS_TOKEN'] = 'token' }

example 'travis encrypt foo' do
run_cli('encrypt', 'foo').should be_success
stdout.should match(/^".{60,}"\n$/)
Expand Down
3 changes: 3 additions & 0 deletions spec/cli/history_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
require 'spec_helper'

describe Travis::CLI::History do

before { ENV['TRAVIS_TOKEN'] = 'token' }

example 'travis history' do
run_cli('history').should be_success
stdout.should be == "#6180 failed: master Associaton -> Association\n"
Expand Down
3 changes: 3 additions & 0 deletions spec/cli/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
require 'spec_helper'

describe Travis::CLI::Init do

before { ENV['TRAVIS_TOKEN'] = 'token' }

old_path = Dir.pwd
tmp_path = File.expand_path('travis-spec-init', Dir.tmpdir)

Expand Down
2 changes: 2 additions & 0 deletions spec/cli/logs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'spec_helper'

describe Travis::CLI::Logs do
before { ENV['TRAVIS_TOKEN'] = 'token' }

example 'logs 6180.1' do
run_cli('logs', '6180.1', '-E').should be_success
stdout.should be == "$ export GEM=railties\n"
Expand Down
9 changes: 6 additions & 3 deletions spec/cli/open_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
require 'spec_helper'

describe Travis::CLI::Open do

before { ENV['TRAVIS_TOKEN'] = 'token' }

example 'travis open -p' do
run_cli('open', '-p').should be_success
stdout.should match(%r{https://travis-ci.org/[\w\W]*/travis\.rb})
stdout.should match(%r{https://travis-ci.com/[\w\W]*/travis\.rb})
end

example 'travis open 6180 -p' do
run_cli('open', '6180', '-p').should be_success
stdout.should match(%r{https://travis-ci.org/[\w\W]*/travis\.rb/builds/4125095})
stdout.should match(%r{https://travis-ci.com/[\w\W]*/travis\.rb/builds/4125095})
end

example 'travis open 6180.1 -p' do
run_cli('open', '6180.1', '-p').should be_success
stdout.should match(%r{https://travis-ci.org/[\w\W]*/travis\.rb/jobs/4125096})
stdout.should match(%r{https://travis-ci.com/[\w\W]*/travis\.rb/jobs/4125096})
end

example 'travis open -pg' do
Expand Down
2 changes: 2 additions & 0 deletions spec/cli/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'spec_helper'

describe Travis::CLI::Show do
before { ENV['TRAVIS_TOKEN'] = 'token' }

example 'show 6180.1' do
run_cli('show', '6180.1', '-E').should be_success
stdout.should include('Config: ')
Expand Down
3 changes: 3 additions & 0 deletions spec/cli/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
require 'spec_helper'

describe Travis::CLI::Status do

before { ENV['TRAVIS_TOKEN'] = 'token' }

example 'travis status' do
run_cli('status').should be_success
stdout.should be == "failed\n"
Expand Down
2 changes: 1 addition & 1 deletion spec/client/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@
end

describe 'config' do
its(:config) { is_expected.to be == { 'host' => 'travis-ci.org' } }
its(:config) { is_expected.to be == { 'host' => 'travis-ci.com' } }
end
end
2 changes: 1 addition & 1 deletion spec/support/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ def authorized?
end

get '/config' do
{ 'config' => { 'host' => 'travis-ci.org' } }.to_json
{ 'config' => { 'host' => 'travis-ci.com' } }.to_json
end

get '/logs/3168318' do
Expand Down
2 changes: 0 additions & 2 deletions spec/support/fake_travis_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ completion_version: 1.8.8
endpoints:
https://api.travis-ci.com/:
access_token: fake-travis-com-token
https://api.travis-ci.org/:
access_token: fake-travis-org-token
https://travis-ci-enterprise/api:
access_token: fake-travis-enterprise-token
2 changes: 1 addition & 1 deletion travis.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ Gem::Specification.new do |s|
s.add_dependency 'json_pure', '~> 2.6.3'
s.add_dependency 'launchy', '~> 2.5.2'
s.add_dependency 'pusher-client', '~> 0.6.2'
s.add_development_dependency 'rack-test', '~> 2.1.0'
s.add_dependency 'rack-test', '~> 2.1.0'
s.add_development_dependency 'rspec', '~> 3.12'
s.add_development_dependency 'rspec-its', '~> 1.3.0'
s.add_development_dependency 'sinatra', '~> 3.0.6'
Expand Down

0 comments on commit 39dd021

Please sign in to comment.