From 4170b70d32c3165da92eb258556f3ddf5b9767f3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 22:06:30 +0900 Subject: [PATCH 01/11] [ruby/net-http] [DOC] Fix too stopped documentations https://github.com/ruby/net-http/commit/58685b78ab --- lib/net/http.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/net/http.rb b/lib/net/http.rb index 43e3349ac0e1b1..7efb468e782e06 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1825,6 +1825,8 @@ def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_use_ss } end + # :startdoc: + class << HTTP # Returns true if self is a class which was created by HTTP::Proxy. def proxy_class? @@ -1948,6 +1950,7 @@ def edit_path(path) path end end + # :startdoc: # # HTTP operations From 953fee11b39197f4ab6170c4c0a48a396be2b4cc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 19:09:28 +0900 Subject: [PATCH 02/11] [DOC] Document of Coverage.line_stub from NEWS-2.6.0 --- ext/coverage/lib/coverage.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/coverage/lib/coverage.rb b/ext/coverage/lib/coverage.rb index f1923ef366cbf3..4bd20e22cbadbe 100644 --- a/ext/coverage/lib/coverage.rb +++ b/ext/coverage/lib/coverage.rb @@ -1,6 +1,11 @@ require "coverage.so" module Coverage + # call-seq: + # line_stub(file) -> array + # + # A simple helper function that creates the "stub" of line coverage + # from a given source code. def self.line_stub(file) lines = File.foreach(file).map { nil } iseqs = [RubyVM::InstructionSequence.compile_file(file)] From 87c39667bf881527d4ddfe1c558fc98adb9543a0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:13:01 +0900 Subject: [PATCH 03/11] [DOC] ObjectSpace.trace_object_allocations_debug_start --- ext/objspace/object_tracing.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c index 0156642ef25897..63eec6739320f9 100644 --- a/ext/objspace/object_tracing.c +++ b/ext/objspace/object_tracing.c @@ -411,6 +411,13 @@ object_allocations_reporter(FILE *out, void *ptr) fprintf(out, "== object_allocations_reporter: END\n"); } +/* + * call-seq: trace_object_allocations_debug_start + * + * Starts tracing object allocations for GC debugging. + * If you encounter the BUG "... is T_NONE" (and so on) on your + * application, please try this method at the beginning of your app. + */ static VALUE trace_object_allocations_debug_start(VALUE self) { From 26fc938b9f81a023494ca356583c7c1a86972619 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:48:30 +0900 Subject: [PATCH 04/11] [DOC] Sort undocumented items by locations --- common.mk | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common.mk b/common.mk index fe8ef3b19efe43..093fea6b3fb56c 100644 --- a/common.mk +++ b/common.mk @@ -624,15 +624,20 @@ html: PHONY main srcs-doc @echo Generating RDoc HTML files $(Q) $(RDOC) --op "$(HTMLOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) . +RDOC_COVERAGE_EXCLUDES = -x ^ext/json -x ^ext/openssl -x ^ext/psych \ + -x ^lib/bundler -x ^lib/rubygems \ + -x ^lib/did_you_mean -x ^lib/error_highlight -x ^lib/syntax_suggest + rdoc-coverage: PHONY main srcs-doc @echo Generating RDoc coverage report - $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) . + $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) $(RDOC_COVERAGE_EXCLUDES) . undocumented: PHONY main srcs-doc - $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) . | \ + $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) $(RDOC_COVERAGE_EXCLUDES) . | \ sed -n \ -e '/^ *# in file /{' -e 's///;N;s/\n/: /p' -e '}' \ - -e 's/^ *\(.*[^ ]\) *# in file \(.*\)/\2: \1/p' | sort + -e 's/^ *\(.*[^ ]\) *# in file \(.*\)/\2: \1/p' | \ + sort -t: -k1,1 -k2n,2 RDOCBENCHOUT=/tmp/rdocbench From af610e107c3a7515228843eb6b1c5978f2ee2685 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 21:58:53 +0900 Subject: [PATCH 05/11] Revert "[ruby/net-http] [DOC] Suppress documentation for internals" This reverts commit 155cdce539a95b510a80a19e3840cde6b293cd4d. --- lib/net/http.rb | 35 +++++++---------- lib/net/http/exceptions.rb | 3 +- lib/net/http/generic_request.rb | 2 - lib/net/http/header.rb | 12 ++---- lib/net/http/requests.rb | 16 +------- lib/net/http/response.rb | 3 +- lib/net/http/responses.rb | 67 --------------------------------- 7 files changed, 21 insertions(+), 117 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 7efb468e782e06..9511f19f268730 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1321,9 +1321,6 @@ def response_body_encoding=(value) # Sets the proxy password; # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. attr_writer :proxy_pass - - # Sets wheter the proxy uses SSL; - # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. attr_writer :proxy_use_ssl # Returns the IP address for the connection. @@ -1635,21 +1632,6 @@ def start # :yield: http self end - # Finishes the \HTTP session: - # - # http = Net::HTTP.new(hostname) - # http.start - # http.started? # => true - # http.finish # => nil - # http.started? # => false - # - # Raises IOError if not in a session. - def finish - raise IOError, 'HTTP session not yet started' unless started? - do_finish - end - - # :stopdoc: def do_start connect @started = true @@ -1776,6 +1758,20 @@ def on_connect end private :on_connect + # Finishes the \HTTP session: + # + # http = Net::HTTP.new(hostname) + # http.start + # http.started? # => true + # http.finish # => nil + # http.started? # => false + # + # Raises IOError if not in a session. + def finish + raise IOError, 'HTTP session not yet started' unless started? + do_finish + end + def do_finish @started = false @socket.close if @socket @@ -1921,7 +1917,6 @@ def proxy_pass alias proxyport proxy_port #:nodoc: obsolete private - # :stopdoc: def unescape(value) require 'cgi/escape' @@ -2405,8 +2400,6 @@ def send_entity(path, data, initheader, dest, type, &block) res end - # :stopdoc: - IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc: def transport_request(req) diff --git a/lib/net/http/exceptions.rb b/lib/net/http/exceptions.rb index 4342cfc0ef4be3..ceec8f7b0a3822 100644 --- a/lib/net/http/exceptions.rb +++ b/lib/net/http/exceptions.rb @@ -3,7 +3,7 @@ module Net # Net::HTTP exception class. # You cannot use Net::HTTPExceptions directly; instead, you must use # its subclasses. - module HTTPExceptions # :nodoc: + module HTTPExceptions def initialize(msg, res) #:nodoc: super msg @response = res @@ -12,7 +12,6 @@ def initialize(msg, res) #:nodoc: alias data response #:nodoc: obsolete end - # :stopdoc: class HTTPError < ProtocolError include HTTPExceptions end diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb index d9a4c4fef05ad5..c92004e5578b38 100644 --- a/lib/net/http/generic_request.rb +++ b/lib/net/http/generic_request.rb @@ -264,8 +264,6 @@ def update_uri(addr, port, ssl) # :nodoc: internal use only private - # :stopdoc: - class Chunker #:nodoc: def initialize(sock) @sock = sock diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 5dcdcc7d74051c..f6c36f1b5e78e7 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -179,9 +179,7 @@ # - #each_value: Passes each string field value to the block. # module Net::HTTPHeader - # The maximum length of HTTP header keys. MAX_KEY_LENGTH = 1024 - # The maximum length of HTTP header values. MAX_FIELD_LENGTH = 65536 def initialize_http_header(initheader) #:nodoc: @@ -269,7 +267,6 @@ def add_field(key, val) end end - # :stopdoc: private def set_field(key, val) case val when Enumerable @@ -297,7 +294,6 @@ def add_field(key, val) ary.push val end end - # :startdoc: # Returns the array field value for the given +key+, # or +nil+ if there is no such field; @@ -494,7 +490,7 @@ def each_capitalized alias canonical_each each_capitalized - def capitalize(name) # :nodoc: + def capitalize(name) name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze) end private :capitalize @@ -961,12 +957,12 @@ def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)] end - def basic_encode(account, password) # :nodoc: + def basic_encode(account, password) 'Basic ' + ["#{account}:#{password}"].pack('m0') end private :basic_encode - # Returns whether the HTTP session is to be closed. +# Returns whether the HTTP session is to be closed. def connection_close? token = /(?:\A|,)\s*close\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} @@ -974,7 +970,7 @@ def connection_close? false end - # Returns whether the HTTP session is to be kept alive. +# Returns whether the HTTP session is to be kept alive. def connection_keep_alive? token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} diff --git a/lib/net/http/requests.rb b/lib/net/http/requests.rb index 939d413f91961c..e58057adf1664c 100644 --- a/lib/net/http/requests.rb +++ b/lib/net/http/requests.rb @@ -29,7 +29,6 @@ # - Net::HTTP#get: sends +GET+ request, returns response object. # class Net::HTTP::Get < Net::HTTPRequest - # :stopdoc: METHOD = 'GET' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -61,7 +60,6 @@ class Net::HTTP::Get < Net::HTTPRequest # - Net::HTTP#head: sends +HEAD+ request, returns response object. # class Net::HTTP::Head < Net::HTTPRequest - # :stopdoc: METHOD = 'HEAD' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = false @@ -97,7 +95,6 @@ class Net::HTTP::Head < Net::HTTPRequest # - Net::HTTP#post: sends +POST+ request, returns response object. # class Net::HTTP::Post < Net::HTTPRequest - # :stopdoc: METHOD = 'POST' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -133,7 +130,6 @@ class Net::HTTP::Post < Net::HTTPRequest # - Net::HTTP#put: sends +PUT+ request, returns response object. # class Net::HTTP::Put < Net::HTTPRequest - # :stopdoc: METHOD = 'PUT' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -166,7 +162,6 @@ class Net::HTTP::Put < Net::HTTPRequest # - Net::HTTP#delete: sends +DELETE+ request, returns response object. # class Net::HTTP::Delete < Net::HTTPRequest - # :stopdoc: METHOD = 'DELETE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -198,7 +193,6 @@ class Net::HTTP::Delete < Net::HTTPRequest # - Net::HTTP#options: sends +OPTIONS+ request, returns response object. # class Net::HTTP::Options < Net::HTTPRequest - # :stopdoc: METHOD = 'OPTIONS' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -230,7 +224,6 @@ class Net::HTTP::Options < Net::HTTPRequest # - Net::HTTP#trace: sends +TRACE+ request, returns response object. # class Net::HTTP::Trace < Net::HTTPRequest - # :stopdoc: METHOD = 'TRACE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -265,7 +258,6 @@ class Net::HTTP::Trace < Net::HTTPRequest # - Net::HTTP#patch: sends +PATCH+ request, returns response object. # class Net::HTTP::Patch < Net::HTTPRequest - # :stopdoc: METHOD = 'PATCH' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -293,7 +285,6 @@ class Net::HTTP::Patch < Net::HTTPRequest # - Net::HTTP#propfind: sends +PROPFIND+ request, returns response object. # class Net::HTTP::Propfind < Net::HTTPRequest - # :stopdoc: METHOD = 'PROPFIND' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -317,7 +308,6 @@ class Net::HTTP::Propfind < Net::HTTPRequest # - Net::HTTP#proppatch: sends +PROPPATCH+ request, returns response object. # class Net::HTTP::Proppatch < Net::HTTPRequest - # :stopdoc: METHOD = 'PROPPATCH' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -341,7 +331,6 @@ class Net::HTTP::Proppatch < Net::HTTPRequest # - Net::HTTP#mkcol: sends +MKCOL+ request, returns response object. # class Net::HTTP::Mkcol < Net::HTTPRequest - # :stopdoc: METHOD = 'MKCOL' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -365,7 +354,6 @@ class Net::HTTP::Mkcol < Net::HTTPRequest # - Net::HTTP#copy: sends +COPY+ request, returns response object. # class Net::HTTP::Copy < Net::HTTPRequest - # :stopdoc: METHOD = 'COPY' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -389,7 +377,6 @@ class Net::HTTP::Copy < Net::HTTPRequest # - Net::HTTP#move: sends +MOVE+ request, returns response object. # class Net::HTTP::Move < Net::HTTPRequest - # :stopdoc: METHOD = 'MOVE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -413,7 +400,6 @@ class Net::HTTP::Move < Net::HTTPRequest # - Net::HTTP#lock: sends +LOCK+ request, returns response object. # class Net::HTTP::Lock < Net::HTTPRequest - # :stopdoc: METHOD = 'LOCK' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -437,8 +423,8 @@ class Net::HTTP::Lock < Net::HTTPRequest # - Net::HTTP#unlock: sends +UNLOCK+ request, returns response object. # class Net::HTTP::Unlock < Net::HTTPRequest - # :stopdoc: METHOD = 'UNLOCK' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true end + diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 8804a99c9e5269..40de96386804f3 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -153,7 +153,6 @@ def read_new(sock) #:nodoc: internal use only end private - # :stopdoc: def read_status_line(sock) str = sock.readline @@ -260,7 +259,7 @@ def body_encoding=(value) # header. attr_accessor :ignore_eof - def inspect # :nodoc: + def inspect "#<#{self.class} #{@code} #{@message} readbody=#{@read}>" end diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb index 2fa01e2c0c3f33..5e2f8ce1aa176a 100644 --- a/lib/net/http/responses.rb +++ b/lib/net/http/responses.rb @@ -5,7 +5,6 @@ module Net class HTTPUnknownResponse < HTTPResponse - # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPError # end @@ -20,7 +19,6 @@ class HTTPUnknownResponse < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_informational_response]. # class HTTPInformation < HTTPResponse - # :stopdoc: HAS_BODY = false EXCEPTION_TYPE = HTTPError # end @@ -36,7 +34,6 @@ class HTTPInformation < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_success]. # class HTTPSuccess < HTTPResponse - # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPError # end @@ -52,7 +49,6 @@ class HTTPSuccess < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection]. # class HTTPRedirection < HTTPResponse - # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPRetriableError # end @@ -67,7 +63,6 @@ class HTTPRedirection < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors]. # class HTTPClientError < HTTPResponse - # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPClientException # end @@ -82,7 +77,6 @@ class HTTPClientError < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors]. # class HTTPServerError < HTTPResponse - # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPFatalError # end @@ -100,7 +94,6 @@ class HTTPServerError < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100]. # class HTTPContinue < HTTPInformation - # :stopdoc: HAS_BODY = false end @@ -118,7 +111,6 @@ class HTTPContinue < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101]. # class HTTPSwitchProtocol < HTTPInformation - # :stopdoc: HAS_BODY = false end @@ -135,7 +127,6 @@ class HTTPSwitchProtocol < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102]. # class HTTPProcessing < HTTPInformation - # :stopdoc: HAS_BODY = false end @@ -154,7 +145,6 @@ class HTTPProcessing < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103]. # class HTTPEarlyHints < HTTPInformation - # :stopdoc: HAS_BODY = false end @@ -172,7 +162,6 @@ class HTTPEarlyHints < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200]. # class HTTPOK < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -190,7 +179,6 @@ class HTTPOK < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201]. # class HTTPCreated < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -208,7 +196,6 @@ class HTTPCreated < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202]. # class HTTPAccepted < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -228,7 +215,6 @@ class HTTPAccepted < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203]. # class HTTPNonAuthoritativeInformation < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -246,7 +232,6 @@ class HTTPNonAuthoritativeInformation < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204]. # class HTTPNoContent < HTTPSuccess - # :stopdoc: HAS_BODY = false end @@ -265,7 +250,6 @@ class HTTPNoContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205]. # class HTTPResetContent < HTTPSuccess - # :stopdoc: HAS_BODY = false end @@ -284,7 +268,6 @@ class HTTPResetContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206]. # class HTTPPartialContent < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -302,7 +285,6 @@ class HTTPPartialContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207]. # class HTTPMultiStatus < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -322,7 +304,6 @@ class HTTPMultiStatus < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208]. # class HTTPAlreadyReported < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -340,7 +321,6 @@ class HTTPAlreadyReported < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226]. # class HTTPIMUsed < HTTPSuccess - # :stopdoc: HAS_BODY = true end @@ -358,7 +338,6 @@ class HTTPIMUsed < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300]. # class HTTPMultipleChoices < HTTPRedirection - # :stopdoc: HAS_BODY = true end HTTPMultipleChoice = HTTPMultipleChoices @@ -377,7 +356,6 @@ class HTTPMultipleChoices < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301]. # class HTTPMovedPermanently < HTTPRedirection - # :stopdoc: HAS_BODY = true end @@ -395,7 +373,6 @@ class HTTPMovedPermanently < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302]. # class HTTPFound < HTTPRedirection - # :stopdoc: HAS_BODY = true end HTTPMovedTemporarily = HTTPFound @@ -413,7 +390,6 @@ class HTTPFound < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303]. # class HTTPSeeOther < HTTPRedirection - # :stopdoc: HAS_BODY = true end @@ -431,7 +407,6 @@ class HTTPSeeOther < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304]. # class HTTPNotModified < HTTPRedirection - # :stopdoc: HAS_BODY = false end @@ -448,7 +423,6 @@ class HTTPNotModified < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305]. # class HTTPUseProxy < HTTPRedirection - # :stopdoc: HAS_BODY = false end @@ -466,7 +440,6 @@ class HTTPUseProxy < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307]. # class HTTPTemporaryRedirect < HTTPRedirection - # :stopdoc: HAS_BODY = true end @@ -483,7 +456,6 @@ class HTTPTemporaryRedirect < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308]. # class HTTPPermanentRedirect < HTTPRedirection - # :stopdoc: HAS_BODY = true end @@ -500,7 +472,6 @@ class HTTPPermanentRedirect < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400]. # class HTTPBadRequest < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -517,7 +488,6 @@ class HTTPBadRequest < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401]. # class HTTPUnauthorized < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -534,7 +504,6 @@ class HTTPUnauthorized < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402]. # class HTTPPaymentRequired < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -552,7 +521,6 @@ class HTTPPaymentRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403]. # class HTTPForbidden < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -569,7 +537,6 @@ class HTTPForbidden < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404]. # class HTTPNotFound < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -586,7 +553,6 @@ class HTTPNotFound < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405]. # class HTTPMethodNotAllowed < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -604,7 +570,6 @@ class HTTPMethodNotAllowed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406]. # class HTTPNotAcceptable < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -621,7 +586,6 @@ class HTTPNotAcceptable < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407]. # class HTTPProxyAuthenticationRequired < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -638,7 +602,6 @@ class HTTPProxyAuthenticationRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408]. # class HTTPRequestTimeout < HTTPClientError - # :stopdoc: HAS_BODY = true end HTTPRequestTimeOut = HTTPRequestTimeout @@ -656,7 +619,6 @@ class HTTPRequestTimeout < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409]. # class HTTPConflict < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -674,7 +636,6 @@ class HTTPConflict < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410]. # class HTTPGone < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -692,7 +653,6 @@ class HTTPGone < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411]. # class HTTPLengthRequired < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -710,7 +670,6 @@ class HTTPLengthRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412]. # class HTTPPreconditionFailed < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -727,7 +686,6 @@ class HTTPPreconditionFailed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413]. # class HTTPPayloadTooLarge < HTTPClientError - # :stopdoc: HAS_BODY = true end HTTPRequestEntityTooLarge = HTTPPayloadTooLarge @@ -745,7 +703,6 @@ class HTTPPayloadTooLarge < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414]. # class HTTPURITooLong < HTTPClientError - # :stopdoc: HAS_BODY = true end HTTPRequestURITooLong = HTTPURITooLong @@ -764,7 +721,6 @@ class HTTPURITooLong < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415]. # class HTTPUnsupportedMediaType < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -781,7 +737,6 @@ class HTTPUnsupportedMediaType < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416]. # class HTTPRangeNotSatisfiable < HTTPClientError - # :stopdoc: HAS_BODY = true end HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable @@ -799,7 +754,6 @@ class HTTPRangeNotSatisfiable < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417]. # class HTTPExpectationFailed < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -820,7 +774,6 @@ class HTTPExpectationFailed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421]. # class HTTPMisdirectedRequest < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -837,7 +790,6 @@ class HTTPMisdirectedRequest < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422]. # class HTTPUnprocessableEntity < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -853,7 +805,6 @@ class HTTPUnprocessableEntity < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423]. # class HTTPLocked < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -870,7 +821,6 @@ class HTTPLocked < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424]. # class HTTPFailedDependency < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -890,7 +840,6 @@ class HTTPFailedDependency < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426]. # class HTTPUpgradeRequired < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -907,7 +856,6 @@ class HTTPUpgradeRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428]. # class HTTPPreconditionRequired < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -924,7 +872,6 @@ class HTTPPreconditionRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429]. # class HTTPTooManyRequests < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -942,7 +889,6 @@ class HTTPTooManyRequests < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431]. # class HTTPRequestHeaderFieldsTooLarge < HTTPClientError - # :stopdoc: HAS_BODY = true end @@ -960,7 +906,6 @@ class HTTPRequestHeaderFieldsTooLarge < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451]. # class HTTPUnavailableForLegalReasons < HTTPClientError - # :stopdoc: HAS_BODY = true end # 444 No Response - Nginx @@ -981,7 +926,6 @@ class HTTPUnavailableForLegalReasons < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500]. # class HTTPInternalServerError < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -999,7 +943,6 @@ class HTTPInternalServerError < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501]. # class HTTPNotImplemented < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1017,7 +960,6 @@ class HTTPNotImplemented < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502]. # class HTTPBadGateway < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1035,7 +977,6 @@ class HTTPBadGateway < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503]. # class HTTPServiceUnavailable < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1053,7 +994,6 @@ class HTTPServiceUnavailable < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504]. # class HTTPGatewayTimeout < HTTPServerError - # :stopdoc: HAS_BODY = true end HTTPGatewayTimeOut = HTTPGatewayTimeout @@ -1071,7 +1011,6 @@ class HTTPGatewayTimeout < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505]. # class HTTPVersionNotSupported < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1088,7 +1027,6 @@ class HTTPVersionNotSupported < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506]. # class HTTPVariantAlsoNegotiates < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1105,7 +1043,6 @@ class HTTPVariantAlsoNegotiates < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507]. # class HTTPInsufficientStorage < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1122,7 +1059,6 @@ class HTTPInsufficientStorage < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508]. # class HTTPLoopDetected < HTTPServerError - # :stopdoc: HAS_BODY = true end # 509 Bandwidth Limit Exceeded - Apache bw/limited extension @@ -1140,7 +1076,6 @@ class HTTPLoopDetected < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510]. # class HTTPNotExtended < HTTPServerError - # :stopdoc: HAS_BODY = true end @@ -1157,14 +1092,12 @@ class HTTPNotExtended < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511]. # class HTTPNetworkAuthenticationRequired < HTTPServerError - # :stopdoc: HAS_BODY = true end end class Net::HTTPResponse - # :stopdoc: CODE_CLASS_TO_OBJ = { '1' => Net::HTTPInformation, '2' => Net::HTTPSuccess, From 4fe0342a860bc3aceb5f51707732545f83a0ac35 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Nov 2025 22:18:37 +0900 Subject: [PATCH 06/11] Reapply "[ruby/net-http] [DOC] Suppress documentation for internals" This reverts commit af610e107c3a7515228843eb6b1c5978f2ee2685. Reverted by a mistake. --- lib/net/http.rb | 35 ++++++++++------- lib/net/http/exceptions.rb | 3 +- lib/net/http/generic_request.rb | 2 + lib/net/http/header.rb | 12 ++++-- lib/net/http/requests.rb | 16 +++++++- lib/net/http/response.rb | 3 +- lib/net/http/responses.rb | 67 +++++++++++++++++++++++++++++++++ 7 files changed, 117 insertions(+), 21 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 9511f19f268730..7efb468e782e06 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1321,6 +1321,9 @@ def response_body_encoding=(value) # Sets the proxy password; # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. attr_writer :proxy_pass + + # Sets wheter the proxy uses SSL; + # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. attr_writer :proxy_use_ssl # Returns the IP address for the connection. @@ -1632,6 +1635,21 @@ def start # :yield: http self end + # Finishes the \HTTP session: + # + # http = Net::HTTP.new(hostname) + # http.start + # http.started? # => true + # http.finish # => nil + # http.started? # => false + # + # Raises IOError if not in a session. + def finish + raise IOError, 'HTTP session not yet started' unless started? + do_finish + end + + # :stopdoc: def do_start connect @started = true @@ -1758,20 +1776,6 @@ def on_connect end private :on_connect - # Finishes the \HTTP session: - # - # http = Net::HTTP.new(hostname) - # http.start - # http.started? # => true - # http.finish # => nil - # http.started? # => false - # - # Raises IOError if not in a session. - def finish - raise IOError, 'HTTP session not yet started' unless started? - do_finish - end - def do_finish @started = false @socket.close if @socket @@ -1917,6 +1921,7 @@ def proxy_pass alias proxyport proxy_port #:nodoc: obsolete private + # :stopdoc: def unescape(value) require 'cgi/escape' @@ -2400,6 +2405,8 @@ def send_entity(path, data, initheader, dest, type, &block) res end + # :stopdoc: + IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc: def transport_request(req) diff --git a/lib/net/http/exceptions.rb b/lib/net/http/exceptions.rb index ceec8f7b0a3822..4342cfc0ef4be3 100644 --- a/lib/net/http/exceptions.rb +++ b/lib/net/http/exceptions.rb @@ -3,7 +3,7 @@ module Net # Net::HTTP exception class. # You cannot use Net::HTTPExceptions directly; instead, you must use # its subclasses. - module HTTPExceptions + module HTTPExceptions # :nodoc: def initialize(msg, res) #:nodoc: super msg @response = res @@ -12,6 +12,7 @@ def initialize(msg, res) #:nodoc: alias data response #:nodoc: obsolete end + # :stopdoc: class HTTPError < ProtocolError include HTTPExceptions end diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb index c92004e5578b38..d9a4c4fef05ad5 100644 --- a/lib/net/http/generic_request.rb +++ b/lib/net/http/generic_request.rb @@ -264,6 +264,8 @@ def update_uri(addr, port, ssl) # :nodoc: internal use only private + # :stopdoc: + class Chunker #:nodoc: def initialize(sock) @sock = sock diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index f6c36f1b5e78e7..5dcdcc7d74051c 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -179,7 +179,9 @@ # - #each_value: Passes each string field value to the block. # module Net::HTTPHeader + # The maximum length of HTTP header keys. MAX_KEY_LENGTH = 1024 + # The maximum length of HTTP header values. MAX_FIELD_LENGTH = 65536 def initialize_http_header(initheader) #:nodoc: @@ -267,6 +269,7 @@ def add_field(key, val) end end + # :stopdoc: private def set_field(key, val) case val when Enumerable @@ -294,6 +297,7 @@ def add_field(key, val) ary.push val end end + # :startdoc: # Returns the array field value for the given +key+, # or +nil+ if there is no such field; @@ -490,7 +494,7 @@ def each_capitalized alias canonical_each each_capitalized - def capitalize(name) + def capitalize(name) # :nodoc: name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze) end private :capitalize @@ -957,12 +961,12 @@ def proxy_basic_auth(account, password) @header['proxy-authorization'] = [basic_encode(account, password)] end - def basic_encode(account, password) + def basic_encode(account, password) # :nodoc: 'Basic ' + ["#{account}:#{password}"].pack('m0') end private :basic_encode -# Returns whether the HTTP session is to be closed. + # Returns whether the HTTP session is to be closed. def connection_close? token = /(?:\A|,)\s*close\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} @@ -970,7 +974,7 @@ def connection_close? false end -# Returns whether the HTTP session is to be kept alive. + # Returns whether the HTTP session is to be kept alive. def connection_keep_alive? token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i @header['connection']&.grep(token) {return true} diff --git a/lib/net/http/requests.rb b/lib/net/http/requests.rb index e58057adf1664c..939d413f91961c 100644 --- a/lib/net/http/requests.rb +++ b/lib/net/http/requests.rb @@ -29,6 +29,7 @@ # - Net::HTTP#get: sends +GET+ request, returns response object. # class Net::HTTP::Get < Net::HTTPRequest + # :stopdoc: METHOD = 'GET' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -60,6 +61,7 @@ class Net::HTTP::Get < Net::HTTPRequest # - Net::HTTP#head: sends +HEAD+ request, returns response object. # class Net::HTTP::Head < Net::HTTPRequest + # :stopdoc: METHOD = 'HEAD' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = false @@ -95,6 +97,7 @@ class Net::HTTP::Head < Net::HTTPRequest # - Net::HTTP#post: sends +POST+ request, returns response object. # class Net::HTTP::Post < Net::HTTPRequest + # :stopdoc: METHOD = 'POST' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -130,6 +133,7 @@ class Net::HTTP::Post < Net::HTTPRequest # - Net::HTTP#put: sends +PUT+ request, returns response object. # class Net::HTTP::Put < Net::HTTPRequest + # :stopdoc: METHOD = 'PUT' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -162,6 +166,7 @@ class Net::HTTP::Put < Net::HTTPRequest # - Net::HTTP#delete: sends +DELETE+ request, returns response object. # class Net::HTTP::Delete < Net::HTTPRequest + # :stopdoc: METHOD = 'DELETE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -193,6 +198,7 @@ class Net::HTTP::Delete < Net::HTTPRequest # - Net::HTTP#options: sends +OPTIONS+ request, returns response object. # class Net::HTTP::Options < Net::HTTPRequest + # :stopdoc: METHOD = 'OPTIONS' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -224,6 +230,7 @@ class Net::HTTP::Options < Net::HTTPRequest # - Net::HTTP#trace: sends +TRACE+ request, returns response object. # class Net::HTTP::Trace < Net::HTTPRequest + # :stopdoc: METHOD = 'TRACE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -258,6 +265,7 @@ class Net::HTTP::Trace < Net::HTTPRequest # - Net::HTTP#patch: sends +PATCH+ request, returns response object. # class Net::HTTP::Patch < Net::HTTPRequest + # :stopdoc: METHOD = 'PATCH' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -285,6 +293,7 @@ class Net::HTTP::Patch < Net::HTTPRequest # - Net::HTTP#propfind: sends +PROPFIND+ request, returns response object. # class Net::HTTP::Propfind < Net::HTTPRequest + # :stopdoc: METHOD = 'PROPFIND' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -308,6 +317,7 @@ class Net::HTTP::Propfind < Net::HTTPRequest # - Net::HTTP#proppatch: sends +PROPPATCH+ request, returns response object. # class Net::HTTP::Proppatch < Net::HTTPRequest + # :stopdoc: METHOD = 'PROPPATCH' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -331,6 +341,7 @@ class Net::HTTP::Proppatch < Net::HTTPRequest # - Net::HTTP#mkcol: sends +MKCOL+ request, returns response object. # class Net::HTTP::Mkcol < Net::HTTPRequest + # :stopdoc: METHOD = 'MKCOL' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -354,6 +365,7 @@ class Net::HTTP::Mkcol < Net::HTTPRequest # - Net::HTTP#copy: sends +COPY+ request, returns response object. # class Net::HTTP::Copy < Net::HTTPRequest + # :stopdoc: METHOD = 'COPY' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -377,6 +389,7 @@ class Net::HTTP::Copy < Net::HTTPRequest # - Net::HTTP#move: sends +MOVE+ request, returns response object. # class Net::HTTP::Move < Net::HTTPRequest + # :stopdoc: METHOD = 'MOVE' REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = true @@ -400,6 +413,7 @@ class Net::HTTP::Move < Net::HTTPRequest # - Net::HTTP#lock: sends +LOCK+ request, returns response object. # class Net::HTTP::Lock < Net::HTTPRequest + # :stopdoc: METHOD = 'LOCK' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true @@ -423,8 +437,8 @@ class Net::HTTP::Lock < Net::HTTPRequest # - Net::HTTP#unlock: sends +UNLOCK+ request, returns response object. # class Net::HTTP::Unlock < Net::HTTPRequest + # :stopdoc: METHOD = 'UNLOCK' REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true end - diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 40de96386804f3..8804a99c9e5269 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -153,6 +153,7 @@ def read_new(sock) #:nodoc: internal use only end private + # :stopdoc: def read_status_line(sock) str = sock.readline @@ -259,7 +260,7 @@ def body_encoding=(value) # header. attr_accessor :ignore_eof - def inspect + def inspect # :nodoc: "#<#{self.class} #{@code} #{@message} readbody=#{@read}>" end diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb index 5e2f8ce1aa176a..2fa01e2c0c3f33 100644 --- a/lib/net/http/responses.rb +++ b/lib/net/http/responses.rb @@ -5,6 +5,7 @@ module Net class HTTPUnknownResponse < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPError # end @@ -19,6 +20,7 @@ class HTTPUnknownResponse < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_informational_response]. # class HTTPInformation < HTTPResponse + # :stopdoc: HAS_BODY = false EXCEPTION_TYPE = HTTPError # end @@ -34,6 +36,7 @@ class HTTPInformation < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_success]. # class HTTPSuccess < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPError # end @@ -49,6 +52,7 @@ class HTTPSuccess < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection]. # class HTTPRedirection < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPRetriableError # end @@ -63,6 +67,7 @@ class HTTPRedirection < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors]. # class HTTPClientError < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPClientException # end @@ -77,6 +82,7 @@ class HTTPClientError < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors]. # class HTTPServerError < HTTPResponse + # :stopdoc: HAS_BODY = true EXCEPTION_TYPE = HTTPFatalError # end @@ -94,6 +100,7 @@ class HTTPServerError < HTTPResponse # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100]. # class HTTPContinue < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -111,6 +118,7 @@ class HTTPContinue < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101]. # class HTTPSwitchProtocol < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -127,6 +135,7 @@ class HTTPSwitchProtocol < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102]. # class HTTPProcessing < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -145,6 +154,7 @@ class HTTPProcessing < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103]. # class HTTPEarlyHints < HTTPInformation + # :stopdoc: HAS_BODY = false end @@ -162,6 +172,7 @@ class HTTPEarlyHints < HTTPInformation # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200]. # class HTTPOK < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -179,6 +190,7 @@ class HTTPOK < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201]. # class HTTPCreated < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -196,6 +208,7 @@ class HTTPCreated < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202]. # class HTTPAccepted < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -215,6 +228,7 @@ class HTTPAccepted < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203]. # class HTTPNonAuthoritativeInformation < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -232,6 +246,7 @@ class HTTPNonAuthoritativeInformation < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204]. # class HTTPNoContent < HTTPSuccess + # :stopdoc: HAS_BODY = false end @@ -250,6 +265,7 @@ class HTTPNoContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205]. # class HTTPResetContent < HTTPSuccess + # :stopdoc: HAS_BODY = false end @@ -268,6 +284,7 @@ class HTTPResetContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206]. # class HTTPPartialContent < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -285,6 +302,7 @@ class HTTPPartialContent < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207]. # class HTTPMultiStatus < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -304,6 +322,7 @@ class HTTPMultiStatus < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208]. # class HTTPAlreadyReported < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -321,6 +340,7 @@ class HTTPAlreadyReported < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226]. # class HTTPIMUsed < HTTPSuccess + # :stopdoc: HAS_BODY = true end @@ -338,6 +358,7 @@ class HTTPIMUsed < HTTPSuccess # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300]. # class HTTPMultipleChoices < HTTPRedirection + # :stopdoc: HAS_BODY = true end HTTPMultipleChoice = HTTPMultipleChoices @@ -356,6 +377,7 @@ class HTTPMultipleChoices < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301]. # class HTTPMovedPermanently < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -373,6 +395,7 @@ class HTTPMovedPermanently < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302]. # class HTTPFound < HTTPRedirection + # :stopdoc: HAS_BODY = true end HTTPMovedTemporarily = HTTPFound @@ -390,6 +413,7 @@ class HTTPFound < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303]. # class HTTPSeeOther < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -407,6 +431,7 @@ class HTTPSeeOther < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304]. # class HTTPNotModified < HTTPRedirection + # :stopdoc: HAS_BODY = false end @@ -423,6 +448,7 @@ class HTTPNotModified < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305]. # class HTTPUseProxy < HTTPRedirection + # :stopdoc: HAS_BODY = false end @@ -440,6 +466,7 @@ class HTTPUseProxy < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307]. # class HTTPTemporaryRedirect < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -456,6 +483,7 @@ class HTTPTemporaryRedirect < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308]. # class HTTPPermanentRedirect < HTTPRedirection + # :stopdoc: HAS_BODY = true end @@ -472,6 +500,7 @@ class HTTPPermanentRedirect < HTTPRedirection # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400]. # class HTTPBadRequest < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -488,6 +517,7 @@ class HTTPBadRequest < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401]. # class HTTPUnauthorized < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -504,6 +534,7 @@ class HTTPUnauthorized < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402]. # class HTTPPaymentRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -521,6 +552,7 @@ class HTTPPaymentRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403]. # class HTTPForbidden < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -537,6 +569,7 @@ class HTTPForbidden < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404]. # class HTTPNotFound < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -553,6 +586,7 @@ class HTTPNotFound < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405]. # class HTTPMethodNotAllowed < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -570,6 +604,7 @@ class HTTPMethodNotAllowed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406]. # class HTTPNotAcceptable < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -586,6 +621,7 @@ class HTTPNotAcceptable < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407]. # class HTTPProxyAuthenticationRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -602,6 +638,7 @@ class HTTPProxyAuthenticationRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408]. # class HTTPRequestTimeout < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestTimeOut = HTTPRequestTimeout @@ -619,6 +656,7 @@ class HTTPRequestTimeout < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409]. # class HTTPConflict < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -636,6 +674,7 @@ class HTTPConflict < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410]. # class HTTPGone < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -653,6 +692,7 @@ class HTTPGone < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411]. # class HTTPLengthRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -670,6 +710,7 @@ class HTTPLengthRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412]. # class HTTPPreconditionFailed < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -686,6 +727,7 @@ class HTTPPreconditionFailed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413]. # class HTTPPayloadTooLarge < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestEntityTooLarge = HTTPPayloadTooLarge @@ -703,6 +745,7 @@ class HTTPPayloadTooLarge < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414]. # class HTTPURITooLong < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestURITooLong = HTTPURITooLong @@ -721,6 +764,7 @@ class HTTPURITooLong < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415]. # class HTTPUnsupportedMediaType < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -737,6 +781,7 @@ class HTTPUnsupportedMediaType < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416]. # class HTTPRangeNotSatisfiable < HTTPClientError + # :stopdoc: HAS_BODY = true end HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable @@ -754,6 +799,7 @@ class HTTPRangeNotSatisfiable < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417]. # class HTTPExpectationFailed < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -774,6 +820,7 @@ class HTTPExpectationFailed < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421]. # class HTTPMisdirectedRequest < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -790,6 +837,7 @@ class HTTPMisdirectedRequest < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422]. # class HTTPUnprocessableEntity < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -805,6 +853,7 @@ class HTTPUnprocessableEntity < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423]. # class HTTPLocked < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -821,6 +870,7 @@ class HTTPLocked < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424]. # class HTTPFailedDependency < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -840,6 +890,7 @@ class HTTPFailedDependency < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426]. # class HTTPUpgradeRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -856,6 +907,7 @@ class HTTPUpgradeRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428]. # class HTTPPreconditionRequired < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -872,6 +924,7 @@ class HTTPPreconditionRequired < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429]. # class HTTPTooManyRequests < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -889,6 +942,7 @@ class HTTPTooManyRequests < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431]. # class HTTPRequestHeaderFieldsTooLarge < HTTPClientError + # :stopdoc: HAS_BODY = true end @@ -906,6 +960,7 @@ class HTTPRequestHeaderFieldsTooLarge < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451]. # class HTTPUnavailableForLegalReasons < HTTPClientError + # :stopdoc: HAS_BODY = true end # 444 No Response - Nginx @@ -926,6 +981,7 @@ class HTTPUnavailableForLegalReasons < HTTPClientError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500]. # class HTTPInternalServerError < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -943,6 +999,7 @@ class HTTPInternalServerError < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501]. # class HTTPNotImplemented < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -960,6 +1017,7 @@ class HTTPNotImplemented < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502]. # class HTTPBadGateway < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -977,6 +1035,7 @@ class HTTPBadGateway < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503]. # class HTTPServiceUnavailable < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -994,6 +1053,7 @@ class HTTPServiceUnavailable < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504]. # class HTTPGatewayTimeout < HTTPServerError + # :stopdoc: HAS_BODY = true end HTTPGatewayTimeOut = HTTPGatewayTimeout @@ -1011,6 +1071,7 @@ class HTTPGatewayTimeout < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505]. # class HTTPVersionNotSupported < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1027,6 +1088,7 @@ class HTTPVersionNotSupported < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506]. # class HTTPVariantAlsoNegotiates < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1043,6 +1105,7 @@ class HTTPVariantAlsoNegotiates < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507]. # class HTTPInsufficientStorage < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1059,6 +1122,7 @@ class HTTPInsufficientStorage < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508]. # class HTTPLoopDetected < HTTPServerError + # :stopdoc: HAS_BODY = true end # 509 Bandwidth Limit Exceeded - Apache bw/limited extension @@ -1076,6 +1140,7 @@ class HTTPLoopDetected < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510]. # class HTTPNotExtended < HTTPServerError + # :stopdoc: HAS_BODY = true end @@ -1092,12 +1157,14 @@ class HTTPNotExtended < HTTPServerError # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511]. # class HTTPNetworkAuthenticationRequired < HTTPServerError + # :stopdoc: HAS_BODY = true end end class Net::HTTPResponse + # :stopdoc: CODE_CLASS_TO_OBJ = { '1' => Net::HTTPInformation, '2' => Net::HTTPSuccess, From a7a4bb93fc37b3d4ad5a7b2147c9adf952928342 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 9 Nov 2025 07:16:42 -0800 Subject: [PATCH 07/11] Automatically review default-gem pull requests (#15116) --- .github/workflows/auto_review_pr.yml | 33 +++++++++ tool/auto_review_pr.rb | 106 +++++++++++++++++++++++++++ tool/sync_default_gems.rb | 1 + 3 files changed, 140 insertions(+) create mode 100644 .github/workflows/auto_review_pr.yml create mode 100755 tool/auto_review_pr.rb diff --git a/.github/workflows/auto_review_pr.yml b/.github/workflows/auto_review_pr.yml new file mode 100644 index 00000000000000..c8095dfd8e34a0 --- /dev/null +++ b/.github/workflows/auto_review_pr.yml @@ -0,0 +1,33 @@ +name: Auto Review PR +on: + pull_request_target: + types: [opened, ready_for_review, reopened] + branches: [master] + +permissions: + contents: read + +jobs: + auto-review-pr: + name: Auto Review PR + runs-on: ubuntu-latest + if: ${{ github.repository == 'ruby/ruby' && github.base_ref == 'master' }} + + permissions: + pull-requests: write + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@ab177d40ee5483edb974554986f56b33477e21d0 # v1.265.0 + with: + ruby-version: '3.4' + bundler: none + + - name: Auto Review PR + run: ruby tool/auto_review_pr.rb "$GITHUB_PR_NUMBER" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/tool/auto_review_pr.rb b/tool/auto_review_pr.rb new file mode 100755 index 00000000000000..a3494e4c1a4144 --- /dev/null +++ b/tool/auto_review_pr.rb @@ -0,0 +1,106 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'json' +require 'net/http' +require 'uri' +require_relative './sync_default_gems' + +class GitHubAPIClient + def initialize(token) + @token = token + end + + def get(path) + response = Net::HTTP.get_response(URI("https://api.github.com#{path}"), { + 'Authorization' => "token #{@token}", + 'Accept' => 'application/vnd.github.v3+json', + }).tap(&:value) + JSON.parse(response.body, symbolize_names: true) + end + + def post(path, body = {}) + body = JSON.dump(body) + response = Net::HTTP.post(URI("https://api.github.com#{path}"), body, { + 'Authorization' => "token #{@token}", + 'Accept' => 'application/vnd.github.v3+json', + 'Content-Type' => 'application/json', + }).tap(&:value) + JSON.parse(response.body, symbolize_names: true) + end +end + +class AutoReviewPR + REPO = 'ruby/ruby' + + COMMENT_USER = 'github-actions[bot]' + COMMENT_PREFIX = 'The following files are maintained in the following upstream repositories:' + COMMENT_SUFFIX = 'Please file a pull request to the above instead. Thank you.' + + def initialize(client) + @client = client + end + + def review(pr_number) + comment_body = "Please file a pull request to ruby/foo instead." + + # Fetch the list of files changed by the PR + changed_files = @client.get("/repos/#{REPO}/pulls/#{pr_number}/files").map { it.fetch(:filename) } + + # Build a Hash: { upstream_repo => files, ... } + upstream_repos = changed_files.group_by { |file| find_upstream_repo(file) } + upstream_repos.delete(nil) # exclude no-upstream files + upstream_repos.delete('prism') if changed_files.include?('prism_compile.c') # allow prism changes in this case + if upstream_repos.empty? + puts "Skipped: The PR ##{pr_number} doesn't have upstream repositories." + return + end + + # Check if the PR is already reviewed + existing_comments = @client.get("/repos/#{REPO}/issues/#{pr_number}/comments") + existing_comments.map! { [it.fetch(:user).fetch(:login), it.fetch(:body)] } + if existing_comments.any? { |user, comment| user == COMMENT_USER && comment.start_with?(COMMENT_PREFIX) } + puts "Skipped: The PR ##{pr_number} already has an automated review comment." + return + end + + # Post a comment + comment = format_comment(upstream_repos) + result = @client.post("/repos/#{REPO}/issues/#{pr_number}/comments", { body: comment }) + puts "Success: #{JSON.pretty_generate(result)}" + end + + private + + def find_upstream_repo(file) + SyncDefaultGems::REPOSITORIES.each do |repo_name, repository| + repository.mappings.each do |_src, dst| + if file.start_with?(dst) + return repo_name + end + end + end + nil + end + + # upstream_repos: { upstream_repo => files, ... } + def format_comment(upstream_repos) + comment = +'' + comment << "#{COMMENT_PREFIX}\n\n" + + upstream_repos.each do |upstream_repo, files| + comment << "* https://github.com/ruby/#{upstream_repo}\n" + files.each do |file| + comment << " * #{file}\n" + end + end + + comment << "\n#{COMMENT_SUFFIX}" + comment + end +end + +pr_number = ARGV[0] || abort("Usage: #{$0} ") +client = GitHubAPIClient.new(ENV.fetch('GITHUB_TOKEN')) + +AutoReviewPR.new(client).review(pr_number) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index b2509f0062b0b5..997cd5eddc8f16 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -61,6 +61,7 @@ def lib((upstream, branch), gemspec_in_subdir: false) ]) end + # Note: tool/auto_review_pr.rb also depends on this constant. REPOSITORIES = { "io-console": repo("ruby/io-console", [ ["ext/io/console", "ext/io/console"], From 2b6580d44aef3f867321d1f8b346c500e51a4344 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 9 Nov 2025 07:34:18 -0800 Subject: [PATCH 08/11] auto_review_pr.rb: Remove an unused variable Follow-up: https://github.com/ruby/ruby/pull/15116 --- tool/auto_review_pr.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/tool/auto_review_pr.rb b/tool/auto_review_pr.rb index a3494e4c1a4144..f434a4f92a294c 100755 --- a/tool/auto_review_pr.rb +++ b/tool/auto_review_pr.rb @@ -42,8 +42,6 @@ def initialize(client) end def review(pr_number) - comment_body = "Please file a pull request to ruby/foo instead." - # Fetch the list of files changed by the PR changed_files = @client.get("/repos/#{REPO}/pulls/#{pr_number}/files").map { it.fetch(:filename) } From 4639bbc8e91238caa4774a8916ec6555b71d6e1b Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 9 Nov 2025 07:35:21 -0800 Subject: [PATCH 09/11] auto_review_pr.rb: Tweak the review message --- tool/auto_review_pr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/auto_review_pr.rb b/tool/auto_review_pr.rb index f434a4f92a294c..c63640354d3593 100755 --- a/tool/auto_review_pr.rb +++ b/tool/auto_review_pr.rb @@ -35,7 +35,7 @@ class AutoReviewPR COMMENT_USER = 'github-actions[bot]' COMMENT_PREFIX = 'The following files are maintained in the following upstream repositories:' - COMMENT_SUFFIX = 'Please file a pull request to the above instead. Thank you.' + COMMENT_SUFFIX = 'Please file a pull request to the above instead. Thank you!' def initialize(client) @client = client From f1b1899a749b28ce5c951034efeb096d15ae244c Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Sun, 9 Nov 2025 11:33:03 -0500 Subject: [PATCH 10/11] [ruby/mmtk] Lock the VM when freeing objects in rb_gc_impl_shutdown_call_finalizer https://github.com/ruby/mmtk/commit/1828f6596f --- gc/mmtk/mmtk.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gc/mmtk/mmtk.c b/gc/mmtk/mmtk.c index 9dd3129e01664e..cc0b1afd4d2051 100644 --- a/gc/mmtk/mmtk.c +++ b/gc/mmtk/mmtk.c @@ -1022,16 +1022,20 @@ rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr) gc_run_finalizers(objspace); } - struct MMTk_RawVecOfObjRef registered_candidates = mmtk_get_all_obj_free_candidates(); - for (size_t i = 0; i < registered_candidates.len; i++) { - VALUE obj = (VALUE)registered_candidates.ptr[i]; - - if (rb_gc_shutdown_call_finalizer_p(obj)) { - rb_gc_obj_free(objspace_ptr, obj); - RBASIC(obj)->flags = 0; + unsigned int lev = RB_GC_VM_LOCK(); + { + struct MMTk_RawVecOfObjRef registered_candidates = mmtk_get_all_obj_free_candidates(); + for (size_t i = 0; i < registered_candidates.len; i++) { + VALUE obj = (VALUE)registered_candidates.ptr[i]; + + if (rb_gc_shutdown_call_finalizer_p(obj)) { + rb_gc_obj_free(objspace_ptr, obj); + RBASIC(obj)->flags = 0; + } } + mmtk_free_raw_vec_of_obj_ref(registered_candidates); } - mmtk_free_raw_vec_of_obj_ref(registered_candidates); + RB_GC_VM_UNLOCK(lev); gc_run_finalizers(objspace); } From 17efb770c89029f6b7df639b673a9a8cc08c8d0d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 9 Nov 2025 09:54:41 -0800 Subject: [PATCH 11/11] sync_default_gems.yml: Pull --rebase before push It was supposed to update a local branch in case the remote branch was updated between actions/checkout and the end of tool/sync_default_gems.rb. Note that this `git pull` didn't exist in the original bin/update-default-gem.sh https://github.com/ruby/git.ruby-lang.org/commit/d9e9bcc60dcf0dd1cbdc2dd42bc0286439e471aa, so it was newly introduced at https://github.com/ruby/ruby/commit/3ba5cfd1cb77b61b2b1ad1d03271bc1fe7b71969. But `git pull --no-ff` failed when master had updates in an unrelated repository. I think we need to use `git pull --rebase` instead. This fixes: * https://github.com/ruby/ruby/actions/runs/19207693793/job/54905403070 * checkout: f08030e9dccf38d9ea5c9505203fe26484dc28d8 * ruby tool/sync_default_gems.rb net-http ec9c70a6fba75a63c128864ef3cb32c883665a33..e4d80bd609f22cad04a2e2c1d54c981bb853c938 * pull: 2bf82c627494e785737037bbaf9a6b98f3c6354c --- .github/workflows/sync_default_gems.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_default_gems.yml b/.github/workflows/sync_default_gems.yml index 2f0b4d8865eb4f..1a9b43ec5241a9 100644 --- a/.github/workflows/sync_default_gems.yml +++ b/.github/workflows/sync_default_gems.yml @@ -56,7 +56,7 @@ jobs: - name: Push run: | - git pull --ff-only origin ${GITHUB_REF#refs/heads/} + git pull --rebase origin ${GITHUB_REF#refs/heads/} git push origin ${GITHUB_REF#refs/heads/} if: ${{ steps.sync.outputs.update }}