diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-10-08 16:30:58 -0700 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-10-08 16:32:10 -0700 |
| commit | dbb5972b340f24d9ff4f3996f57439d5a6b3454e (patch) | |
| tree | 83a78ca4f894c5ad99e6506d0652ba5fe1edab19 | |
| parent | afb21f34987e47932b92530f48a19992863b29b1 (diff) | |
commit-email.rb: Use base64 instead of nkf
which makes it more obvious what it's doing.
| -rwxr-xr-x | tool/commit-email.rb | 7 | ||||
| -rw-r--r-- | tool/test/test_commit_email.rb | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/tool/commit-email.rb b/tool/commit-email.rb index d9f79f41c9..d5b17a09c2 100755 --- a/tool/commit-email.rb +++ b/tool/commit-email.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "optparse" -require "nkf" +require "base64" require "shellwords" CommitEmailInfo = Struct.new( @@ -207,7 +207,8 @@ class << CommitEmail private def b_encode(str) - NKF.nkf('-WwM', str) + base64_str = Base64.encode64(str.force_encoding('UTF-8')).strip # NKF.nkf('-WwMB', str) + "=?UTF-8?B?#{base64_str}?=" end def make_body(info, viewer_uri:) @@ -351,7 +352,7 @@ class << CommitEmail escaped_name = name.gsub(/["\\\n]/) { |c| "\\#{c}" } %Q["#{escaped_name}" <#{email}>] else - escaped_name = "=?UTF-8?B?#{NKF.nkf('-WwMB', name)}?=" + escaped_name = b_encode(name) %Q[#{escaped_name} <#{email}>] end end diff --git a/tool/test/test_commit_email.rb b/tool/test/test_commit_email.rb index 539b0b071c..2d93f11c3e 100644 --- a/tool/test/test_commit_email.rb +++ b/tool/test/test_commit_email.rb @@ -30,7 +30,7 @@ class TestCommitEmail < Test::Unit::TestCase # 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) + _, err, status = EnvUtil.invoke_ruby([gem_env, '-e', 'require "base64"'], '', false, true) unless status.success? omit "bundled gems are not available: #{err}" end |
