diff --git a/Gemfile b/Gemfile index 46a828eb0..b926e01fd 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ group :test do install_if -> { RUBY_VERSION >= '2.8' } do gem 'rexml', '>= 3.2.4' end + gem 'base64' gem 'json', '>= 2.3.0' gem 'jwt', '~> 2.2', '>= 2.2.1' gem 'mime-types', '~> 3.3', '>= 3.3.1' diff --git a/lib/octokit/client/code_scanning.rb b/lib/octokit/client/code_scanning.rb index 9b51bed2d..2ea8d8474 100644 --- a/lib/octokit/client/code_scanning.rb +++ b/lib/octokit/client/code_scanning.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'base64' require 'tempfile' require 'zlib' @@ -45,7 +44,7 @@ def compress_sarif_data(file) Zlib::GzipWriter.open(tempfile) do |gz_file| gz_file.write File.binread(file) end - Base64.strict_encode64(tempfile.read) + [tempfile.read].pack('m0') # Base64.strict_encode64 end end end diff --git a/lib/octokit/client/contents.rb b/lib/octokit/client/contents.rb index cf7ceeb16..031d60189 100644 --- a/lib/octokit/client/contents.rb +++ b/lib/octokit/client/contents.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'base64' - module Octokit class Client # Methods for the Repo Contents API @@ -80,7 +78,7 @@ def create_contents(*args) end raise ArgumentError, 'content or :file option required' if content.nil? - options[:content] = Base64.strict_encode64(content) + options[:content] = [content].pack('m0') # Base64.strict_encode64 options[:message] = message url = "#{Repository.path repo}/contents/#{path}" put url, options diff --git a/octokit.gemspec b/octokit.gemspec index c9ca5afad..ba79e9e7d 100644 --- a/octokit.gemspec +++ b/octokit.gemspec @@ -5,7 +5,6 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'octokit/version' Gem::Specification.new do |spec| - spec.add_dependency 'base64' spec.add_dependency 'faraday', '>= 1', '< 3' spec.add_dependency 'sawyer', '~> 0.9' spec.authors = ['Wynn Netherland', 'Erik Michaels-Ober', 'Clint Shryock'] diff --git a/spec/octokit/client/licenses_spec.rb b/spec/octokit/client/licenses_spec.rb index fe5df26f7..12d4d965b 100644 --- a/spec/octokit/client/licenses_spec.rb +++ b/spec/octokit/client/licenses_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'base64' + describe Octokit::Client::Licenses do describe '.licenses', :vcr do it 'returns all licenses' do