Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/annocheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
builddir: build
makeup: true

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/auto_review_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ on:
pull_request_target:
types: [opened, ready_for_review, reopened]
branches: [master]
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to review'
required: true
type: number

permissions:
contents: read
Expand All @@ -11,7 +17,7 @@ jobs:
auto-review-pr:
name: Auto Review PR
runs-on: ubuntu-latest
if: ${{ github.repository == 'ruby/ruby' && github.base_ref == 'master' }}
if: ${{ github.repository == 'ruby/ruby' && (github.base_ref == 'master' || github.event_name == 'workflow_dispatch') }}

permissions:
pull-requests: write
Expand All @@ -23,7 +29,7 @@ jobs:
with:
persist-credentials: false

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.4'
bundler: none
Expand All @@ -32,4 +38,4 @@ jobs:
run: ruby tool/auto_review_pr.rb "$GITHUB_PR_NUMBER"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
2 changes: 1 addition & 1 deletion .github/workflows/baseruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- ruby-3.3

steps:
- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: ${{ matrix.ruby }}
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bundled_gems.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: 4.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: ./.github/actions/setup/directories

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}
persist-credentials: false

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: head

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/modgc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: ./.github/actions/setup/ubuntu
if: ${{ contains(matrix.os, 'ubuntu') }}

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/parse_y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

- uses: ./.github/actions/setup/ubuntu

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
persist-credentials: false

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: 3.3.4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spec_guards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
with:
persist-credentials: false

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: ${{ matrix.ruby }}
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_default_gems.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
token: ${{ github.repository == 'ruby/ruby' && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.4'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
with:
arch: ${{ matrix.arch }}

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
run: |
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- run: md build
working-directory:

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
# windows-11-arm has only 3.4.1, 3.4.2, 3.4.3, head
ruby-version: ${{ !endsWith(matrix.os, 'arm') && '3.1' || '3.4' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:

- uses: ./.github/actions/setup/ubuntu

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
rustup install ${{ matrix.rust_version }} --profile minimal
rustup default ${{ matrix.rust_version }}

- uses: taiki-e/install-action@de6bbd1333b8f331563d54a051e542c7dfef81c3 # v2.68.34
- uses: taiki-e/install-action@94a7388bec5d4c8dd93e3ebf09e0ff448f3f6f4d # v2.68.35
with:
tool: nextest@0.9
if: ${{ matrix.test_task == 'zjit-check' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ jobs:

- uses: ./.github/actions/setup/ubuntu

- uses: ruby/setup-ruby@c984c1a20bb35a1cbda04477c816cea024418be9 # v1.294.0
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.1'
bundler: none

- uses: taiki-e/install-action@de6bbd1333b8f331563d54a051e542c7dfef81c3 # v2.68.34
- uses: taiki-e/install-action@94a7388bec5d4c8dd93e3ebf09e0ff448f3f6f4d # v2.68.35
with:
tool: nextest@0.9
if: ${{ matrix.test_task == 'zjit-check' }}
Expand Down
49 changes: 33 additions & 16 deletions lib/rubygems/commands/sources_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ def initialize
end

def add_source(source_uri) # :nodoc:
check_rubygems_https source_uri

source = Gem::Source.new source_uri

check_typo_squatting(source)
source = build_new_source(source_uri)
source_uri = source.uri.to_s

begin
if Gem.sources.include? source
Expand All @@ -76,11 +73,8 @@ def add_source(source_uri) # :nodoc:
end

def append_source(source_uri) # :nodoc:
check_rubygems_https source_uri

source = Gem::Source.new source_uri

check_typo_squatting(source)
source = build_new_source(source_uri)
source_uri = source.uri.to_s

begin
source.load_specs :released
Expand All @@ -103,11 +97,8 @@ def append_source(source_uri) # :nodoc:
end

def prepend_source(source_uri) # :nodoc:
check_rubygems_https source_uri

source = Gem::Source.new source_uri

check_typo_squatting(source)
source = build_new_source(source_uri)
source_uri = source.uri.to_s

begin
source.load_specs :released
Expand Down Expand Up @@ -141,6 +132,19 @@ def check_typo_squatting(source)
end
end

def normalize_source_uri(source_uri) # :nodoc:
# Ensure the source URI has a trailing slash for proper RFC 2396 path merging
# Without a trailing slash, the last path segment is treated as a file and removed
# during relative path resolution (e.g., "/blish" + "gems/foo.gem" = "/gems/foo.gem")
# With a trailing slash, it's treated as a directory (e.g., "/blish/" + "gems/foo.gem" = "/blish/gems/foo.gem")
uri = Gem::URI.parse(source_uri)
uri.path = uri.path.gsub(%r{/+\z}, "") + "/" if uri.path && !uri.path.empty?
uri.to_s
rescue Gem::URI::Error
# If parsing fails, return the original URI and let later validation handle it
source_uri
end

def check_rubygems_https(source_uri) # :nodoc:
uri = Gem::URI source_uri

Expand Down Expand Up @@ -273,7 +277,8 @@ def execute
end

def remove_source(source_uri) # :nodoc:
source = Gem::Source.new source_uri
source = build_source(source_uri)
source_uri = source.uri.to_s

if configured_sources&.include? source
Gem.sources.delete source
Expand Down Expand Up @@ -328,4 +333,16 @@ def configured_sources
def config_file_name
Gem.configuration.config_file_name
end

def build_source(source_uri)
source_uri = normalize_source_uri(source_uri)
Gem::Source.new(source_uri)
end

def build_new_source(source_uri)
source = build_source(source_uri)
check_rubygems_https(source.uri.to_s)
check_typo_squatting(source)
source
end
end
8 changes: 8 additions & 0 deletions spec/bundler/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def self.ruby=(ruby)
ENV["XDG_CACHE_HOME"] = nil
ENV["GEMRC"] = nil

# Prevent tests from modifying the user's global git config.
# GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM are available since Git 2.32.
git_version = `git --version`[/(\d+\.\d+\.\d+)/, 1]
if Gem::Version.new(git_version) >= Gem::Version.new("2.32")
ENV["GIT_CONFIG_GLOBAL"] = File.join(ENV["HOME"], ".gitconfig")
ENV["GIT_CONFIG_NOSYSTEM"] = "1"
end

# Don't wrap output in tests
ENV["THOR_COLUMNS"] = "10000"

Expand Down
3 changes: 3 additions & 0 deletions spec/bundler/support/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ def inspect
end
end

git_version = Gem::Version.new(`git --version`[/(\d+\.\d+\.\d+)/, 1])

RSpec.configure do |config|
config.filter_run_excluding realworld: true

config.filter_run_excluding rubygems: RequirementChecker.against(Gem.rubygems_version)
config.filter_run_excluding git: RequirementChecker.against(git_version)
config.filter_run_excluding ruby_repo: !ENV["GEM_COMMAND"].nil?
config.filter_run_excluding no_color_tty: Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?
config.filter_run_excluding permissions: Gem.win_platform?
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_thread_cv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_condvar_wait_and_broadcast
end
end
end
sleep 0.1
Thread.pass until threads.all?(&:stop?)
mutex.synchronize do
result << "P1"
condvar.broadcast
Expand Down
Loading