diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 74528305c6..e584f8819e 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -91,6 +91,27 @@ module RepositoriesHelper render_changes_tree(tree[:s]) end + # Mapping from internal action to (folder|file)-icon type + def change_action_mapping + { + 'A' => :add, + 'B' => :remove + } + end + + # This calculates whether a folder was added, deleted or modified. It is based on the assumption that + # a folder was added/deleted when all content was added/deleted since the folder changes were not tracked. + def calculate_folder_action(tree) + seen = Set.new + tree.each do |_, entry| + if folderStyle = change_action_mapping[entry[:c].try(:action)] + seen << folderStyle + end + end + + seen.size == 1 ? seen.first : :open + end + def render_changes_tree(tree) return '' if tree.nil? @@ -108,7 +129,8 @@ module RepositoriesHelper project_id: @project, path: path_param, rev: @changeset.identifier) - output << "
  • #{text}
  • " + + output << "
  • #{text}
  • " output << render_changes_tree(s) elsif c = tree[file][:c] style << " change-#{c.action}" diff --git a/lib/redmine/unified_diff.rb b/lib/redmine/unified_diff.rb index 8105b94f40..2430217891 100644 --- a/lib/redmine/unified_diff.rb +++ b/lib/redmine/unified_diff.rb @@ -236,7 +236,7 @@ module Redmine def html_line_left if offsets - line_left.dup.insert(offsets.first, '').insert(offsets.last, '').html_safe + line_left.dup.insert(offsets.first, '').insert(offsets.last, '') else line_left end @@ -244,7 +244,7 @@ module Redmine def html_line_right if offsets - line_right.dup.insert(offsets.first, '').insert(offsets.last, '').html_safe + line_right.dup.insert(offsets.first, '').insert(offsets.last, '') else line_right end @@ -252,7 +252,7 @@ module Redmine def html_line if offsets - line.dup.insert(offsets.first, '').insert(offsets.last, '').html_safe + line.dup.insert(offsets.first, '').insert(offsets.last, '') else line end