X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=blobdiff_plain;f=BugsSite%2FPrettyPatch%2FPrettyPatch.rb;h=7539b74657c69eddafb1760814713f81273394cd;hp=59d9ca993dee71000077ebf502fded297e2e6431;hb=4989641882dcd2d32c8a7995149cb2fbece8f908;hpb=b0708b2a1ec41f07e33544ad1aa6e3ba43e22eda;ds=sidebyside diff --git a/BugsSite/PrettyPatch/PrettyPatch.rb b/BugsSite/PrettyPatch/PrettyPatch.rb index 59d9ca993dee..7539b74657c6 100644 --- a/BugsSite/PrettyPatch/PrettyPatch.rb +++ b/BugsSite/PrettyPatch/PrettyPatch.rb @@ -1,16 +1,12 @@ require 'cgi' require 'diff' -require 'open3' require 'pp' require 'set' -require 'tempfile' module PrettyPatch public - GIT_PATH = "/opt/local/bin/git" - def self.prettify(string) fileDiffs = FileDiff.parse(string) @@ -42,16 +38,10 @@ private /^diff/ ] - BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/ + BINARY_FILE_MARKER_FORMAT = /^(?:Cannot display: file marked as a binary type.)|(?:GIT binary patch)$/ IMAGE_FILE_MARKER_FORMAT = /^svn:mime-type = image\/png$/ - GIT_INDEX_MARKER_FORMAT = /^index ([0-9a-f]{40})\.\.([0-9a-f]{40})/ - - GIT_BINARY_FILE_MARKER_FORMAT = /^GIT binary patch$/ - - GIT_LITERAL_FORMAT = /^literal \d+$/ - START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data. START_OF_SECTION_FORMAT = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@\s*(.*)/ @@ -225,42 +215,11 @@ EOF end end break - when GIT_INDEX_MARKER_FORMAT - @git_indexes = [$1, $2] - when GIT_BINARY_FILE_MARKER_FORMAT - @binary = true - if (GIT_LITERAL_FORMAT.match(lines[i + 1]) and PrettyPatch.has_image_suffix(@filename)) then - @git_image = true - startOfSections = i + 1 - end - break end end lines_with_contents = lines[startOfSections...lines.length] @sections = DiffSection.parse(lines_with_contents) unless @binary - if @image - @image_url = "data:image/png;base64," + lines_with_contents.join - elsif @git_image - begin - raise "index line is missing" unless @git_indexes - - chunks = nil - for i in 0...lines_with_contents.length - if lines_with_contents[i] =~ /^$/ - chunks = [lines_with_contents[i + 1 .. -1], lines_with_contents[0 .. i]] - break - end - end - - raise "no binary chunks" unless chunks - - @image_urls = chunks.zip(@git_indexes).collect do |chunk, git_index| - FileDiff.extract_contents_from_git_binary_chunk(chunk, git_index) - end - rescue - @image_error = "Exception raised during decoding git binary patch:
#{CGI.escapeHTML($!.to_s)}
" - end - end + @image_url = "data:image/png;base64," + lines_with_contents.join if @image nil end @@ -269,21 +228,6 @@ EOF str += "

#{PrettyPatch.linkifyFilename(@filename)}

\n" if @image then str += "" - elsif @git_image then - if @image_error - str += @image_error - else - for i in (0...2) - image_url = @image_urls[i] - style = ["remove", "add"][i] - str += "

" - if image_url - str += "" - else - str += ["Added", "Removed"][i] - end - end - end elsif @binary then str += "Binary file, nothing to see here" else @@ -308,51 +252,6 @@ EOF linesForDiffs.collect { |lines| FileDiff.new(lines) } end - - def self.git_new_file_binary_patch(filename, encoded_chunk, git_index) - return <