-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d31abc
commit 413b353
Showing
12 changed files
with
112 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.pre.scroll | ||
.diff{ class: "digits-#{diff.max_digits}" }> | ||
- diff.lines&.each do |line| | ||
- id = "diff_#{file_index}_n#{line.index}" | ||
%div{ class: "line #{line.state}", id: }> | ||
- case line.state | ||
- when 'comment', 'range' | ||
.offset | ||
.text-muted.text | ||
= line.content | ||
- else | ||
= link_to("##{id}", class: 'd-flex') do | ||
.number< | ||
= line.original_index | ||
.number< | ||
= line.changed_index | ||
.value< | ||
%span.character>< | ||
= line.content[0] | ||
%span.content>< | ||
= line.content[1..] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class DiffComponent < ApplicationComponent | ||
attr_reader :diff, :file_index | ||
|
||
def initialize(diff:, file_index:) | ||
super | ||
@diff = parse_diff(diff) | ||
@file_index = file_index | ||
end | ||
|
||
def render? | ||
diff.present? | ||
end | ||
|
||
private | ||
|
||
def parse_diff(content) | ||
DiffParser.new(content: content).call | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- diff_list.each_with_index do |(name, file_info), file_index| | ||
- state = file_info['state'] | ||
.accordion.mb-2{ id: "diff-list-#{name.parameterize}" } | ||
.accordion-item | ||
%h2.accordion-header | ||
%button.accordion-button.text-bg-light{ type: 'button', data: { 'bs-toggle': 'collapse', | ||
'bs-target': "#diff-item-#{name.parameterize}" }, | ||
aria: { expanded: 'true', controls: "diff-item-#{name.parameterize}" } } | ||
- if (old_file = file_info['old']) | ||
= changed_filename(old_file['name'], name, state) | ||
- else | ||
= name | ||
%span.badge.ms-1{ class: badge_for_state(state) }= state.capitalize | ||
.accordion-collapse.collapse{ class: expand?(name, state) ? 'show' : '', id: "diff-item-#{name.parameterize}", 'data-object': view_id } | ||
= render(DiffComponent.new(diff: file_info.dig('diff', '_content'), file_index:)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
class DiffListComponent < ApplicationComponent | ||
attr_reader :diff_list, :view_id | ||
|
||
def initialize(diff_list:, view_id: nil) | ||
super | ||
@diff_list = diff_list | ||
@view_id = view_id | ||
end | ||
|
||
def badge_for_state(state) | ||
return 'text-bg-success' if state == 'added' | ||
return 'text-bg-danger' if state == 'deleted' | ||
|
||
'text-bg-info' | ||
end | ||
|
||
def changed_filename(old_filename, new_filename, state) | ||
return new_filename unless ['changed', 'renamed'].include?(state) | ||
return new_filename if old_filename == new_filename | ||
|
||
"#{old_filename} -> #{new_filename}" | ||
end | ||
|
||
def expand?(filename, state) | ||
state != 'deleted' && filename.exclude?('/') && (filename == '_patchinfo' || filename.ends_with?('.spec', '.changes')) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters