Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/views/status.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<style>
.unchanged {
display: none !important;
}
.commit:hover {
color: red;
}
Expand Down Expand Up @@ -191,8 +194,9 @@
</a>

<div id="latest_diff_html" class="collapse">
<iframe srcdoc="<%= @last_diff_html %>" width="100%" height="400" class="mb-3">
</iframe>
<div>
<%= @last_diff_html %>
</div>
</div>
</div>

Expand Down
5 changes: 2 additions & 3 deletions lib/web_git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ class Server < Sinatra::Base
@diff = Diff.diff_to_html(git.diff.to_s)
last_diff = nil
if git.log.count > 1
last_diff = git.diff(git.log[1], "HEAD").to_s + "\n"
last_diff = git.diff("HEAD~1", "HEAD").to_s + "\n"
end
# @last_diff_html = Diff.last_to_html(last_diff)
@last_diff_html = last_diff
@last_diff_html = Diff.last_to_html(last_diff)
@branches = git.branches.local.map(&:full)

logs = git.log
Expand Down
11 changes: 6 additions & 5 deletions lib/web_git/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def self.get_last_diff
end

def self.get_last_left(diff)
filenames = get_file_names(get_last_commit_hash)
filenames = get_file_names("HEAD~1")
files = file_diffs(diff)
ones = {}
files.each_with_index do |file, i|
Expand All @@ -139,7 +139,7 @@ def self.get_last_left(diff)
end

def self.get_last_right(diff)
filenames = get_file_names(get_last_commit_hash)
filenames = get_file_names("HEAD~1")
files = file_diffs(diff)
ones = {}
files.each_with_index do |file, i|
Expand Down Expand Up @@ -172,14 +172,15 @@ def self.last_to_html(diff)
html_output += '<style>'
html_output += Diffy::CSS
html_output += '</style>'
html_output += '<div class="card">'
html_output += '<div class="card" style="overflow-y: scroll;max-height:400px">'
left_hash.keys.each do |file|
html_output += '<div class="file mb-4 p-3">'
html_output += '<div class="file mb-4 p-1">'
html_output += '<h4>' + file + '</h4>'
html_output += Diffy::Diff.new(
left_hash[file],
right_hash[file],
:include_plus_and_minus_in_html => true
:include_plus_and_minus_in_html => true,
:allow_empty_diff => false
).to_s(:html)
html_output += '</div>'
end
Expand Down