* Fix binary diffs cause error when viewed * Change color of git lines to #000000a0 * Update assets
This commit is contained in:
+6
-6
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '5.1.2'
|
||||
s.date = '2020-12-01'
|
||||
s.date = '2021-01-03'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.summary = 'A simple, Git-powered wiki.'
|
||||
@@ -68,15 +68,15 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/app.rb
|
||||
lib/gollum/assets.rb
|
||||
lib/gollum/helpers.rb
|
||||
lib/gollum/public/assets/.sprockets-manifest-459226ba5fc211b78ba9a3aa6ebde96c.json
|
||||
lib/gollum/public/assets/.sprockets-manifest-35882cacf71c40928e0c2dc9b8acf8fe.json
|
||||
lib/gollum/public/assets/app-4215e58002a43c4b2e9f0f7caa05a81c7c09d22a918c6fe40cd8e423db3110b5.css
|
||||
lib/gollum/public/assets/app-4215e58002a43c4b2e9f0f7caa05a81c7c09d22a918c6fe40cd8e423db3110b5.css.gz
|
||||
lib/gollum/public/assets/app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js
|
||||
lib/gollum/public/assets/app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js.gz
|
||||
lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css
|
||||
lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css.gz
|
||||
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
|
||||
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
|
||||
lib/gollum/public/assets/editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js
|
||||
lib/gollum/public/assets/editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js.gz
|
||||
lib/gollum/public/assets/editor-b621bfe2cb8823516fb3a96c32e82001b297f6754117b47bdad6e59db85a9d08.js
|
||||
lib/gollum/public/assets/editor-b621bfe2cb8823516fb3a96c32e82001b297f6754117b47bdad6e59db85a9d08.js.gz
|
||||
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css
|
||||
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz
|
||||
lib/gollum/public/gollum/javascript/HOWTO_UPDATE_ACE.md
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"files":{"app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js":{"logical_path":"app.js","mtime":"2021-01-03T19:24:22+05:00","size":136032,"digest":"6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd","integrity":"sha256-bpJeOKEqQMT6ngQAzIdOD0+Xtm/euQoUTepSfbtUT70="},"editor-b621bfe2cb8823516fb3a96c32e82001b297f6754117b47bdad6e59db85a9d08.js":{"logical_path":"editor.js","mtime":"2020-12-30T18:08:26+05:00","size":747276,"digest":"b621bfe2cb8823516fb3a96c32e82001b297f6754117b47bdad6e59db85a9d08","integrity":"sha256-tiG/4suII1Fvs6lsMuggAbKX9nVBF7R72tblnbhanQg="},"app-4215e58002a43c4b2e9f0f7caa05a81c7c09d22a918c6fe40cd8e423db3110b5.css":{"logical_path":"app.css","mtime":"2021-01-03T19:58:10+05:00","size":298142,"digest":"4215e58002a43c4b2e9f0f7caa05a81c7c09d22a918c6fe40cd8e423db3110b5","integrity":"sha256-QhXlgAKkPEsunw98qgWoHHwJ0iqRjG/kDNjkI9sxELU="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2020-12-30T18:08:26+05:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2020-12-30T18:08:26+05:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js","editor.js":"editor-b621bfe2cb8823516fb3a96c32e82001b297f6754117b47bdad6e59db85a9d08.js","app.css":"app-4215e58002a43c4b2e9f0f7caa05a81c7c09d22a918c6fe40cd8e423db3110b5.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
|
||||
@@ -1 +0,0 @@
|
||||
{"files":{"app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js":{"logical_path":"app.js","mtime":"2020-08-03T18:13:54+02:00","size":136032,"digest":"6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd","integrity":"sha256-bpJeOKEqQMT6ngQAzIdOD0+Xtm/euQoUTepSfbtUT70="},"editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js":{"logical_path":"editor.js","mtime":"2020-08-03T18:13:54+02:00","size":747273,"digest":"b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708","integrity":"sha256-ssEPIu9soeEglWotEf9MoZrETX5yQPXMQ+yUkYTYtwg="},"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css":{"logical_path":"app.css","mtime":"2020-03-30T11:12:22+02:00","size":298111,"digest":"b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7","integrity":"sha256-sgXlk6MPHMAFTi6e2fyK82WNjvSmK5cIwg8gRWDe77c="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2020-03-29T22:28:51+02:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2020-03-30T11:12:22+02:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js","editor.js":"editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js","app.css":"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
|
||||
+1
-1
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1
-1
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -615,6 +615,10 @@ a {
|
||||
color: #999;
|
||||
background-color: #EAF2F5;
|
||||
}
|
||||
|
||||
.gg {
|
||||
color: #000000a0;
|
||||
}
|
||||
}
|
||||
|
||||
.type-csharp {
|
||||
|
||||
@@ -23,12 +23,19 @@ module Precious
|
||||
end
|
||||
|
||||
def files
|
||||
files = @diff.split(%r{^diff --git a/.+ b/.+$}).reject(&:empty?)
|
||||
files = @diff.force_encoding(Encoding::UTF_8).scan(%r{
|
||||
^diff\ --git\ # diff start
|
||||
.+? # diff body
|
||||
(?=^diff\ --git|\Z) # scan until next diff or string
|
||||
}sxmu)
|
||||
|
||||
files.map do |diff|
|
||||
matched = diff.match(%r{(?<=^--- a/).+$})
|
||||
matched = diff.match(%r{(?<=^\+\+\+ b/).+$}) if matched.nil?
|
||||
match = diff.match(%r{^diff --git (")?[ab]/(.+)(?(1)") (")?[ab]/(.+)(?(3)")})
|
||||
path = match[2]
|
||||
path = match[4] if path.nil?
|
||||
|
||||
{
|
||||
path: matched[0],
|
||||
path: path,
|
||||
lines: lines(diff)
|
||||
}
|
||||
end
|
||||
|
||||
@@ -19,16 +19,21 @@ module Precious
|
||||
|
||||
def lines(diff = @diff)
|
||||
lines = []
|
||||
lines_to_parse = diff.split("\n")[4..-1]
|
||||
# If the diff is of a rename, the diff header will be one line longer than normal because it will contain a line starting with '+++' to indicate the 'new' filename.
|
||||
# Make sure to skip that header line if it is present.
|
||||
lines_to_parse = lines_to_parse[1..-1] if lines_to_parse[0].start_with?('+++')
|
||||
lines_to_parse = diff.split("\n")[3..-1]
|
||||
lines_to_parse = lines_to_parse[2..-1] if lines_to_parse[0].start_with?('---')
|
||||
|
||||
if lines_to_parse.nil? || lines_to_parse.empty?
|
||||
lines_to_parse = [] # File is created without content
|
||||
else
|
||||
lines_to_parse = lines_to_parse[1..-1] if lines_to_parse[0].start_with?('+++')
|
||||
end
|
||||
|
||||
lines_to_parse.each_with_index do |line, line_index|
|
||||
lines << { :line => line,
|
||||
:class => line_class(line),
|
||||
:ldln => left_diff_line_number(line),
|
||||
:rdln => right_diff_line_number(line) }
|
||||
end if diff
|
||||
end
|
||||
lines
|
||||
end
|
||||
|
||||
@@ -41,6 +46,8 @@ module Precious
|
||||
def line_class(line)
|
||||
if line =~ /^@@/
|
||||
'gc'
|
||||
elsif git_line?(line)
|
||||
'gg'
|
||||
elsif line =~ /^\+/
|
||||
'gi'
|
||||
elsif line =~ /^\-/
|
||||
@@ -53,7 +60,7 @@ module Precious
|
||||
@left_diff_line_number = nil
|
||||
|
||||
def left_diff_line_number(line)
|
||||
if line =~ /^@@/
|
||||
if git_line?(line)
|
||||
m, li = *line.match(/\-(\d+)/)
|
||||
@left_diff_line_number = li.to_i
|
||||
@current_line_number = @left_diff_line_number
|
||||
@@ -75,7 +82,7 @@ module Precious
|
||||
@right_diff_line_number = nil
|
||||
|
||||
def right_diff_line_number(line)
|
||||
if line =~ /^@@/
|
||||
if git_line?(line)
|
||||
m, ri = *line.match(/\+(\d+)/)
|
||||
@right_diff_line_number = ri.to_i
|
||||
@current_line_number = @right_diff_line_number
|
||||
@@ -93,6 +100,10 @@ module Precious
|
||||
end
|
||||
ret
|
||||
end
|
||||
|
||||
def git_line?(line)
|
||||
!!(line =~ /^(\\ No newline|Binary files|@@)/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,3 +10,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc
|
||||
563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence <charles@charlespence.net> 1363478075 -0400 push
|
||||
874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe <techwiz96@gmail.com> 1421012322 -0500 push
|
||||
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto <dawa.ometto@phil.uu.nl> 1492034760 +0200 push
|
||||
f803c64d11407b23797325e3843f3f378b78f611 181c757cca395d4da18701d069a6b8123e88e040 ViChyavIn <nikita.vyach.ivanov@gmail.com> 1609841455 +0500 push
|
||||
|
||||
@@ -10,3 +10,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc
|
||||
563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence <charles@charlespence.net> 1363478075 -0400 push
|
||||
874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe <techwiz96@gmail.com> 1421012322 -0500 push
|
||||
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto <dawa.ometto@phil.uu.nl> 1492034760 +0200 push
|
||||
f803c64d11407b23797325e3843f3f378b78f611 181c757cca395d4da18701d069a6b8123e88e040 ViChyavIn <nikita.vyach.ivanov@gmail.com> 1609841455 +0500 push
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
f803c64d11407b23797325e3843f3f378b78f611
|
||||
181c757cca395d4da18701d069a6b8123e88e040
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
require File.expand_path '../../lib/gollum/views/commit', __FILE__
|
||||
|
||||
def get_commit_diff(sha1)
|
||||
commit = @wiki.repo.commit(sha1)
|
||||
@wiki.repo.diff(commit.parent.id, sha1)
|
||||
end
|
||||
|
||||
context "Precious::Views::Compare" do
|
||||
setup do
|
||||
@path = cloned_testpath('examples/lotr.git')
|
||||
# Precious::App.set(:gollum_path, @path)
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
|
||||
test 'file addition diff' do
|
||||
view = Precious::Views::Compare.new
|
||||
diff = get_commit_diff 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb'
|
||||
view.instance_variable_set(:@diff, diff)
|
||||
|
||||
assert_equal [
|
||||
{:line=>"@@ -0,0 +1 @@", :class=>"gc", :ldln=>"...", :rdln=>"..."},
|
||||
{:line=>"+# Eye Of Sauron", :class=>"gi", :ldln=>" ", :rdln=>"1"}
|
||||
], view.lines
|
||||
end
|
||||
|
||||
test 'empty file addition diff' do
|
||||
view = Precious::Views::Compare.new
|
||||
diff = get_commit_diff '181c757cca395d4da18701d069a6b8123e88e040'
|
||||
view.instance_variable_set(:@diff, diff)
|
||||
|
||||
assert_equal [], view.lines
|
||||
end
|
||||
|
||||
test 'binary file addition diff' do
|
||||
view = Precious::Views::Compare.new
|
||||
diff = get_commit_diff 'afe2034d400ba21e13361f38f74900c51dbc7fde'
|
||||
view.instance_variable_set(:@diff, diff)
|
||||
|
||||
lines = view.lines
|
||||
line = lines[0].delete :line
|
||||
|
||||
assert_match %r{Binary files (/dev/null and b/Mordor/eye.jpg )?differ}, line
|
||||
assert_equal [{:class=>"gg", :ldln=>"...", :rdln=>"..."}], lines
|
||||
end
|
||||
end
|
||||
@@ -35,9 +35,11 @@ context 'Precious::Views::LatestChanges' do
|
||||
get(@url)
|
||||
body = last_response.body
|
||||
|
||||
commits_list_elements = body.scan(%r{<li class="Box-row Box-row--hover-gray border-top d-flex flex-items-center">})
|
||||
assert !commits_list_elements.nil?, "the commits should be listed with this tag"
|
||||
assert commits_list_elements.length == 10, "/latest_changes should include the :pagination_count commit"
|
||||
|
||||
assert body.include?("Charles Pence</span>"), "/latest_changes should include Author Charles Pence"
|
||||
assert body.include?('1db89eb'), "/latest_changes should include the :pagination_count commit"
|
||||
assert !body.include?('a8ad3c0'), "/latest_changes should not include more than :pagination_count commits"
|
||||
assert body.include?('<a href="/Data-Two.csv/874f597a5659b4c3b153674ea04e406ff393975e">Data-Two.csv</a>'), "/latest_changes include links to modified files in #{body}"
|
||||
assert body.include?('<a href="/Hobbit.md/874f597a5659b4c3b153674ea04e406ff393975e">Hobbit.md</a>'), "/latest_changes should include links to modified pages in #{body}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user