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 << "