Skip to content

Commit

Permalink
Revert Fix encoding of process output under windows (#784)
Browse files Browse the repository at this point in the history
This appears to break usage under Linux. Until a proper solution can be
implemented, revert.
  • Loading branch information
sds committed May 3, 2022
1 parent 274e8d6 commit 1f7e5a2
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions lib/overcommit/subprocess.rb
Expand Up @@ -52,7 +52,7 @@ def spawn(args, options = {})
err.rewind
out.rewind

Result.new(process.exit_code, to_utf8(out.read), to_utf8(err.read))
Result.new(process.exit_code, out.read, err.read)
end

# Spawns a new process in the background using the given array of
Expand Down Expand Up @@ -84,27 +84,6 @@ def win32_prepare_args(args)
%w[cmd.exe /c] + [args.join(' ')]
end

# Convert string from current locale to utf-8
#
# When running commands under windows the command output is using
# current system locale (depends on system lanuage) not UTF-8
#
# @param process [String]
# @return [String]
def to_utf8(string)
# Our encoding code doesn't work on the GitHub Actions Windows
# environment for unknown reasons, so just skip it in CI.
return string if OS.windows? && ENV['GITHUB_ACTIONS']

if Encoding.locale_charmap == 'UTF-8'
return string
end

ec = Encoding::Converter.new(Encoding.locale_charmap, 'UTF-8')
# Convert encoding, alternatively simple: string.scrub will suffice
ec.convert(string)
end

# @param process [ChildProcess]
# @return [Array<IO>]
def assign_output_streams(process)
Expand Down

0 comments on commit 1f7e5a2

Please sign in to comment.