Skip to content
Snippets Groups Projects
Commit ad65ca37 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge pull request #100 from cabeca/better-encode

Better encode
parents 38b6a2a4 35471113
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -81,8 +81,7 @@ class Build < ActiveRecord::Base
 
def write_trace(trace)
self.reload
sanitized_output = sanitize_build_output(trace)
update_attributes(trace: sanitized_output)
update_attributes(trace: trace)
end
 
def short_before_sha
Loading
Loading
@@ -94,22 +93,12 @@ class Build < ActiveRecord::Base
end
 
def trace_html
if trace.present?
Ansi2html::convert(compose_output)
else
''
end
end
def sanitize_build_output(output)
GitlabCi::Encode.encode!(output)
html = Ansi2html::convert(compose_output) if trace.present?
html ||= ''
end
 
def read_tmp_file
content = if tmp_file && File.readable?(tmp_file)
File.read(tmp_file)
end
content = GitlabCi::Encode.encode!(File.binread(tmp_file)) if tmp_file && File.readable?(tmp_file)
content ||= ''
end
 
Loading
Loading
@@ -117,8 +106,7 @@ class Build < ActiveRecord::Base
output = trace
 
if running?
sanitized_output = sanitize_build_output(read_tmp_file)
output << sanitized_output if sanitized_output.present?
output << read_tmp_file
end
 
output
Loading
Loading
require 'charlock_holmes/string'
\ No newline at end of file
require 'charlock_holmes/string'
module GitlabCi
module Encode
extend self
Loading
Loading
Loading
Loading
@@ -75,7 +75,7 @@ class Runner
@output << "\n"
 
@process = ChildProcess.build(cmd)
@tmp_file = Tempfile.new("child-output")
@tmp_file = Tempfile.new("child-output", binmode: true)
@process.io.stdout = @tmp_file
@process.io.stderr = @tmp_file
@process.cwd = path
Loading
Loading
@@ -99,7 +99,9 @@ class Runner
@process.exit_code == 0
ensure
@tmp_file.rewind
@output << @tmp_file.read
@output << GitlabCi::Encode.encode!(@tmp_file.read)
@tmp_file.close
@tmp_file.unlink
end
 
def prepare_project_cmd(path, ref)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment