Project

General

Profile

Patch #38278 » improve_display_revision.patch

Patch - Niklaus Giger, 2023-02-16 17:17

View differences:

app/helpers/repositories_helper.rb (working copy)
326 326
    end
327 327
    max_space
328 328
  end
329

  
330
  def has_branch_detail?
331
    @repository.scm.respond_to? :branch_contains
332
  end
333

  
334
  def insert_branches_detail(html)
335
    return html unless has_branch_detail?
336
    substring = '</li>'
337
    location = html.index(substring).to_i + substring.length
338
    html.insert(location, branches_html)
339
  end
340

  
341
  def branches_html
342
    content_tag(:li) do
343
      content = content_tag(:strong, "#{l(:label_branch)}")
344
      content << " "
345
      content << "#{@repository.identifier}@ "
346
      content << links_to_branches.join(', ').html_safe
347
    end
348
  end
349

  
350
  def links_to_branches
351
    return [] unless has_branch_detail?
352
    branch_groups.map { |name, branches| branches_link(name, branches) }
353
  end
354

  
355
  def branches_link(name, branches)
356
    return branch_link(branches.first) if branches.length == 1
357
    link =  link_to("[#{name}...]", 'javascript:;', class: 'scm-branch-group').html_safe
358
    content_tag(:span, class: 'scm-branch-hide') do
359
      link << content_tag(:span, class: 'scm-branches') do
360
        branches.map { |branch| branch_link(branch) }.join(', ').html_safe
361
      end
362
    end
363
  end
364

  
365
  def branch_link(branch)
366
    link_to(branch, {:controller => 'repositories',
367
                     :action => 'show',
368
                     :id => @repository.project,
369
                     :repository_id => @repository.identifier,
370
                     :path => to_path_param(@path),
371
                     :rev => branch}).html_safe
372
  end
373

  
374
  def branch_groups
375
    @repository.scm.branch_contains(@rev).group_by do |branch|
376
      branch.downcase
377
        .gsub(/^\d+/, '#####')
378
        .split(/[\-\._]/)
379
        .first
380
    end.sort_by { |name, branches| [branches.length, name] }
381
  end
382

  
383

  
329 384
end
app/views/issues/tabs/_changesets.html.erb (working copy)
7 7
    </h4>
8 8
    <p>
9 9
    <%= "#{changeset.project.name} - " unless changeset.project == project %>
10
    <%= if Setting.display_repository_base_name?
11
        changeset.repository.url.split('/').last.sub('.git','') + ': '
12
        end %>
10 13
    <%= link_to_revision(changeset, changeset.repository,
11 14
                        :text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
12 15
    <% if changeset.filechanges.any? && User.current.allowed_to?(:browse_repository, changeset.project) %>
......
17 20
           :repository_id => changeset.repository.identifier_param,
18 21
           :path   => "",
19 22
           :rev    => changeset.identifier) %>)
23
      <% if !Setting.display_under_associated_revisions? && changeset.scmid.present?
24
           @repository = changeset.repository
25
           @rev = changeset.identifier
26
      %>
27
         (<em><%= l(:label_branches) %>: <%= links_to_branches.join(', ').html_safe %></em>)
28
      <% end %>
20 29
    <% end %></p>
21 30

  
22 31
    <div class="wiki changeset-comments">
app/views/repositories/_changeset.html.erb (working copy)
20 20
              }.join(", ").html_safe %>
21 21
      </li>
22 22
    <% end %>
23
      <% if !Setting.display_under_single_revision? %>
24
      <li>
25
        <strong><%= l(:label_branches) %></strong>
26
        <%=  links_to_branches.join(', ').html_safe %>
27
      </li>
28
      <% end %>
29

  
23 30
    <% if @changeset.children.present? %>
24 31
      <li>
25 32
        <strong><%= l(:label_child_revision) %></strong>
app/views/settings/_issues.html.erb (working copy)
24 24
<p><%= setting_text_field :gantt_items_limit, :size => 6 %></p>
25 25

  
26 26
<p><%= setting_text_field :gantt_months_limit, :size => 6 %></p>
27

  
27 28
</div>
29
<fieldset class="box">
30
  <legend><%= l(:label_display_revision_branches) %></legend>
31
  <div class="tabular settings">
32
<p><%= setting_check_box :display_under_single_revision %></p>
28 33

  
34
<p><%= setting_check_box :display_under_associated_revisions %></p>
35

  
36
<p><%= setting_check_box :display_repository_base_name %></p>
37
  </div>
38
</fieldset>
39

  
29 40
<fieldset class="box">
30 41
  <legend><%= l(:label_parent_task_attributes) %></legend>
31 42
  <div class="tabular settings">
config/locales/de.yml (working copy)
461 461
  label_board_sticky: Wichtig (immer oben)
462 462
  label_boolean: Boolean
463 463
  label_branch: Zweig
464
  label_branches: Zweige
464 465
  label_browse: Codebrowser
465 466
  label_bulk_edit_selected_issues: Alle ausgewählten Tickets bearbeiten
466 467
  label_bulk_edit_selected_time_entries: Ausgewählte Zeitaufwände bearbeiten
......
1005 1006
  setting_default_projects_tracker_ids: Standardmäßig aktivierte Tracker für neue Projekte
1006 1007
  setting_diff_max_lines_displayed: Maximale Anzahl anzuzeigender Diff-Zeilen
1007 1008
  setting_display_subprojects_issues: Tickets von Unterprojekten im Hauptprojekt anzeigen
1009
  setting_display_under_single_revision: Unterschiede bei Revision anzeigen
1010
  setting_display_under_associated_revisions: Bei zugehörigen Revisionen anzeigen
1011
  setting_display_repository_base_name: Name des zugehörigen Repository anzeigen
1008 1012
  setting_emails_footer: E-Mail-Fußzeile
1009 1013
  setting_emails_header: E-Mail-Kopfzeile
1010 1014
  setting_enabled_scm: Aktivierte Versionskontrollsysteme
......
1303 1307
  label_ends_with: endet mit
1304 1308
  label_issue_fixed_version_updated: Zielversion aktualisiert
1305 1309
  setting_project_list_defaults: Voreinstellungen Projektliste
1310
  label_display_revision_branches: Zweige zur Revision anzeigen
1306 1311
  label_display_type: Ergebnisse anzeigen als
1307 1312
  label_display_type_list: Liste
1308 1313
  label_display_type_board: Karte
config/locales/en.yml (working copy)
443 443
  setting_time_format: Time format
444 444
  setting_timespan_format: Time span format
445 445
  setting_cross_project_issue_relations: Allow cross-project issue relations
446
  setting_display_under_single_revision: Display revision under Single Revision
447
  setting_display_under_associated_revisions: Display revision under Associated Revisions
448
  setting_display_repository_base_name: Display basename of associated repository
446 449
  setting_cross_project_subtasks: Allow cross-project subtasks
447 450
  setting_issue_list_default_columns: Issues list defaults
448 451
  setting_repositories_encodings: Attachments and repositories encodings
......
823 826
  label_repository_plural: Repositories
824 827
  label_browse: Browse
825 828
  label_branch: Branch
829
  label_branches: Branches
826 830
  label_tag: Tag
827 831
  label_revision: Revision
828 832
  label_revision_plural: Revisions
......
947 951
  label_registration_manual_activation: manual account activation
948 952
  label_registration_automatic_activation: automatic account activation
949 953
  label_display_per_page: "Per page: %{value}"
954
  label_display_revision_branches: Show branches for revision
950 955
  label_age: Age
951 956
  label_change_properties: Change properties
952 957
  label_general: General
config/settings.yml (working copy)
226 226
issue_list_default_totals:
227 227
  serialized: true
228 228
  default: []
229
display_under_single_revision:
230
  default: true
231
display_under_associated_revisions:
232
  default: true
229 233
display_subprojects_issues:
230 234
  default: 1
235
display_repository_base_name:
236
  default: true
231 237
time_entry_list_defaults:
232 238
  serialized: true
233 239
  default:
lib/redmine/scm/adapters/git_adapter.rb (working copy)
98 98
        rescue ScmCommandAborted
99 99
          nil
100 100
        end
101
        
102
        def branch_contains(hash)
103
          cleaned_hash = hash.sub(/[^\w]/, '')
104
          cmd_args = ['branch', '--contains', cleaned_hash]
105
          begin
106
            branches = git_cmd(cmd_args) do |io|
107
              io.readlines.sort!.map{|t| t.strip.gsub(/\* ?/, '')}
108
            end
109
          rescue ScmCommandAborted
110
            branches = Array.new
111
          end
112
          branches.uniq
113
        end
101 114

  
102 115
        def tags
103 116
          return @tags if @tags
public/javascripts/repository_navigation.js (working copy)
33 33
      $('#branch,#tag').removeAttr('disabled');
34 34
    }
35 35
  });
36

  
37
  $('a.scm-branch-group').on('click', function() {
38
    $(this).parent().removeClass('scm-branch-hide');
39
  });
36 40
})
public/stylesheets/scm.css (working copy)
126 126
.breadcrumbs>.separator::before, .breadcrumbs>.separator::after {
127 127
    content: " ";
128 128
}
129

  
130
.scm-branch-group, .scm-branch-hide > .scm-branches { display: none; }
131
.scm-branch-hide > .scm-branch-group { display: inline; }
(3-3/4)