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
33 changes: 17 additions & 16 deletions .github/workflows/check_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,16 @@ jobs:
- name: Check if to generate documents
id: rdoc
run: |
ref=$(sed 's/#.*//;/^rdoc /!d' gems/bundled_gems | awk '{print $4}')
echo ref=$ref >> $GITHUB_OUTPUT
# Generate only when document commit/PR
if: >-
${{false
|| contains(github.event.head_commit.message, '[ruby/rdoc]')
|| contains(github.event.head_commit.message, '[DOC]')
|| contains(github.event.pull_request.title, '[DOC]')
|| contains(github.event.pull_request.labels.*.name, 'Documentation')
}}
set -- $(sed 's/#.*//;/^rdoc /!d' gems/bundled_gems)
{ echo version=$2; echo ref=$4; } >> $GITHUB_OUTPUT
echo RDOC='ruby -W0 --disable-gems tool/rdoc-srcdir -q' >> $GITHUB_ENV

- name: Checkout rdoc
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: ruby/rdoc
ref: ${{ steps.rdoc.outputs.ref }}
path: .bundle/gems/rdoc-0
path: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }}
if: ${{ steps.rdoc.outputs.ref != '' }}

- name: Generate rdoc
Expand All @@ -88,18 +81,26 @@ jobs:
bundle config --local path vendor/bundle
bundle install --jobs 4
bundle exec rake generate
working-directory: .bundle/gems/rdoc-0
working-directory: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }}
if: ${{ steps.rdoc.outputs.ref != '' }}

- name: Core docs coverage
run: |
$RDOC -C -x ^ext -x ^lib .

- name: Generate docs
id: docs
run: |
$RDOC -C -x ^ext -x ^lib .
$RDOC --op html .
echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT
env:
RDOC: ruby -W0 --disable-gems tool/rdoc-srcdir -q
if: ${{ steps.rdoc.outcome == 'success' }}
# Generate only when document commit/PR
if: >-
${{false
|| contains(github.event.head_commit.message, '[ruby/rdoc]')
|| contains(github.event.head_commit.message, '[DOC]')
|| contains(github.event.pull_request.title, '[DOC]')
|| contains(github.event.pull_request.labels.*.name, 'Documentation')
}}

- name: Upload docs
uses: actions/upload-artifact@v4
Expand Down
10 changes: 5 additions & 5 deletions doc/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ require 'English'

### Separators

| Variable | English | Contains |
|-------------|----------------------------|--------------------------------------------|
| `$/` | `$INPUT_RECORD_SEPARATOR` | Input record separator; initially newline. |
| `$\\\\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator; initially `nil`. |
| Variable | English | Contains |
|----------|----------------------------|--------------------------------------------|
| `$/` | `$INPUT_RECORD_SEPARATOR` | Input record separator; initially newline. |
| `$\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator; initially `nil`. |

### Streams

Expand Down Expand Up @@ -179,7 +179,7 @@ English - `$INPUT_RECORD_SEPARATOR`, `$RS`.

Aliased as `$-0`.

### `$\\` (Output Record Separator)
### `$\` (Output Record Separator)

An output record separator, initially `nil`.

Expand Down
4 changes: 2 additions & 2 deletions gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# - revision: revision in repository-url to test
# if `revision` is not given, "v"+`version` or `version` will be used.

minitest 5.25.5 https://github.com/minitest/minitest
minitest 5.26.0 https://github.com/minitest/minitest
power_assert 2.0.5 https://github.com/ruby/power_assert f88e406e7c9e0810cc149869582afbae1fb84c4a
rake 13.3.0 https://github.com/ruby/rake
test-unit 3.7.0 https://github.com/test-unit/test-unit
rexml 3.4.4 https://github.com/ruby/rexml
rss 0.3.1 https://github.com/ruby/rss
net-ftp 0.3.8 https://github.com/ruby/net-ftp
net-imap 0.5.10 https://github.com/ruby/net-imap 71c0288b9a8f78a7125a4ce2980ab421acdf5836
net-imap 0.5.12 https://github.com/ruby/net-imap
net-pop 0.1.2 https://github.com/ruby/net-pop
net-smtp 0.5.1 https://github.com/ruby/net-smtp
matrix 0.4.3 https://github.com/ruby/matrix
Expand Down
3 changes: 3 additions & 0 deletions namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,20 +986,23 @@ rb_f_dump_classext(VALUE recv, VALUE klass)
return res;
}

/* :nodoc: */
static VALUE
rb_namespace_root_p(VALUE namespace)
{
const rb_namespace_t *ns = (const rb_namespace_t *)rb_get_namespace_t(namespace);
return RBOOL(NAMESPACE_ROOT_P(ns));
}

/* :nodoc: */
static VALUE
rb_namespace_main_p(VALUE namespace)
{
const rb_namespace_t *ns = (const rb_namespace_t *)rb_get_namespace_t(namespace);
return RBOOL(NAMESPACE_MAIN_P(ns));
}

/* :nodoc: */
static VALUE
rb_namespace_user_p(VALUE namespace)
{
Expand Down
40 changes: 9 additions & 31 deletions tool/commit-email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,14 @@ def diff_info(info, uri)
end

def make_header(to, from, info)
headers = []
headers << x_author(info)
headers << x_repository(info)
headers << x_revision(info)
headers << x_id(info)
headers << 'Mime-Version: 1.0'
headers << 'Content-Type: text/plain; charset=utf-8'
headers << 'Content-Transfer-Encoding: quoted-printable'
headers << "From: #{from}"
headers << "To: #{to}"
headers << "Subject: #{make_subject(info)}"
headers.find_all do |header|
/\A\s*\z/ !~ header
end.join("\n")
<<~EOS
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
From: #{from}
To: #{to}
Subject: #{make_subject(info)}
EOS
end

def make_subject(info)
Expand All @@ -356,24 +350,8 @@ def make_from(name:, email:)
end
end

def x_author(info)
"X-SVN-Author: #{b_encode(info.author)}"
end

def x_repository(info)
'X-SVN-Repository: XXX'
end

def x_id(info)
"X-SVN-Commit-Id: #{info.entire_sha256}"
end

def x_revision(info)
"X-SVN-Revision: #{info.revision}"
end

def make_mail(to, from, info, viewer_uri:)
"#{make_header(to, from, info)}\n#{make_body(info, viewer_uri: viewer_uri)}"
make_header(to, from, info) + make_body(info, viewer_uri: viewer_uri)
end
end

Expand Down
12 changes: 10 additions & 2 deletions tool/test/init.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# This file includes the settings for "make test-all".
# This file includes the settings for "make test-all" and "make test-tool".
# Note that this file is loaded not only by test/runner.rb but also by tool/lib/test/unit/parallel.rb.

ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze
# Prevent test-all from using bundled gems
["GEM_HOME", "GEM_PATH"].each do |gem_env|
# Preserve the gem environment prepared by tool/runruby.rb for test-tool, which uses bundled gems.
ENV["BUNDLED_#{gem_env}"] = ENV[gem_env]

ENV[gem_env] = "".freeze
end
ENV["GEM_SKIP"] = "".freeze

ENV.delete("RUBY_CODESIGN")

Warning[:experimental] = false
Expand Down
60 changes: 41 additions & 19 deletions tool/test/test_commit_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,79 @@
require 'open3'

class TestCommitEmail < Test::Unit::TestCase
STDIN_DELIMITER = "---\n"

def setup
@ruby = Dir.mktmpdir
Dir.chdir(@ruby) do
git('init')
git('init', '--initial-branch=master')
git('config', 'user.name', 'Jóhän Grübél')
git('config', 'user.email', 'johan@example.com')
git('commit', '--allow-empty', '-m', 'New repository initialized by cvs2svn.')
git('commit', '--allow-empty', '-m', 'Initial revision')
git('commit', '--allow-empty', '-m', 'version 1.0.0')
env = { 'GIT_AUTHOR_DATE' => '2025-10-08T12:00:00Z', 'TZ' => 'UTC' }
git('commit', '--allow-empty', '-m', 'New repository initialized by cvs2svn.', env:)
git('commit', '--allow-empty', '-m', 'Initial revision', env:)
git('commit', '--allow-empty', '-m', 'version 1.0.0', env:)
end

@sendmail = File.join(Dir.mktmpdir, 'sendmail')
File.write(@sendmail, <<~SENDMAIL)
#!/usr/bin/env ruby
p ARGV
print #{STDIN_DELIMITER.dump}
puts STDIN.read
SENDMAIL
FileUtils.chmod(0755, @sendmail)

@commit_email = File.expand_path('../../tool/commit-email.rb', __dir__)
end

# Just testing an exit status :p
# TODO: prepare something in test/fixtures/xxx and test output
def test_successful_run
_, err, status = EnvUtil.invoke_ruby([gem_env, '-e', 'require "nkf"'], '', false, true)
unless status.success?
omit "bundled gems are not available: #{err}"
end
def test_sendmail_encoding
omit 'the sendmail script does not work on windows' if windows?

Dir.chdir(@ruby) do
before_rev = git('rev-parse', 'HEAD^').chomp
after_rev = git('rev-parse', 'HEAD').chomp
short_rev = after_rev[0...10]

out, _, status = EnvUtil.invoke_ruby([
{ 'SENDMAIL' => @sendmail }.merge!(gem_env),
{ 'SENDMAIL' => @sendmail, 'TZ' => 'UTC' }.merge!(gem_env),
@commit_email, './', 'cvs-admin@ruby-lang.org',
git('rev-parse', 'HEAD^').chomp, git('rev-parse', 'HEAD').chomp, 'refs/heads/master',
before_rev, after_rev, 'refs/heads/master',
'--viewer-uri', 'https://github.com/ruby/ruby/commit/',
'--error-to', 'cvs-admin@ruby-lang.org',
], '', true)
assert_true(status.success?, out)
stdin = out.b.split(STDIN_DELIMITER.b, 2).last.force_encoding('UTF-8')

assert_true(status.success?)
assert_equal(stdin, <<~EOS)
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
From: =?UTF-8?B?SsOzaMOkbiBHcsO8YsOpbA==?= <noreply@ruby-lang.org>
To: cvs-admin@ruby-lang.org
Subject: #{short_rev} (master): =?UTF-8?B?dmVyc2lvbuOAgDEuMC4w?=
J=C3=B3h=C3=A4n Gr=C3=BCb=C3=A9l\t2025-10-08 12:00:00 +0000 (Wed, 08 Oct 2=
025)

New Revision: #{short_rev}

https://github.com/ruby/ruby/commit/#{short_rev}

Log:
version=E3=80=801.0.0=
EOS
end
end

private

# Cancel the gem environments set by tool/test/init.rb
# Resurrect the gem environment preserved by tool/test/init.rb.
# This should work as long as you have run `make up` or `make install`.
def gem_env
{ 'GEM_PATH' => nil, 'GEM_HOME' => nil }
{ 'GEM_PATH' => ENV['BUNDLED_GEM_PATH'], 'GEM_HOME' => ENV['BUNDLED_GEM_HOME'] }
end

def git(*cmd)
out, status = Open3.capture2('git', *cmd)
def git(*cmd, env: {})
out, status = Open3.capture2(env, 'git', *cmd)
unless status.success?
raise "git #{cmd.shelljoin}\n#{out}"
end
Expand Down